delete command
This commit is contained in:
parent
7a0ab2271d
commit
a7c65df5e0
1 changed files with 15 additions and 1 deletions
|
|
@ -881,10 +881,24 @@ export class CommandController extends Controller {
|
|||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "COMMAND");
|
||||
const command = await this.commandRepository.findOne({ where: { id: id } });
|
||||
const command = await this.commandRepository.findOne({
|
||||
where: { id: id },
|
||||
relations: ["commandType", "commandRecives"],
|
||||
});
|
||||
if (!command) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
|
||||
}
|
||||
|
||||
const path = commandTypePath(command.commandType.code);
|
||||
if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
|
||||
await new CallAPI()
|
||||
.PostData(request, path + "/delete", {
|
||||
refIds: command.commandRecives.map((x) => x.refId),
|
||||
})
|
||||
.then(async (res) => {})
|
||||
.catch(() => {});
|
||||
|
||||
await this.commandReciveRepository.delete({ commandId: command.id });
|
||||
command.status = "CANCEL";
|
||||
command.lastUpdateUserId = request.user.sub;
|
||||
command.lastUpdateFullName = request.user.name;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue