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',
})
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[],
tenantId?: string,
): Promise<BatchResult> {
this.batchDeleteManager.setData(dataIds);
this.batchDeleteManager.setService(this.serviceData, TABLE_NAME.ITEM);
await this.batchDeleteManager.execute();
return this.batchDeleteManager.getResult();
console.log('batch delete item tenant');
return;
// this.batchDeleteManager.setData(dataIds);
// this.batchDeleteManager.setService(this.serviceData, TABLE_NAME.ITEM);
// await this.batchDeleteManager.execute();
// return this.batchDeleteManager.getResult();
}
async active(dataId, tenantId?: string): Promise<string> {

View File

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

View File

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