no message

This commit is contained in:
Bright 2025-09-29 15:01:01 +07:00
parent a7ada56745
commit e63799eb00

View file

@ -3023,15 +3023,24 @@ export class CommandController extends Controller {
@Request() req: RequestWithUser,
@Body()
body: {
commandId: string[];
resignId: string[];
},
) {
const commands = await this.commandRepository.find({ where: { id: In(body.commandId) } });
const data = commands.map((_data) => ({
..._data,
status: "CANCEL",
}));
await this.commandRepository.save(data);
const _refId = Array.from(new Set(body.resignId));
// 1. ดึง commandRecive ที่ refId ตรงกับ resignId
const commandRecives = await this.commandReciveRepository.find({
select: ["commandId"],
where: { refId: In(_refId) },
});
// 2. ดึง commandId ที่ไม่ซ้ำ
const commandIds = Array.from(new Set(commandRecives.map(x => x.commandId).filter(Boolean)));
// 3. อัปเดต status ของ command
if (commandIds.length > 0) {
await this.commandRepository.update(
{ id: In(commandIds) },
{ status: "CANCEL" }
);
}
return new HttpSuccess();
}