no message
This commit is contained in:
parent
a7ada56745
commit
e63799eb00
1 changed files with 16 additions and 7 deletions
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue