From e340b6d8a8f1f0204bc2cf77250b5fca8124a02d Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 26 Sep 2024 16:05:59 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1re?= =?UTF-8?q?port?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 82 ++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 37688a0e..b1f981af 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -29,6 +29,7 @@ import { CommandSendCC } from "../entities/CommandSendCC"; import { CommandSalary } from "../entities/CommandSalary"; import { CommandRecive } from "../entities/CommandRecive"; import HttpStatus from "../interfaces/http-status"; +import Extension from "../interfaces/extension"; @Route("api/v1/org/command") @Tags("Command") @@ -697,6 +698,9 @@ export class CommandController extends Controller { if (!command) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้"); } + await this.commandSendCCRepository.delete({ commandSend: { commandId: command.id } }); + await this.commandReciveRepository.delete({ commandId: command.id }); + await this.commandSendRepository.delete({ commandId: command.id }); await this.commandRepository.delete(command.id); return new HttpSuccess(); } @@ -838,4 +842,82 @@ export class CommandController extends Controller { await this.commandRepository.save(command); return new HttpSuccess(); } + + /** + * API รายละเอียดรายการคำสั่ง tab4 คำสั่ง + * + * @summary API รายละเอียดรายการคำสั่ง tab4 คำสั่ง + * + * @param {string} id Id คำสั่ง + */ + @Get("tab4/cover/{id}") + async GetByIdTab4Cover(@Path() id: string) { + const command = await this.commandRepository.findOne({ + where: { id }, + relations: ["commandType"], + }); + if (!command) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้"); + } + + const _command = { + issue: "...................................", + commandNo: command.commandNo, + commandYear: command.commandYear, + commandTitle: command.issue, + detailHeader: command.detailHeader, + detailBody: command.detailBody, + detailFooter: command.detailFooter, + commandDate: Extension.ToThaiNumber(Extension.ToThaiFullDate2(command.commandAffectDate)), + commandExcecuteDate: Extension.ToThaiNumber( + Extension.ToThaiFullDate2(command.commandExcecuteDate), + ), + name: "...................................", + position: "...................................", + }; + return new HttpSuccess({ + template: command.commandType.fileCover, + reportName: "docx-report", + data: { _command }, + }); + } + + /** + * API รายละเอียดรายการคำสั่ง tab4 แนบท้าย + * + * @summary API รายละเอียดรายการคำสั่ง tab4 แนบท้าย + * + * @param {string} id Id คำสั่ง + */ + @Get("tab4/attachment/{id}") + async GetByIdTab4Attachment(@Path() id: string) { + const command = await this.commandRepository.findOne({ + where: { id }, + relations: ["commandType"], + }); + if (!command) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้"); + } + + const _command = { + issue: "...................................", + commandNo: command.commandNo, + commandYear: command.commandYear, + commandTitle: command.issue, + detailHeader: command.detailHeader, + detailBody: command.detailBody, + detailFooter: command.detailFooter, + commandDate: Extension.ToThaiNumber(Extension.ToThaiFullDate2(command.commandAffectDate)), + commandExcecuteDate: Extension.ToThaiNumber( + Extension.ToThaiFullDate2(command.commandExcecuteDate), + ), + name: "...................................", + position: "...................................", + }; + return new HttpSuccess({ + template: command.commandType.fileAttachment, + reportName: "xlsx-report", + data: { _command }, + }); + } }