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, @Request() req: RequestWithUser,
@Body() @Body()
body: { body: {
commandId: string[]; resignId: string[];
}, },
) { ) {
const commands = await this.commandRepository.find({ where: { id: In(body.commandId) } }); const _refId = Array.from(new Set(body.resignId));
const data = commands.map((_data) => ({ // 1. ดึง commandRecive ที่ refId ตรงกับ resignId
..._data, const commandRecives = await this.commandReciveRepository.find({
status: "CANCEL", select: ["commandId"],
})); where: { refId: In(_refId) },
await this.commandRepository.save(data); });
// 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(); return new HttpSuccess();
} }