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 { protected oldBasePrice: number; async validateProcess(): Promise { return; } async beforeProcess(): Promise { this.oldBasePrice = this.oldData.base_price; return; } async afterProcess(): Promise { 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, }, ]; } }