feat(SPG-777): add validation delete for tenant item bundling

pull/52/head
Firman Ramdhani 2024-08-06 11:33:51 +07:00
parent ebfcbb85fe
commit e922db827d
4 changed files with 33 additions and 6 deletions

View File

@ -116,4 +116,19 @@ export class ItemModel
onUpdate: 'CASCADE', onUpdate: 'CASCADE',
}) })
gates: GateModel[]; gates: GateModel[];
// relasi untuk mendapatkan parent bundling
@ManyToMany(() => ItemModel, (model) => model.bundling_parents)
@JoinTable({
name: 'item_bundlings',
joinColumn: {
name: 'item_id',
referencedColumnName: 'id',
},
inverseJoinColumn: {
name: 'item_bundling_id',
referencedColumnName: 'id',
},
})
bundling_parents: ItemModel[];
} }

View File

@ -82,10 +82,12 @@ export class ItemDataOrchestrator extends BaseDataTransactionOrchestrator<ItemEn
dataIds: string[], dataIds: string[],
tenantId?: string, tenantId?: string,
): Promise<BatchResult> { ): Promise<BatchResult> {
this.batchDeleteManager.setData(dataIds); console.log('batch delete item tenant');
this.batchDeleteManager.setService(this.serviceData, TABLE_NAME.ITEM); return;
await this.batchDeleteManager.execute(); // this.batchDeleteManager.setData(dataIds);
return this.batchDeleteManager.getResult(); // this.batchDeleteManager.setService(this.serviceData, TABLE_NAME.ITEM);
// await this.batchDeleteManager.execute();
// return this.batchDeleteManager.getResult();
} }
async active(dataId, tenantId?: string): Promise<string> { async active(dataId, tenantId?: string): Promise<string> {

View File

@ -26,7 +26,12 @@ export class BatchDeleteItemManager extends BaseBatchDeleteManager<ItemEntity> {
} }
get validateRelations(): validateRelations[] { get validateRelations(): validateRelations[] {
return []; return [
{
relation: 'bundling_parents',
message: `Gagal! Item sudah berelasi dengen bundling`,
},
];
} }
get entityTarget(): any { get entityTarget(): any {

View File

@ -29,7 +29,12 @@ export class DeleteItemManager extends BaseDeleteManager<ItemEntity> {
} }
get validateRelations(): validateRelations[] { get validateRelations(): validateRelations[] {
return []; return [
{
relation: 'bundling_parents',
message: `Gagal! Item sudah berelasi dengen bundling`,
},
];
} }
get entityTarget(): any { get entityTarget(): any {