From 2bfb36fd8ab6c52d915b89de3c6b87ee786212d1 Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 18 Oct 2024 17:35:04 +0700 Subject: [PATCH 1/8] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=20link=20noti?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 111 ++++----------------------- src/interfaces/utils.ts | 100 ++++++++++++++++++++++-- 2 files changed, 108 insertions(+), 103 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 27778027..0cef3336 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -36,6 +36,8 @@ import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory"; import { calculateRetireDate, calculateRetireLaw, + commandTypePath, + commandTypePathLink, removeProfileInOrganize, setLogDataDiff, } from "../interfaces/utils"; @@ -556,7 +558,7 @@ export class CommandController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ได้รับคำสั่ง"); } - const path = this.commandTypePath(commandRecive.command.commandType.code); + const path = commandTypePath(commandRecive.command.commandType.code); if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); await new CallAPI() .PostData(request, path + "/delete", { @@ -863,7 +865,7 @@ export class CommandController extends Controller { where: { commandId: id }, }); - const path = this.commandTypePath(command.commandType.code); + const path = commandTypePath(command.commandType.code); if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); await new CallAPI() .PostData(request, path + "/delete", { @@ -1013,7 +1015,12 @@ export class CommandController extends Controller { let profiles = command && command.commandRecives.length > 0 - ? command.commandRecives.filter((x) => x.profileId != null).map((x) => x.profileId) + ? command.commandRecives + .filter((x) => x.profileId != null) + .map((x) => ({ + profileId: x.profileId, + notiLink: `${process.env.API_URL}${commandTypePathLink(command.commandType.code)}/${x.refId}`, + })) : []; await new CallAPI() @@ -1022,7 +1029,6 @@ export class CommandController extends Controller { body: `${command.issue}`, receiverUserIds: profiles, payload: "", //แนบไฟล์ - notiLink: "", //แนบไฟล์ isSendMail: true, isSendInbox: true, isSendNotification: true, @@ -1044,7 +1050,7 @@ export class CommandController extends Controller { command.lastUpdatedAt = new Date(); await this.commandRepository.save(command); } else { - const path = this.commandTypePath(command.commandType.code); + const path = commandTypePath(command.commandType.code); if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); const msg = { data: { @@ -1101,7 +1107,7 @@ export class CommandController extends Controller { } command.forEach(async (x) => { - const path = this.commandTypePath(x.commandType.code); + const path = commandTypePath(x.commandType.code); if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); const msg = { data: { @@ -1213,7 +1219,7 @@ export class CommandController extends Controller { } let _command: any = []; - const path = this.commandTypePath(command.commandType.code); + const path = commandTypePath(command.commandType.code); if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); await new CallAPI() .PostData(request, path + "/attachment", { @@ -1366,7 +1372,7 @@ export class CommandController extends Controller { await this.commandRepository.save(command); } - const path = this.commandTypePath(commandCode); + const path = commandTypePath(commandCode); if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); await new CallAPI() .PostData(request, path, { @@ -2845,93 +2851,4 @@ export class CommandController extends Controller { await this.posMasterRepository.save(data); return new HttpSuccess(); } - - commandTypePath(commandCode: string) { - switch (commandCode) { - case "C-PM-01": - return "/placement/recruit/report"; // - case "C-PM-02": - return "/placement/candidate/report"; // - case "C-PM-03": - return "/placement/appoint/report"; - case "C-PM-04": - return "/placement/move/report"; - case "C-PM-05": - return "/placement/appointment/appoint/report"; - case "C-PM-06": - return "/placement/slip/report"; - case "C-PM-07": - return "/placement/appointment/move/report"; - case "C-PM-08": - return "/retirement/other/appoint/report"; - case "C-PM-09": - return "/retirement/other/out/report"; - case "C-PM-10": - return "/probation/report/command10/officer/report"; - case "C-PM-11": - return "/probation/report/command11/officer/report"; - case "C-PM-12": - return "/probation/report/command12/officer/report"; - case "C-PM-13": - return "/placement/transfer/command/report"; - case "C-PM-14": - return "/placement/receive/command/report"; - case "C-PM-15": - return "/placement/officer/command/report"; - case "C-PM-16": - return "/placement/repatriation/command/report"; - case "C-PM-17": - return "/retirement/resign/command/report"; - case "C-PM-18": - return "/retirement/out/command/report"; - case "C-PM-19": - return "/discipline/result/command19/report"; - case "C-PM-20": - return "/discipline/result/command20/report"; - case "C-PM-21": - return "/org/command/command21/employee/report"; - case "C-PM-22": - return "/placement/appointment/employee-appoint/report"; - case "C-PM-23": - return "/retirement/resign/employee/report"; - case "C-PM-24": - return "/placement/appointment/employee-move/report"; - case "C-PM-25": - return "/discipline/result/command25/report"; - case "C-PM-26": - return "/discipline/result/command26/report"; - case "C-PM-27": - return "/discipline/result/command27/report"; - case "C-PM-28": - return "/discipline/result/command28/report"; - case "C-PM-29": - return "/discipline/result/command29/report"; - case "C-PM-30": - return "/discipline/result/command30/report"; - case "C-PM-31": - return "/discipline/result/command31/report"; - case "C-PM-32": - return "/discipline/result/command32/report"; - case "C-PM-33": - return "/salary/report/command/officer/report"; - case "C-PM-34": - return "/salary/report/command/officer/report"; - case "C-PM-35": - return "/salary/report/command/officer/report"; - case "C-PM-36": - return "/salary/report/command/employee/report"; - case "C-PM-37": - return "/salary/report/command/employee/report"; - case "C-PM-38": - return "/org/command/command38/officer/report"; - case "C-PM-39": - return "/placement/appointment/slip/report"; - case "C-PM-40": - return "/org/command/command40/officer/report"; - case "C-PM-41": - return "/retirement/resign/leave-cancel/report"; - default: - return null; - } - } } diff --git a/src/interfaces/utils.ts b/src/interfaces/utils.ts index d3f9ded0..192267d0 100644 --- a/src/interfaces/utils.ts +++ b/src/interfaces/utils.ts @@ -213,9 +213,9 @@ export function editLogSequence(req: RequestWithUser, index: number, data: LogSe export function commandTypePath(commandCode: string): string | null { switch (commandCode) { case "C-PM-01": - return "/placement/recruit/report"; + return "/placement/recruit/report"; // case "C-PM-02": - return "/placement/candidate/report"; + return "/placement/candidate/report"; // case "C-PM-03": return "/placement/appoint/report"; case "C-PM-04": @@ -223,7 +223,7 @@ export function commandTypePath(commandCode: string): string | null { case "C-PM-05": return "/placement/appointment/appoint/report"; case "C-PM-06": - return "/placement/appointment/slip/report"; + return "/placement/slip/report"; case "C-PM-07": return "/placement/appointment/move/report"; case "C-PM-08": @@ -231,7 +231,7 @@ export function commandTypePath(commandCode: string): string | null { case "C-PM-09": return "/retirement/other/out/report"; case "C-PM-10": - return "/xxxxxx"; + return "/probation/report/command10/officer/report"; case "C-PM-11": return "/probation/report/command11/officer/report"; case "C-PM-12": @@ -239,7 +239,7 @@ export function commandTypePath(commandCode: string): string | null { case "C-PM-13": return "/placement/transfer/command/report"; case "C-PM-14": - return "/placement/Receive/command/report"; + return "/placement/receive/command/report"; case "C-PM-15": return "/placement/officer/command/report"; case "C-PM-16": @@ -289,7 +289,7 @@ export function commandTypePath(commandCode: string): string | null { case "C-PM-38": return "/org/command/command38/officer/report"; case "C-PM-39": - return "/placement/slip/report"; + return "/placement/appointment/slip/report"; case "C-PM-40": return "/org/command/command40/officer/report"; case "C-PM-41": @@ -299,3 +299,91 @@ export function commandTypePath(commandCode: string): string | null { } } +export function commandTypePathLink(commandCode: string): string | null { + switch (commandCode) { + case "C-PM-01": + return "/placement/personal-detail"; + case "C-PM-02": + return "/placement/personal-detail"; + case "C-PM-03": + return "/placement/personal-detail"; + case "C-PM-04": + return "/placement/personal-detail"; + case "C-PM-05": + return "/xxxxxx"; + case "C-PM-06": + return "/placement/personal-detail"; + case "C-PM-07": + return "/xxxxxx"; + case "C-PM-08": + return "/xxxxxx"; + case "C-PM-09": + return "/xxxxxx"; + case "C-PM-10": + return "/xxxxxx"; + case "C-PM-11": + return "/xxxxxx"; + case "C-PM-12": + return "/xxxxxx"; + case "C-PM-13": + return "/placement/transfer"; + case "C-PM-14": + return "/xxxxxx"; + case "C-PM-15": + return "/xxxxxx"; + case "C-PM-16": + return "/xxxxxx"; + case "C-PM-17": + return "/xxxxxx"; + case "C-PM-18": + return "/xxxxxx"; + case "C-PM-19": + return "/xxxxxx"; + case "C-PM-20": + return "/xxxxxx"; + case "C-PM-21": + return "/xxxxxx"; + case "C-PM-22": + return "/xxxxxx"; + case "C-PM-23": + return "/xxxxxx"; + case "C-PM-24": + return "/xxxxxx"; + case "C-PM-25": + return "/xxxxxx"; + case "C-PM-26": + return "/xxxxxx"; + case "C-PM-27": + return "/xxxxxx"; + case "C-PM-28": + return "/xxxxxx"; + case "C-PM-29": + return "/xxxxxx"; + case "C-PM-30": + return "/xxxxxx"; + case "C-PM-31": + return "/xxxxxx"; + case "C-PM-32": + return "/xxxxxx"; + case "C-PM-33": + return "/xxxxxx"; + case "C-PM-34": + return "/xxxxxx"; + case "C-PM-35": + return "/xxxxxx"; + case "C-PM-36": + return "/xxxxxx"; + case "C-PM-37": + return "/xxxxxx"; + case "C-PM-38": + return "/xxxxxx"; + case "C-PM-39": + return "/xxxxxx"; + case "C-PM-40": + return "/xxxxxx"; + case "C-PM-41": + return "/xxxxxx"; + default: + return null; + } +} From 2637e58b1b265c259785f8c0a43d30a0aae2ea5d Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 18 Oct 2024 17:52:25 +0700 Subject: [PATCH 2/8] no message --- src/controllers/CommandController.ts | 2 +- src/interfaces/utils.ts | 82 ++++++++++++++-------------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 0cef3336..79d4b10f 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -1018,7 +1018,7 @@ export class CommandController extends Controller { ? command.commandRecives .filter((x) => x.profileId != null) .map((x) => ({ - profileId: x.profileId, + receiverUserId: x.profileId, notiLink: `${process.env.API_URL}${commandTypePathLink(command.commandType.code)}/${x.refId}`, })) : []; diff --git a/src/interfaces/utils.ts b/src/interfaces/utils.ts index 192267d0..a3d674ff 100644 --- a/src/interfaces/utils.ts +++ b/src/interfaces/utils.ts @@ -302,87 +302,87 @@ export function commandTypePath(commandCode: string): string | null { export function commandTypePathLink(commandCode: string): string | null { switch (commandCode) { case "C-PM-01": - return "/placement/personal-detail"; + return "placement/personal-detail"; case "C-PM-02": - return "/placement/personal-detail"; + return "placement/personal-detail"; case "C-PM-03": - return "/placement/personal-detail"; + return "placement/personal-detail"; case "C-PM-04": - return "/placement/personal-detail"; + return "placement/personal-detail"; case "C-PM-05": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-06": - return "/placement/personal-detail"; + return "placement/personal-detail"; case "C-PM-07": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-08": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-09": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-10": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-11": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-12": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-13": - return "/placement/transfer"; + return "placement/transfer"; case "C-PM-14": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-15": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-16": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-17": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-18": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-19": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-20": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-21": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-22": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-23": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-24": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-25": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-26": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-27": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-28": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-29": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-30": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-31": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-32": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-33": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-34": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-35": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-36": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-37": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-38": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-39": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-40": - return "/xxxxxx"; + return "xxxxxx"; case "C-PM-41": - return "/xxxxxx"; + return "xxxxxx"; default: return null; } From 5bf3beb30b797901ab75034df631ab31768d2ab6 Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 18 Oct 2024 17:56:00 +0700 Subject: [PATCH 3/8] no message --- src/controllers/CommandController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 79d4b10f..d4b19d46 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -1019,7 +1019,7 @@ export class CommandController extends Controller { .filter((x) => x.profileId != null) .map((x) => ({ receiverUserId: x.profileId, - notiLink: `${process.env.API_URL}${commandTypePathLink(command.commandType.code)}/${x.refId}`, + notiLink: `${commandTypePathLink(command.commandType.code)}/${x.refId}`, })) : []; From d4437c86403514b44a0556caec3c0a5bb14c6db6 Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 18 Oct 2024 18:08:08 +0700 Subject: [PATCH 4/8] noti report --- src/controllers/CommandController.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index d4b19d46..26637b6a 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -1004,7 +1004,7 @@ export class CommandController extends Controller { ) { const command = await this.commandRepository.findOne({ where: { id: id }, - relations: ["commandType", "commandRecives"], + relations: ["commandType", "commandRecives", "commandSends", "commandSends.commandSendCCs"], }); if (!command) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้"); @@ -1036,6 +1036,29 @@ export class CommandController extends Controller { .catch((error) => { console.error("Error calling API:", error); }); + let _profiles = + command && command.commandSends.length > 0 + ? command.commandSends + .filter((x) => x.profileId != null) + .map((x) => ({ + receiverUserId: x.profileId, + notiLink: "", + isSendMail: x.commandSendCCs.map((x) => x.name == "EMAIL").length > 0 ? true : false, + isSendInbox: x.commandSendCCs.map((x) => x.name == "INBOX").length > 0 ? true : false, + isSendNotification: true, + })) + : []; + + await new CallAPI() + .PostData(request, "/placement/noti/profiles", { + subject: `${command.issue}`, + body: `${command.issue}`, + receiverUserIds: _profiles, + payload: "", //แนบไฟล์ + }) + .catch((error) => { + console.error("Error calling API:", error); + }); if ( new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()) < new Date( From ed134d87f72f89979578d6a3db5ea3af16db8188 Mon Sep 17 00:00:00 2001 From: kittapath Date: Sat, 19 Oct 2024 22:29:37 +0700 Subject: [PATCH 5/8] =?UTF-8?q?noti=20=E0=B8=AA=E0=B8=B3=E0=B9=80=E0=B8=99?= =?UTF-8?q?=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 26637b6a..a53b77e3 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -1036,7 +1036,7 @@ export class CommandController extends Controller { .catch((error) => { console.error("Error calling API:", error); }); - let _profiles = + let profilesSend = command && command.commandSends.length > 0 ? command.commandSends .filter((x) => x.profileId != null) @@ -1050,10 +1050,10 @@ export class CommandController extends Controller { : []; await new CallAPI() - .PostData(request, "/placement/noti/profiles", { + .PostData(request, "/placement/noti/profiles-send", { subject: `${command.issue}`, body: `${command.issue}`, - receiverUserIds: _profiles, + receiverUserIds: profilesSend, payload: "", //แนบไฟล์ }) .catch((error) => { From b2ccdfdf3078ddef465307ece423405120485b44 Mon Sep 17 00:00:00 2001 From: kittapath Date: Mon, 21 Oct 2024 10:22:39 +0700 Subject: [PATCH 6/8] ptath workflow --- src/controllers/CommandController.ts | 3 +- src/controllers/WorkflowController.ts | 19 +++- src/entities/Assign.ts | 8 ++ src/interfaces/utils.ts | 89 ------------------- .../1729480130391-update_workflow_add_path.ts | 18 ++++ 5 files changed, 43 insertions(+), 94 deletions(-) create mode 100644 src/migration/1729480130391-update_workflow_add_path.ts diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index a53b77e3..2a9a8772 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -37,7 +37,6 @@ import { calculateRetireDate, calculateRetireLaw, commandTypePath, - commandTypePathLink, removeProfileInOrganize, setLogDataDiff, } from "../interfaces/utils"; @@ -1019,7 +1018,7 @@ export class CommandController extends Controller { .filter((x) => x.profileId != null) .map((x) => ({ receiverUserId: x.profileId, - notiLink: `${commandTypePathLink(command.commandType.code)}/${x.refId}`, + notiLink: "", })) : []; diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index 3619f4bc..7f0b520d 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -16,6 +16,7 @@ import { MetaState } from "../entities/MetaState"; import { MetaStateOperator } from "../entities/MetaStateOperator"; import { PosMaster } from "../entities/PosMaster"; import { IsNull, Not } from "typeorm"; +import { Assign } from "../entities/Assign"; @Route("api/v1/org/workflow") @Tags("Workflow") @@ -32,6 +33,7 @@ export class WorkflowController extends Controller { private metaStateRepo = AppDataSource.getRepository(MetaState); private metaStateOperatorRepo = AppDataSource.getRepository(MetaStateOperator); private posMasterRepo = AppDataSource.getRepository(PosMaster); + private assignRepo = AppDataSource.getRepository(Assign); @Post("add-workflow") public async checkWorkflow( @@ -505,7 +507,7 @@ export class WorkflowController extends Controller { where: { id: body.stateId, }, - relations: ["stateUserComments"], + relations: ["stateUserComments", "workflow"], }); if (!state) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลขั้นตอนการอนุมัติ"); @@ -523,12 +525,23 @@ export class WorkflowController extends Controller { stateUserComment.lastUpdateFullName = req.user.name; stateUserComment.lastUpdatedAt = new Date(); await this.stateUserCommentRepo.save(stateUserComment); - + state.workflow.sysName; + const assign = await this.assignRepo.findOne({ + where: { + id: state.workflow.sysName, + }, + }); + if (!assign) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลขั้นตอนการอนุมัติ"); await new CallAPI() .PostData(req, "/placement/noti/profiles", { subject: `ได้รับรายการ`, body: `ได้รับรายการ`, - receiverUserIds: [body.profileId], + receiverUserIds: [ + { + receiverUserId: body.profileId, + notiLink: `${assign.path}/${state.workflow.refId}`, + }, + ], payload: "", //แนบไฟล์ isSendMail: true, isSendInbox: true, diff --git a/src/entities/Assign.ts b/src/entities/Assign.ts index 96dbaf75..9505f2db 100644 --- a/src/entities/Assign.ts +++ b/src/entities/Assign.ts @@ -61,6 +61,14 @@ export class Assign { }) description: string; + @Column({ + nullable: true, + comment: "path link", + type: "text", + default: null, + }) + path: string; + @OneToMany(() => PosMasterAssign, (posMasterAssign) => posMasterAssign.assign) posMasterAssigns: PosMasterAssign[]; diff --git a/src/interfaces/utils.ts b/src/interfaces/utils.ts index a3d674ff..c2daf911 100644 --- a/src/interfaces/utils.ts +++ b/src/interfaces/utils.ts @@ -298,92 +298,3 @@ export function commandTypePath(commandCode: string): string | null { return null; } } - -export function commandTypePathLink(commandCode: string): string | null { - switch (commandCode) { - case "C-PM-01": - return "placement/personal-detail"; - case "C-PM-02": - return "placement/personal-detail"; - case "C-PM-03": - return "placement/personal-detail"; - case "C-PM-04": - return "placement/personal-detail"; - case "C-PM-05": - return "xxxxxx"; - case "C-PM-06": - return "placement/personal-detail"; - case "C-PM-07": - return "xxxxxx"; - case "C-PM-08": - return "xxxxxx"; - case "C-PM-09": - return "xxxxxx"; - case "C-PM-10": - return "xxxxxx"; - case "C-PM-11": - return "xxxxxx"; - case "C-PM-12": - return "xxxxxx"; - case "C-PM-13": - return "placement/transfer"; - case "C-PM-14": - return "xxxxxx"; - case "C-PM-15": - return "xxxxxx"; - case "C-PM-16": - return "xxxxxx"; - case "C-PM-17": - return "xxxxxx"; - case "C-PM-18": - return "xxxxxx"; - case "C-PM-19": - return "xxxxxx"; - case "C-PM-20": - return "xxxxxx"; - case "C-PM-21": - return "xxxxxx"; - case "C-PM-22": - return "xxxxxx"; - case "C-PM-23": - return "xxxxxx"; - case "C-PM-24": - return "xxxxxx"; - case "C-PM-25": - return "xxxxxx"; - case "C-PM-26": - return "xxxxxx"; - case "C-PM-27": - return "xxxxxx"; - case "C-PM-28": - return "xxxxxx"; - case "C-PM-29": - return "xxxxxx"; - case "C-PM-30": - return "xxxxxx"; - case "C-PM-31": - return "xxxxxx"; - case "C-PM-32": - return "xxxxxx"; - case "C-PM-33": - return "xxxxxx"; - case "C-PM-34": - return "xxxxxx"; - case "C-PM-35": - return "xxxxxx"; - case "C-PM-36": - return "xxxxxx"; - case "C-PM-37": - return "xxxxxx"; - case "C-PM-38": - return "xxxxxx"; - case "C-PM-39": - return "xxxxxx"; - case "C-PM-40": - return "xxxxxx"; - case "C-PM-41": - return "xxxxxx"; - default: - return null; - } -} diff --git a/src/migration/1729480130391-update_workflow_add_path.ts b/src/migration/1729480130391-update_workflow_add_path.ts new file mode 100644 index 00000000..5216b6ab --- /dev/null +++ b/src/migration/1729480130391-update_workflow_add_path.ts @@ -0,0 +1,18 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateWorkflowAddPath1729480130391 implements MigrationInterface { + name = 'UpdateWorkflowAddPath1729480130391' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`assign\` ADD \`path\` text NULL COMMENT 'path link'`); + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` ADD \`commandId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง command'`); + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` ADD CONSTRAINT \`FK_8ba1f49c8315bf86848ebcb29f5\` FOREIGN KEY (\`commandId\`) REFERENCES \`command\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` DROP FOREIGN KEY \`FK_8ba1f49c8315bf86848ebcb29f5\``); + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` DROP COLUMN \`commandId\``); + await queryRunner.query(`ALTER TABLE \`assign\` DROP COLUMN \`path\``); + } + +} From 9abb5ed8e44b26c6e4035a587e0768e6044bdbd1 Mon Sep 17 00:00:00 2001 From: kittapath Date: Mon, 21 Oct 2024 11:12:41 +0700 Subject: [PATCH 7/8] no message --- src/controllers/ProfileEditController.ts | 4 ++-- src/controllers/ProfileEditEmployeeController.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controllers/ProfileEditController.ts b/src/controllers/ProfileEditController.ts index e41c0194..c30a23e9 100644 --- a/src/controllers/ProfileEditController.ts +++ b/src/controllers/ProfileEditController.ts @@ -63,7 +63,7 @@ export class ProfileEditController extends Controller { ); }), ) - .orderBy("ProfileEdit.createdAt", "ASC") + .orderBy("ProfileEdit.createdAt", "DESC") .skip((page - 1) * pageSize) .take(pageSize) .getManyAndCount(); @@ -117,7 +117,7 @@ export class ProfileEditController extends Controller { ); }), ) - .orderBy("ProfileEdit.createdAt", "ASC") + .orderBy("ProfileEdit.createdAt", "DESC") .skip((page - 1) * pageSize) .take(pageSize) .getManyAndCount(); diff --git a/src/controllers/ProfileEditEmployeeController.ts b/src/controllers/ProfileEditEmployeeController.ts index 7d8ef83e..99356803 100644 --- a/src/controllers/ProfileEditEmployeeController.ts +++ b/src/controllers/ProfileEditEmployeeController.ts @@ -68,7 +68,7 @@ export class ProfileEditEmployeeController extends Controller { ); }), ) - .orderBy("ProfileEdit.createdAt", "ASC") + .orderBy("ProfileEdit.createdAt", "DESC") .skip((page - 1) * pageSize) .take(pageSize) .getManyAndCount(); @@ -122,7 +122,7 @@ export class ProfileEditEmployeeController extends Controller { ); }), ) - .orderBy("ProfileEdit.createdAt", "ASC") + .orderBy("ProfileEdit.createdAt", "DESC") .skip((page - 1) * pageSize) .take(pageSize) .getManyAndCount(); From 8d1d5cc45c88340f176294b40c7033375d59c34d Mon Sep 17 00:00:00 2001 From: kittapath Date: Mon, 21 Oct 2024 14:14:55 +0700 Subject: [PATCH 8/8] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B9=80?= =?UTF-8?q?=E0=B8=A0=E0=B8=97=E0=B8=AD=E0=B8=B3=E0=B8=99=E0=B8=A7=E0=B8=A2?= =?UTF-8?q?=E0=B8=81=E0=B8=B2=E0=B8=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/WorkflowController.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index 7f0b520d..06c70ae6 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -639,8 +639,8 @@ export class WorkflowController extends Controller { * * */ - @Get("commander") - async getProfilePlacement(@Request() req: RequestWithUser) { + @Get("commander/{type}") //xxxxxxxxxxxxxxxxxx + async getProfilePlacement(@Request() req: RequestWithUser, @Path() type: string) { const posMasterUser = await this.posMasterRepo.findOne({ where: { orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false }, @@ -657,7 +657,7 @@ export class WorkflowController extends Controller { current_holderId: Not(IsNull()), orgRootId: posMasterUser.orgRootId, }, - relations: ["current_holder", "orgRoot"], + relations: ["current_holder"], }); let _posMasters = posMasters.map((data) => ({ @@ -668,7 +668,6 @@ export class WorkflowController extends Controller { position: data.current_holder.position, posLevel: data.current_holder.posLevel, posType: data.current_holder.posType, - orgRoot: data.orgRoot.orgRootName, })); return new HttpSuccess(_posMasters);