51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
|
import { ItemEntity } from '../../entities/item.entity';
|
|
import {
|
|
EventTopics,
|
|
validateRelations,
|
|
} from 'src/core/strings/constants/interface.constants';
|
|
import { ItemModel } from '../../../data/models/item.model';
|
|
import { ItemChangeStatusEvent } from '../../entities/event/item-change-status.event';
|
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
|
import { Injectable } from '@nestjs/common';
|
|
import { STATUS } from 'src/core/strings/constants/base.constants';
|
|
|
|
@Injectable()
|
|
export class BatchConfirmItemManager extends BaseBatchUpdateStatusManager<ItemEntity> {
|
|
async validateData(data: ItemEntity): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
beforeProcess(): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
afterProcess(): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
get validateRelations(): validateRelations[] {
|
|
return [{
|
|
relation: 'tenant',
|
|
singleQuery: ['status', '!=', STATUS.ACTIVE],
|
|
message: `Failed! Tenant of item must be active first`,
|
|
}];
|
|
}
|
|
|
|
get entityTarget(): any {
|
|
return ItemModel;
|
|
}
|
|
|
|
get eventTopics(): EventTopics[] {
|
|
return [
|
|
{
|
|
topic: ItemChangeStatusEvent,
|
|
},
|
|
];
|
|
}
|
|
|
|
getResult(): BatchResult {
|
|
return this.result;
|
|
}
|
|
}
|