61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { BaseUpdateManager } from 'src/core/modules/domain/usecase/managers/base-update.manager';
|
|
import { ItemEntity } from '../../entities/item.entity';
|
|
import { ItemModel } from '../../../data/models/item.model';
|
|
import { ItemUpdatedEvent } from '../../entities/event/item-updated.event';
|
|
import {
|
|
EventTopics,
|
|
columnUniques,
|
|
validateRelations,
|
|
} from 'src/core/strings/constants/interface.constants';
|
|
|
|
@Injectable()
|
|
export class UpdateItemManager extends BaseUpdateManager<ItemEntity> {
|
|
protected oldBasePrice: number;
|
|
|
|
async validateProcess(): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
async beforeProcess(): Promise<void> {
|
|
this.oldBasePrice = this.oldData.base_price;
|
|
return;
|
|
}
|
|
|
|
async afterProcess(): Promise<void> {
|
|
const newBasePrice = this.result.base_price;
|
|
const itemId = this.result.id;
|
|
|
|
await this.dataService.updateItemRatePrice(
|
|
this.oldBasePrice,
|
|
newBasePrice,
|
|
itemId,
|
|
);
|
|
|
|
if (this.result.breakdown_bundling) {
|
|
this.dataService.updateBreakdownBundling(itemId);
|
|
}
|
|
return;
|
|
}
|
|
|
|
get validateRelations(): validateRelations[] {
|
|
return [];
|
|
}
|
|
|
|
get uniqueColumns(): columnUniques[] {
|
|
return [];
|
|
}
|
|
|
|
get entityTarget(): any {
|
|
return ItemModel;
|
|
}
|
|
|
|
get eventTopics(): EventTopics[] {
|
|
return [
|
|
{
|
|
topic: ItemUpdatedEvent,
|
|
},
|
|
];
|
|
}
|
|
}
|