From 566ac716eefb9675d85214522e8c10a9125bebca Mon Sep 17 00:00:00 2001 From: kittapath Date: Tue, 1 Oct 2024 17:51:48 +0700 Subject: [PATCH 01/12] no message --- src/controllers/CommandController.ts | 250 ++++++++++++++++++++++++--- src/entities/CommandRecive.ts | 51 +++--- src/entities/Profile.ts | 5 - 3 files changed, 253 insertions(+), 53 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 8c2604b9..9544aa3f 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -30,6 +30,8 @@ import { CommandSalary } from "../entities/CommandSalary"; import { CommandRecive } from "../entities/CommandRecive"; import HttpStatus from "../interfaces/http-status"; import Extension from "../interfaces/extension"; +import { ProfileEmployee } from "../entities/ProfileEmployee"; +import CallAPI from "../interfaces/call-api"; @Route("api/v1/org/command") @Tags("Command") @@ -47,6 +49,7 @@ export class CommandController extends Controller { private commandSalaryRepository = AppDataSource.getRepository(CommandSalary); private commandReciveRepository = AppDataSource.getRepository(CommandRecive); private profileRepository = AppDataSource.getRepository(Profile); + private profileEmployeeRepository = AppDataSource.getRepository(ProfileEmployee); private orgRevisionRepo = AppDataSource.getRepository(OrgRevision); /** @@ -276,7 +279,7 @@ export class CommandController extends Controller { prefix: x.prefix, firstName: x.firstName, lastName: x.lastName, - profileId: x.profileId, + // profileId: x.profileId, order: x.order, remarkVertical: x.remarkVertical, remarkHorizontal: x.remarkHorizontal, @@ -858,6 +861,15 @@ export class CommandController extends Controller { ) { command.status = "WAITING"; } else { + let path = this.commandTypePath(command.commandType.name); + if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); + + new CallAPI() + .PostData(request, path + "excecute", { + refIds: command.commandRecives.map((x) => x.refId), + }) + .then(async (res) => {}) + .catch(() => {}); command.status = "REPORTED"; } command.lastUpdateUserId = request.user.sub; @@ -875,7 +887,7 @@ export class CommandController extends Controller { * @param {string} id Id คำสั่ง */ @Get("tab4/cover/{id}") - async GetByIdTab4Cover(@Path() id: string) { + async GetByIdTab4Cover(@Path() id: string, @Request() request: RequestWithUser) { const command = await this.commandRepository.findOne({ where: { id }, relations: ["commandType"], @@ -918,38 +930,230 @@ export class CommandController extends Controller { * @param {string} id Id คำสั่ง */ @Get("tab4/attachment/{id}") - async GetByIdTab4Attachment(@Path() id: string) { + async GetByIdTab4Attachment(@Path() id: string, @Request() request: RequestWithUser) { const command = await this.commandRepository.findOne({ where: { id }, - relations: ["commandType"], + relations: ["commandType", "commandRecives"], }); 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: - command.commandAffectDate == null - ? "" - : Extension.ToThaiNumber(Extension.ToThaiFullDate2(command.commandAffectDate)), - commandExcecuteDate: - command.commandExcecuteDate == null - ? "" - : Extension.ToThaiNumber(Extension.ToThaiFullDate2(command.commandExcecuteDate)), - name: "...................................", - position: "...................................", - }; + let _command: any = []; + let path = this.commandTypePath(command.commandType.name); + if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); + + new CallAPI() + .PostData(request, path + "attachment", { + refIds: command.commandRecives.map((x) => x.refId), + }) + .then(async (res) => { + console.log(res); + _command = res; + }) + .catch(() => {}); + return new HttpSuccess({ template: command.commandType.fileAttachment, reportName: "xlsx-report", data: _command, }); } + + /** + * API สร้างรายการ body คำสั่ง + * + * @summary API สร้างรายการ body คำสั่ง + * + */ + @Post("person") + async PostPerson( + @Body() + requestBody: { + commandTypeId?: string; + commandNo?: string | null; + commandYear?: number | null; + commandId?: string | null; + persons: { + refId: string; + citizenId: string; + prefix: string; + firstName: string; + lastName: string; + }[]; + }, + @Request() request: RequestWithUser, + ) { + let command = new Command(); + if ( + requestBody.commandId != undefined && + requestBody.commandId != null && + requestBody.commandId != "" + ) { + const _command = await this.commandRepository.findOne({ + where: { id: requestBody.commandId }, + relations: ["commandRecives"], + order: { + commandRecives: { + order: "DESC", + }, + }, + }); + if (!_command) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบคำสั่งนี้ในระบบ"); + } + command = _command; + } else { + command = Object.assign(new Command(), requestBody); + const commandType = await this.commandTypeRepository.findOne({ + where: { id: requestBody.commandTypeId }, + }); + + if (!commandType) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); + } + command.detailHeader = commandType.detailHeader; + command.detailBody = commandType.detailBody; + command.detailFooter = commandType.detailFooter; + command.isAttachment = commandType.isAttachment; + command.status = "NEW"; + command.issue = commandType.name; + command.createdUserId = request.user.sub; + command.createdFullName = request.user.name; + command.createdAt = new Date(); + command.lastUpdateUserId = request.user.sub; + command.lastUpdateFullName = request.user.name; + command.lastUpdatedAt = new Date(); + await this.commandRepository.save(command); + } + + let path = this.commandTypePath(command.commandType.name); + if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); + new CallAPI() + .PostData(request, path, { + refIds: requestBody.persons.map((x) => x.refId), + }) + .then(async (res) => { + let order = + command.commandRecives == null || command.commandRecives.length <= 0 + ? 0 + : command.commandRecives[0].order; + await Promise.all( + requestBody.persons.map(async (item) => { + const _commandRecive = await this.commandReciveRepository.findOne({ + where: { + commandId: command.id, + refId: item.refId, + }, + }); + if (_commandRecive) return; + order = order + 1; + let commandRecive = new CommandRecive(); + commandRecive = Object.assign(new CommandRecive(), item); + commandRecive.order = order; + commandRecive.commandId = command.id; + commandRecive.createdUserId = request.user.sub; + commandRecive.createdFullName = request.user.name; + commandRecive.createdAt = new Date(); + commandRecive.lastUpdateUserId = request.user.sub; + commandRecive.lastUpdateFullName = request.user.name; + commandRecive.lastUpdatedAt = new Date(); + await this.commandReciveRepository.save(commandRecive); + }), + ); + }) + .catch(() => {}); + return new HttpSuccess(command.id); + } + + commandTypePath(commandType: string) { + let path = null; + switch (commandType) { + case "C-PM-01": + path = "/placemant/main/report/"; + case "C-PM-02": + path = "/placemant/recive/report/"; + case "C-PM-03": + path = "/discipline/recive/report/"; + case "C-PM-04": + path = "/xxxxxx/"; + case "C-PM-05": + path = "/xxxxxx/"; + case "C-PM-06": + path = "/xxxxxx/"; + case "C-PM-07": + path = "/xxxxxx/"; + case "C-PM-08": + path = "/xxxxxx/"; + case "C-PM-09": + path = "/xxxxxx/"; + case "C-PM-10": + path = "/xxxxxx/"; + case "C-PM-11": + path = "/xxxxxx/"; + case "C-PM-12": + path = "/xxxxxx/"; + case "C-PM-13": + path = "/xxxxxx/"; + case "C-PM-14": + path = "/xxxxxx/"; + case "C-PM-15": + path = "/xxxxxx/"; + case "C-PM-16": + path = "/xxxxxx/"; + case "C-PM-17": + path = "/xxxxxx/"; + case "C-PM-18": + path = "/xxxxxx/"; + case "C-PM-19": + path = "/xxxxxx/"; + case "C-PM-20": + path = "/xxxxxx/"; + case "C-PM-21": + path = "/xxxxxx/"; + case "C-PM-22": + path = "/xxxxxx/"; + case "C-PM-23": + path = "/xxxxxx/"; + case "C-PM-24": + path = "/xxxxxx/"; + case "C-PM-25": + path = "/xxxxxx/"; + case "C-PM-26": + path = "/xxxxxx/"; + case "C-PM-27": + path = "/xxxxxx/"; + case "C-PM-28": + path = "/xxxxxx/"; + case "C-PM-29": + path = "/xxxxxx/"; + case "C-PM-30": + path = "/xxxxxx/"; + case "C-PM-31": + path = "/xxxxxx/"; + case "C-PM-32": + path = "/xxxxxx/"; + case "C-PM-33": + path = "/xxxxxx/"; + case "C-PM-34": + path = "/xxxxxx/"; + case "C-PM-35": + path = "/xxxxxx/"; + case "C-PM-36": + path = "/xxxxxx/"; + case "C-PM-37": + path = "/xxxxxx/"; + case "C-PM-38": + path = "/xxxxxx/"; + case "C-PM-39": + path = "/xxxxxx/"; + case "C-PM-40": + path = "/xxxxxx/"; + case "C-PM-41": + path = "/xxxxxx/"; + default: + path = null; + } + return path; + } } diff --git a/src/entities/CommandRecive.ts b/src/entities/CommandRecive.ts index b017f82e..3b25ad3d 100644 --- a/src/entities/CommandRecive.ts +++ b/src/entities/CommandRecive.ts @@ -1,7 +1,6 @@ import { Entity, Column, JoinColumn, ManyToOne, OneToMany, Double } from "typeorm"; import { EntityBase } from "./base/Base"; import { Command } from "./Command"; -import { Profile } from "./Profile"; @Entity("commandRecive") export class CommandRecive extends EntityBase { @@ -37,22 +36,6 @@ export class CommandRecive extends EntityBase { }) lastName: string; - @Column({ - nullable: true, - comment: "ตำแหน่ง", - length: 255, - default: null, - }) - position: string; - - @Column({ - nullable: true, - comment: "หน่วยงาน", - length: 255, - default: null, - }) - org: string; - @Column({ nullable: true, comment: "ลำดับแสดงผล", @@ -100,6 +83,14 @@ export class CommandRecive extends EntityBase { }) mouthSalaryAmount: Double; + @Column({ + nullable: true, + length: 40, + comment: "refId", + default: null, + }) + refId: string; + @Column({ length: 40, comment: "คีย์นอก(FK)ของตาราง command", @@ -110,15 +101,25 @@ export class CommandRecive extends EntityBase { @JoinColumn({ name: "commandId" }) command: Command; - @Column({ - length: 40, - comment: "คีย์นอก(FK)ของตาราง profile", - }) - profileId: string; + // @Column({ + // length: 40, + // comment: "คีย์นอก(FK)ของตาราง profile", + // }) + // profileId: string; - @ManyToOne(() => Profile, (profile) => profile.commandRecives) - @JoinColumn({ name: "profileId" }) - profile: Profile; + // @ManyToOne(() => Profile, (profile) => profile.commandRecives) + // @JoinColumn({ name: "profileId" }) + // profile: Profile; + + // @Column({ + // length: 40, + // comment: "คีย์นอก(FK)ของตาราง profileEmployee", + // }) + // profileEmployeeId: string; + + // @ManyToOne(() => ProfileEmployee, (profileEmployee) => profileEmployee.commandRecives) + // @JoinColumn({ name: "profileEmployeeId" }) + // profileEmployee: ProfileEmployee; } export class CreateCommandRecive { diff --git a/src/entities/Profile.ts b/src/entities/Profile.ts index 968d2046..0978f528 100644 --- a/src/entities/Profile.ts +++ b/src/entities/Profile.ts @@ -29,10 +29,8 @@ import { ProfileDiscipline } from "./ProfileDiscipline"; import { ProfileEmployee } from "./ProfileEmployee"; import { ProfileEdit } from "./ProfileEdit"; import { ProfileDevelopment } from "./ProfileDevelopment"; -import { OrgRoot } from "./OrgRoot"; import { PermissionOrg } from "./PermissionOrg"; import { CommandSend } from "./CommandSend"; -import { CommandRecive } from "./CommandRecive"; import { DevelopmentRequest } from "./DevelopmentRequest"; @Entity("profile") @@ -380,9 +378,6 @@ export class Profile extends EntityBase { @OneToMany(() => CommandSend, (v) => v.profile) commandSends: CommandSend[]; - @OneToMany(() => CommandRecive, (v) => v.profile) - commandRecives: CommandRecive[]; - @ManyToOne(() => PosLevel, (posLevel) => posLevel.profiles) @JoinColumn({ name: "posLevelId" }) posLevel: PosLevel; From 000bc2aad9cc557afe93cc57fdd27ca3c95a26ed Mon Sep 17 00:00:00 2001 From: kittapath Date: Tue, 1 Oct 2024 23:33:45 +0700 Subject: [PATCH 02/12] =?UTF-8?q?api=20=E0=B8=AD=E0=B8=AD=E0=B8=81?= =?UTF-8?q?=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 125 ++++++++++-------- src/entities/ProfileSalary.ts | 11 +- ...727795520589-update_ProfileDevelopment1.ts | 22 +++ 3 files changed, 93 insertions(+), 65 deletions(-) create mode 100644 src/migration/1727795520589-update_ProfileDevelopment1.ts diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 9544aa3f..efccce68 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -831,9 +831,9 @@ export class CommandController extends Controller { } /** - * API ทำคำสั่งใหม่ + * API ออกคำสั่ง * - * @summary API ทำคำสั่งใหม่ + * @summary API ออกคำสั่ง * * @param {string} id Id คำสั่ง */ @@ -844,7 +844,10 @@ export class CommandController extends Controller { requestBody: { sign?: boolean }, @Request() request: RequestWithUser, ) { - 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, "ไม่พบข้อมูลคำสั่งนี้"); } @@ -861,16 +864,25 @@ export class CommandController extends Controller { ) { command.status = "WAITING"; } else { - let path = this.commandTypePath(command.commandType.name); + const path = this.commandTypePath(command.commandType.code); if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); new CallAPI() .PostData(request, path + "excecute", { - refIds: command.commandRecives.map((x) => x.refId), + refIds: command.commandRecives + .filter((x) => x.refId != null) + .map((x) => ({ + refId: x.refId, + commandAffectDate: command.commandAffectDate, + commandNo: command.commandNo, + commandYear: command.commandYear, + templateDoc: command.positionDetail, + })), }) .then(async (res) => {}) - .catch(() => {}); - command.status = "REPORTED"; + .catch((e) => { + command.status = "REPORTED"; + }); } command.lastUpdateUserId = request.user.sub; command.lastUpdateFullName = request.user.name; @@ -940,7 +952,7 @@ export class CommandController extends Controller { } let _command: any = []; - let path = this.commandTypePath(command.commandType.name); + const path = this.commandTypePath(command.commandType.code); if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); new CallAPI() @@ -985,6 +997,7 @@ export class CommandController extends Controller { @Request() request: RequestWithUser, ) { let command = new Command(); + let commandCode = null; if ( requestBody.commandId != undefined && requestBody.commandId != null && @@ -992,7 +1005,7 @@ export class CommandController extends Controller { ) { const _command = await this.commandRepository.findOne({ where: { id: requestBody.commandId }, - relations: ["commandRecives"], + relations: ["commandRecives", "commandType"], order: { commandRecives: { order: "DESC", @@ -1002,6 +1015,7 @@ export class CommandController extends Controller { if (!_command) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบคำสั่งนี้ในระบบ"); } + commandCode = _command.commandType.code; command = _command; } else { command = Object.assign(new Command(), requestBody); @@ -1012,6 +1026,7 @@ export class CommandController extends Controller { if (!commandType) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); } + commandCode = commandType.code; command.detailHeader = commandType.detailHeader; command.detailBody = commandType.detailBody; command.detailFooter = commandType.detailFooter; @@ -1027,7 +1042,7 @@ export class CommandController extends Controller { await this.commandRepository.save(command); } - let path = this.commandTypePath(command.commandType.name); + const path = this.commandTypePath(commandCode); if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); new CallAPI() .PostData(request, path, { @@ -1066,94 +1081,92 @@ export class CommandController extends Controller { return new HttpSuccess(command.id); } - commandTypePath(commandType: string) { - let path = null; - switch (commandType) { + commandTypePath(commandCode: string) { + switch (commandCode) { case "C-PM-01": - path = "/placemant/main/report/"; + return "/placement/recruit/report/"; case "C-PM-02": - path = "/placemant/recive/report/"; + return "/placemant/recruit/report/"; case "C-PM-03": - path = "/discipline/recive/report/"; + return "/discipline/recive/report/"; case "C-PM-04": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-05": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-06": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-07": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-08": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-09": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-10": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-11": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-12": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-13": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-14": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-15": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-16": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-17": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-18": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-19": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-20": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-21": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-22": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-23": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-24": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-25": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-26": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-27": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-28": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-29": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-30": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-31": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-32": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-33": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-34": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-35": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-36": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-37": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-38": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-39": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-40": - path = "/xxxxxx/"; + return "/xxxxxx/"; case "C-PM-41": - path = "/xxxxxx/"; + return "/xxxxxx/"; default: - path = null; + return null; } - return path; } } diff --git a/src/entities/ProfileSalary.ts b/src/entities/ProfileSalary.ts index 641f88e0..91458be0 100644 --- a/src/entities/ProfileSalary.ts +++ b/src/entities/ProfileSalary.ts @@ -1,11 +1,4 @@ -import { - Entity, - Column, - OneToMany, - JoinColumn, - ManyToOne, - Double, -} from "typeorm"; +import { Entity, Column, OneToMany, JoinColumn, ManyToOne, Double } from "typeorm"; import { EntityBase } from "./base/Base"; import { Profile } from "./Profile"; import { ProfileEmployee } from "./ProfileEmployee"; @@ -174,7 +167,7 @@ export class CreateProfileSalary { positionType: string | null; positionLevel: string | null; refCommandNo: string | null; - commandType?: string | null; + // commandType?: string | null; templateDoc: string | null; } diff --git a/src/migration/1727795520589-update_ProfileDevelopment1.ts b/src/migration/1727795520589-update_ProfileDevelopment1.ts new file mode 100644 index 00000000..8c325978 --- /dev/null +++ b/src/migration/1727795520589-update_ProfileDevelopment1.ts @@ -0,0 +1,22 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateProfileDevelopment11727795520589 implements MigrationInterface { + name = 'UpdateProfileDevelopment11727795520589' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`commandRecive\` DROP FOREIGN KEY \`FK_fb29bfd315d0d43d0b49b362995\``); + await queryRunner.query(`ALTER TABLE \`commandRecive\` DROP COLUMN \`org\``); + await queryRunner.query(`ALTER TABLE \`commandRecive\` DROP COLUMN \`position\``); + await queryRunner.query(`ALTER TABLE \`commandRecive\` DROP COLUMN \`profileId\``); + await queryRunner.query(`ALTER TABLE \`commandRecive\` ADD \`refId\` varchar(40) NULL COMMENT 'refId'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`commandRecive\` DROP COLUMN \`refId\``); + await queryRunner.query(`ALTER TABLE \`commandRecive\` ADD \`profileId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง profile'`); + await queryRunner.query(`ALTER TABLE \`commandRecive\` ADD \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง'`); + await queryRunner.query(`ALTER TABLE \`commandRecive\` ADD \`org\` varchar(255) NULL COMMENT 'หน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`commandRecive\` ADD CONSTRAINT \`FK_fb29bfd315d0d43d0b49b362995\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + +} From 1bccf8f87d30e407c3be19b5ea60f2bf7e9cc394 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 2 Oct 2024 11:12:28 +0700 Subject: [PATCH 03/12] no message --- src/controllers/CommandController.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index efccce68..d2eaa73f 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -877,6 +877,9 @@ export class CommandController extends Controller { commandNo: command.commandNo, commandYear: command.commandYear, templateDoc: command.positionDetail, + amount: x.amount, + positionSalaryAmount: x.positionSalaryAmount, + mouthSalaryAmount: x.mouthSalaryAmount, })), }) .then(async (res) => {}) @@ -982,7 +985,7 @@ export class CommandController extends Controller { async PostPerson( @Body() requestBody: { - commandTypeId?: string; + commandTypeId?: string | null; commandNo?: string | null; commandYear?: number | null; commandId?: string | null; @@ -1019,6 +1022,9 @@ export class CommandController extends Controller { command = _command; } else { command = Object.assign(new Command(), requestBody); + if (!requestBody.commandTypeId) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่ง"); + } const commandType = await this.commandTypeRepository.findOne({ where: { id: requestBody.commandTypeId }, }); From ba8d78b11cc267d44e846bbd5634888736c72571 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 2 Oct 2024 11:25:38 +0700 Subject: [PATCH 04/12] no message --- src/controllers/CommandController.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index d2eaa73f..0f182bf5 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -1094,13 +1094,13 @@ export class CommandController extends Controller { case "C-PM-02": return "/placemant/recruit/report/"; case "C-PM-03": - return "/discipline/recive/report/"; + return "/placemant/appoint/report/"; case "C-PM-04": - return "/xxxxxx/"; + return "/placemant/move/report/"; case "C-PM-05": - return "/xxxxxx/"; + return "/placemant/appointment/appoint/report/"; case "C-PM-06": - return "/xxxxxx/"; + return "/placemant/appointment/slip/report/"; case "C-PM-07": return "/xxxxxx/"; case "C-PM-08": @@ -1166,7 +1166,7 @@ export class CommandController extends Controller { case "C-PM-38": return "/xxxxxx/"; case "C-PM-39": - return "/xxxxxx/"; + return "/placemant/slip/report/"; case "C-PM-40": return "/xxxxxx/"; case "C-PM-41": From 2af2f32cf7e1e8e20bb808cbe563eb2d222b5ef8 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 2 Oct 2024 13:50:36 +0700 Subject: [PATCH 05/12] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=9F?= =?UTF-8?q?=E0=B8=B4=E0=B8=A7=20=E0=B8=AD=E0=B8=AD=E0=B8=81=E0=B8=84?= =?UTF-8?q?=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 11 ++----- src/entities/CommandRecive.ts | 32 +++++++++---------- ...727851675456-update_ProfileDevelopment2.ts | 20 ++++++++++++ 3 files changed, 39 insertions(+), 24 deletions(-) create mode 100644 src/migration/1727851675456-update_ProfileDevelopment2.ts diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 0f182bf5..d316ec27 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -276,10 +276,7 @@ export class CommandController extends Controller { .map((x) => ({ id: x.id, citizenId: x.citizenId, - prefix: x.prefix, - firstName: x.firstName, - lastName: x.lastName, - // profileId: x.profileId, + fullName: x.fullName, order: x.order, remarkVertical: x.remarkVertical, remarkHorizontal: x.remarkHorizontal, @@ -992,9 +989,7 @@ export class CommandController extends Controller { persons: { refId: string; citizenId: string; - prefix: string; - firstName: string; - lastName: string; + fullName: string; }[]; }, @Request() request: RequestWithUser, @@ -1102,7 +1097,7 @@ export class CommandController extends Controller { case "C-PM-06": return "/placemant/appointment/slip/report/"; case "C-PM-07": - return "/xxxxxx/"; + return "/placemant/appointment/move/report/"; case "C-PM-08": return "/xxxxxx/"; case "C-PM-09": diff --git a/src/entities/CommandRecive.ts b/src/entities/CommandRecive.ts index 3b25ad3d..e0998802 100644 --- a/src/entities/CommandRecive.ts +++ b/src/entities/CommandRecive.ts @@ -14,27 +14,27 @@ export class CommandRecive extends EntityBase { @Column({ nullable: true, - comment: "คำนำหน้า", + comment: "ชื่อ-สกุล", length: 255, default: null, }) - prefix: string; + fullName: string; - @Column({ - nullable: true, - comment: "ชื่อ", - length: 255, - default: null, - }) - firstName: string; + // @Column({ + // nullable: true, + // comment: "ชื่อ", + // length: 255, + // default: null, + // }) + // firstName: string; - @Column({ - nullable: true, - comment: "สกุล", - length: 255, - default: null, - }) - lastName: string; + // @Column({ + // nullable: true, + // comment: "สกุล", + // length: 255, + // default: null, + // }) + // lastName: string; @Column({ nullable: true, diff --git a/src/migration/1727851675456-update_ProfileDevelopment2.ts b/src/migration/1727851675456-update_ProfileDevelopment2.ts new file mode 100644 index 00000000..5566c3c0 --- /dev/null +++ b/src/migration/1727851675456-update_ProfileDevelopment2.ts @@ -0,0 +1,20 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateProfileDevelopment21727851675456 implements MigrationInterface { + name = 'UpdateProfileDevelopment21727851675456' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`commandRecive\` DROP COLUMN \`firstName\``); + await queryRunner.query(`ALTER TABLE \`commandRecive\` DROP COLUMN \`lastName\``); + await queryRunner.query(`ALTER TABLE \`commandRecive\` DROP COLUMN \`prefix\``); + await queryRunner.query(`ALTER TABLE \`commandRecive\` ADD \`fullName\` varchar(255) NULL COMMENT 'ชื่อ-สกุล'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`commandRecive\` DROP COLUMN \`fullName\``); + await queryRunner.query(`ALTER TABLE \`commandRecive\` ADD \`prefix\` varchar(255) NULL COMMENT 'คำนำหน้า'`); + await queryRunner.query(`ALTER TABLE \`commandRecive\` ADD \`lastName\` varchar(255) NULL COMMENT 'สกุล'`); + await queryRunner.query(`ALTER TABLE \`commandRecive\` ADD \`firstName\` varchar(255) NULL COMMENT 'ชื่อ'`); + } + +} From 8a29a374551b9b45a63f7f7e840b0be547c595af Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 2 Oct 2024 14:08:40 +0700 Subject: [PATCH 06/12] no message --- src/controllers/CommandController.ts | 9 ++++-- src/entities/CommandRecive.ts | 32 +++++++++---------- ...727852313568-update_ProfileDevelopment3.ts | 20 ++++++++++++ 3 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 src/migration/1727852313568-update_ProfileDevelopment3.ts diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index d316ec27..c6ea91a9 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -276,7 +276,10 @@ export class CommandController extends Controller { .map((x) => ({ id: x.id, citizenId: x.citizenId, - fullName: x.fullName, + prefix: x.prefix, + firstName: x.firstName, + lastName: x.lastName, + // profileId: x.profileId, order: x.order, remarkVertical: x.remarkVertical, remarkHorizontal: x.remarkHorizontal, @@ -989,7 +992,9 @@ export class CommandController extends Controller { persons: { refId: string; citizenId: string; - fullName: string; + prefix: string; + firstName: string; + lastName: string; }[]; }, @Request() request: RequestWithUser, diff --git a/src/entities/CommandRecive.ts b/src/entities/CommandRecive.ts index e0998802..3b25ad3d 100644 --- a/src/entities/CommandRecive.ts +++ b/src/entities/CommandRecive.ts @@ -14,27 +14,27 @@ export class CommandRecive extends EntityBase { @Column({ nullable: true, - comment: "ชื่อ-สกุล", + comment: "คำนำหน้า", length: 255, default: null, }) - fullName: string; + prefix: string; - // @Column({ - // nullable: true, - // comment: "ชื่อ", - // length: 255, - // default: null, - // }) - // firstName: string; + @Column({ + nullable: true, + comment: "ชื่อ", + length: 255, + default: null, + }) + firstName: string; - // @Column({ - // nullable: true, - // comment: "สกุล", - // length: 255, - // default: null, - // }) - // lastName: string; + @Column({ + nullable: true, + comment: "สกุล", + length: 255, + default: null, + }) + lastName: string; @Column({ nullable: true, diff --git a/src/migration/1727852313568-update_ProfileDevelopment3.ts b/src/migration/1727852313568-update_ProfileDevelopment3.ts new file mode 100644 index 00000000..3fc82083 --- /dev/null +++ b/src/migration/1727852313568-update_ProfileDevelopment3.ts @@ -0,0 +1,20 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateProfileDevelopment31727852313568 implements MigrationInterface { + name = 'UpdateProfileDevelopment31727852313568' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`commandRecive\` DROP COLUMN \`fullName\``); + await queryRunner.query(`ALTER TABLE \`commandRecive\` ADD \`prefix\` varchar(255) NULL COMMENT 'คำนำหน้า'`); + await queryRunner.query(`ALTER TABLE \`commandRecive\` ADD \`firstName\` varchar(255) NULL COMMENT 'ชื่อ'`); + await queryRunner.query(`ALTER TABLE \`commandRecive\` ADD \`lastName\` varchar(255) NULL COMMENT 'สกุล'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`commandRecive\` DROP COLUMN \`lastName\``); + await queryRunner.query(`ALTER TABLE \`commandRecive\` DROP COLUMN \`firstName\``); + await queryRunner.query(`ALTER TABLE \`commandRecive\` DROP COLUMN \`prefix\``); + await queryRunner.query(`ALTER TABLE \`commandRecive\` ADD \`fullName\` varchar(255) NULL COMMENT 'ชื่อ-สกุล'`); + } + +} From 95b756d26dbc72dc1c3c207c5d7a2ad150aeeefd Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 2 Oct 2024 15:14:21 +0700 Subject: [PATCH 07/12] no message --- src/controllers/CommandController.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index c6ea91a9..6cd4fc5e 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -1104,15 +1104,15 @@ export class CommandController extends Controller { case "C-PM-07": return "/placemant/appointment/move/report/"; case "C-PM-08": - return "/xxxxxx/"; + return "/retirement/other/appoint/report/"; case "C-PM-09": - return "/xxxxxx/"; + return "/retirement/other/out/report/"; case "C-PM-10": return "/xxxxxx/"; case "C-PM-11": - return "/xxxxxx/"; + return "/order/command11/report/"; case "C-PM-12": - return "/xxxxxx/"; + return "/order/command12/report/"; case "C-PM-13": return "/xxxxxx/"; case "C-PM-14": From 3dae6f8a30633b5681cae90efcbcb8686a89c127 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 2 Oct 2024 16:07:29 +0700 Subject: [PATCH 08/12] no message --- src/controllers/CommandController.ts | 18 +++++++++--------- src/controllers/ProfileEmployeeController.ts | 1 - .../ProfileEmployeeTempController.ts | 1 - 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 6cd4fc5e..adce4ebf 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -1114,23 +1114,23 @@ export class CommandController extends Controller { case "C-PM-12": return "/order/command12/report/"; case "C-PM-13": - return "/xxxxxx/"; + return "/placement/transfer/report/"; case "C-PM-14": - return "/xxxxxx/"; + return "/placement/Receive/report/"; case "C-PM-15": - return "/xxxxxx/"; + return "/placement/officer/report/"; case "C-PM-16": - return "/xxxxxx/"; + return "/placement/repatriation/report/"; case "C-PM-17": - return "/xxxxxx/"; + return "/retirement/resign/report/"; case "C-PM-18": - return "/xxxxxx/"; + return "/retirement/other/leave/report/"; case "C-PM-19": - return "/xxxxxx/"; + return "/order/command19/report/"; case "C-PM-20": - return "/xxxxxx/"; + return "/order/command20/report/"; case "C-PM-21": - return "/xxxxxx/"; + return "/order/command21/report/"; case "C-PM-22": return "/xxxxxx/"; case "C-PM-23": diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 25c5a1b1..671ce062 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -3478,7 +3478,6 @@ export class ProfileEmployeeController extends Controller { body: { result: { id: string; - personId: string; templateDoc: string; amount: Double | null; positionSalaryAmount: Double | null; diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index e148648c..10a1f9f9 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -3179,7 +3179,6 @@ export class ProfileEmployeeTempController extends Controller { body: { result: { id: string; - personId: string; templateDoc: string; amount: Double | null; positionSalaryAmount: Double | null; From f550047545e80a6fbc62324a628b566aad9de85d Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 2 Oct 2024 22:54:43 +0700 Subject: [PATCH 09/12] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=84?= =?UTF-8?q?=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 50 ++++++++++++++-------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index adce4ebf..5b46e226 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -1114,17 +1114,17 @@ export class CommandController extends Controller { case "C-PM-12": return "/order/command12/report/"; case "C-PM-13": - return "/placement/transfer/report/"; + return "/placement/transfer/command/report/"; case "C-PM-14": - return "/placement/Receive/report/"; + return "/placement/Receive/command/report/"; case "C-PM-15": - return "/placement/officer/report/"; + return "/placement/officer/command/report/"; case "C-PM-16": - return "/placement/repatriation/report/"; + return "/placement/repatriation/command/report/"; case "C-PM-17": - return "/retirement/resign/report/"; + return "/retirement/resign/command/report/"; case "C-PM-18": - return "/retirement/other/leave/report/"; + return "/retirement/out/command/report/"; case "C-PM-19": return "/order/command19/report/"; case "C-PM-20": @@ -1132,45 +1132,45 @@ export class CommandController extends Controller { case "C-PM-21": return "/order/command21/report/"; case "C-PM-22": - return "/xxxxxx/"; + return "/placement/appointment/employee-appoint/report/"; case "C-PM-23": - return "/xxxxxx/"; + return "/retirement/resign/employee/report/"; case "C-PM-24": - return "/xxxxxx/"; + return "/placement/appointment/employee-move/report/"; case "C-PM-25": - return "/xxxxxx/"; + return "/order/command25/report/"; case "C-PM-26": - return "/xxxxxx/"; + return "/order/command26/report/"; case "C-PM-27": - return "/xxxxxx/"; + return "/order/command27/report/"; case "C-PM-28": - return "/xxxxxx/"; + return "/order/command28/report/"; case "C-PM-29": - return "/xxxxxx/"; + return "/order/command29/report/"; case "C-PM-30": - return "/xxxxxx/"; + return "/order/command30/report/"; case "C-PM-31": - return "/xxxxxx/"; + return "/order/command31/report/"; case "C-PM-32": - return "/xxxxxx/"; + return "/order/command32/report/"; case "C-PM-33": - return "/xxxxxx/"; + return "/order/command33/report/"; case "C-PM-34": - return "/xxxxxx/"; + return "/order/command34/report/"; case "C-PM-35": - return "/xxxxxx/"; + return "/order/command35/report/"; case "C-PM-36": - return "/xxxxxx/"; + return "/order/command36/report/"; case "C-PM-37": - return "/xxxxxx/"; + return "/order/command37/report/"; case "C-PM-38": - return "/xxxxxx/"; + return "/order/command38/report/"; case "C-PM-39": return "/placemant/slip/report/"; case "C-PM-40": - return "/xxxxxx/"; + return "/order/command40/report/"; case "C-PM-41": - return "/xxxxxx/"; + return "/retirement/resign/leave-cancel/report/"; default: return null; } From 11064272506aa4990c7aaf7625afa9a83f07f441 Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 3 Oct 2024 11:54:55 +0700 Subject: [PATCH 10/12] no message --- src/controllers/CommandController.ts | 98 ++++++++++++++-------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 5b46e226..74bd4537 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -867,8 +867,8 @@ export class CommandController extends Controller { const path = this.commandTypePath(command.commandType.code); if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); - new CallAPI() - .PostData(request, path + "excecute", { + await new CallAPI() + .PostData(request, path + "/excecute", { refIds: command.commandRecives .filter((x) => x.refId != null) .map((x) => ({ @@ -882,10 +882,10 @@ export class CommandController extends Controller { mouthSalaryAmount: x.mouthSalaryAmount, })), }) - .then(async (res) => {}) - .catch((e) => { + .then(async (res) => { command.status = "REPORTED"; - }); + }) + .catch((e) => {}); } command.lastUpdateUserId = request.user.sub; command.lastUpdateFullName = request.user.name; @@ -958,8 +958,8 @@ export class CommandController extends Controller { const path = this.commandTypePath(command.commandType.code); if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); - new CallAPI() - .PostData(request, path + "attachment", { + await new CallAPI() + .PostData(request, path + "/attachment", { refIds: command.commandRecives.map((x) => x.refId), }) .then(async (res) => { @@ -1050,7 +1050,7 @@ export class CommandController extends Controller { const path = this.commandTypePath(commandCode); if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); - new CallAPI() + await new CallAPI() .PostData(request, path, { refIds: requestBody.persons.map((x) => x.refId), }) @@ -1090,87 +1090,87 @@ export class CommandController extends Controller { commandTypePath(commandCode: string) { switch (commandCode) { case "C-PM-01": - return "/placement/recruit/report/"; + return "/placement/recruit/report"; case "C-PM-02": - return "/placemant/recruit/report/"; + return "/placement/candidate/report"; case "C-PM-03": - return "/placemant/appoint/report/"; + return "/placement/appoint/report"; case "C-PM-04": - return "/placemant/move/report/"; + return "/placement/move/report"; case "C-PM-05": - return "/placemant/appointment/appoint/report/"; + return "/placement/appointment/appoint/report"; case "C-PM-06": - return "/placemant/appointment/slip/report/"; + return "/placement/appointment/slip/report"; case "C-PM-07": - return "/placemant/appointment/move/report/"; + return "/placement/appointment/move/report"; case "C-PM-08": - return "/retirement/other/appoint/report/"; + return "/retirement/other/appoint/report"; case "C-PM-09": - return "/retirement/other/out/report/"; + return "/retirement/other/out/report"; case "C-PM-10": - return "/xxxxxx/"; + return "/xxxxxx"; case "C-PM-11": - return "/order/command11/report/"; + return "/order/command11/report"; case "C-PM-12": - return "/order/command12/report/"; + return "/order/command12/report"; case "C-PM-13": - return "/placement/transfer/command/report/"; + 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/"; + return "/placement/officer/command/report"; case "C-PM-16": - return "/placement/repatriation/command/report/"; + return "/placement/repatriation/command/report"; case "C-PM-17": - return "/retirement/resign/command/report/"; + return "/retirement/resign/command/report"; case "C-PM-18": - return "/retirement/out/command/report/"; + return "/retirement/out/command/report"; case "C-PM-19": - return "/order/command19/report/"; + return "/order/command19/report"; case "C-PM-20": - return "/order/command20/report/"; + return "/order/command20/report"; case "C-PM-21": - return "/order/command21/report/"; + return "/order/command21/report"; case "C-PM-22": - return "/placement/appointment/employee-appoint/report/"; + return "/placement/appointment/employee-appoint/report"; case "C-PM-23": - return "/retirement/resign/employee/report/"; + return "/retirement/resign/employee/report"; case "C-PM-24": - return "/placement/appointment/employee-move/report/"; + return "/placement/appointment/employee-move/report"; case "C-PM-25": - return "/order/command25/report/"; + return "/order/command25/report"; case "C-PM-26": - return "/order/command26/report/"; + return "/order/command26/report"; case "C-PM-27": - return "/order/command27/report/"; + return "/order/command27/report"; case "C-PM-28": - return "/order/command28/report/"; + return "/order/command28/report"; case "C-PM-29": - return "/order/command29/report/"; + return "/order/command29/report"; case "C-PM-30": - return "/order/command30/report/"; + return "/order/command30/report"; case "C-PM-31": - return "/order/command31/report/"; + return "/order/command31/report"; case "C-PM-32": - return "/order/command32/report/"; + return "/order/command32/report"; case "C-PM-33": - return "/order/command33/report/"; + return "/order/command33/report"; case "C-PM-34": - return "/order/command34/report/"; + return "/order/command34/report"; case "C-PM-35": - return "/order/command35/report/"; + return "/order/command35/report"; case "C-PM-36": - return "/order/command36/report/"; + return "/order/command36/report"; case "C-PM-37": - return "/order/command37/report/"; + return "/order/command37/report"; case "C-PM-38": - return "/order/command38/report/"; + return "/order/command38/report"; case "C-PM-39": - return "/placemant/slip/report/"; + return "/placement/slip/report"; case "C-PM-40": - return "/order/command40/report/"; + return "/order/command40/report"; case "C-PM-41": - return "/retirement/resign/leave-cancel/report/"; + return "/retirement/resign/leave-cancel/report"; default: return null; } From e805759af5b54f10df4d6317d6a0321605edc226 Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 3 Oct 2024 12:28:13 +0700 Subject: [PATCH 11/12] no message --- src/controllers/OrganizationController.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index ea7e9017..7f151dd7 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -4786,7 +4786,10 @@ export class OrganizationController extends Controller { child3: null, child4: null, }; - if (orgRevision.orgRevisionIsDraft == true && orgRevision.orgRevisionIsCurrent == false) { + if ( + (orgRevision.orgRevisionIsDraft == true && orgRevision.orgRevisionIsCurrent == false) || + system != "SYS_ORG" + ) { _data = await new permission().PermissionOrgList(request, system.trim().toUpperCase()); } const orgRootData = await AppDataSource.getRepository(OrgRoot) From 85657d1c3224ae5db4f2c06de24c4d7d4ab50c5a Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 3 Oct 2024 15:37:28 +0700 Subject: [PATCH 12/12] add isBlank --- src/controllers/OrganizationController.ts | 3 ++- src/controllers/PermissionOrgController.ts | 30 +++++++++++----------- src/controllers/PositionController.ts | 24 +++++++++++++++-- 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 7f151dd7..a07b20f4 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -621,7 +621,8 @@ export class OrganizationController extends Controller { // let attrOwnership = null; if ( orgRevision.orgRevisionIsDraft == true && - orgRevision.orgRevisionIsCurrent == false + orgRevision.orgRevisionIsCurrent == false && + request.user.role.includes("SUPER_ADMIN") // attrOwnership == false ) { const profile = await this.profileRepo.findOne({ diff --git a/src/controllers/PermissionOrgController.ts b/src/controllers/PermissionOrgController.ts index 1150f6cd..9cd157f5 100644 --- a/src/controllers/PermissionOrgController.ts +++ b/src/controllers/PermissionOrgController.ts @@ -48,9 +48,9 @@ export class PermissionOrgController extends Controller { */ @Get() async GetActiveRootIdAdmin(@Request() request: RequestWithUser) { - if (!request.user.role.includes("SUPER_ADMIN")) { - throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); - } + // if (!request.user.role.includes("SUPER_ADMIN")) { + // throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); + // } const orgRevisionActive = await this.orgRevisionRepository.findOne({ where: { orgRevisionIsCurrent: false, orgRevisionIsDraft: true }, }); @@ -76,9 +76,9 @@ export class PermissionOrgController extends Controller { searchField?: "fullName" | "position" | "posNo" | "postype" | "poslevel", @Query() searchKeyword: string = "", ) { - if (!request.user.role.includes("SUPER_ADMIN")) { - throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); - } + // if (!request.user.role.includes("SUPER_ADMIN")) { + // throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); + // } let queryLike = "CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword"; if (searchField == "postype") { @@ -233,9 +233,9 @@ export class PermissionOrgController extends Controller { searchKeyword: string; }, ) { - if (!request.user.role.includes("SUPER_ADMIN")) { - throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); - } + // if (!request.user.role.includes("SUPER_ADMIN")) { + // throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); + // } let profiles: any = []; if (requestBody.id != null) { const _permissionOrg = await this.orgRootRepository.findOne({ @@ -423,9 +423,9 @@ export class PermissionOrgController extends Controller { @Request() request: RequestWithUser, @Body() requestBody: { nodeId: string; personId: string }, ) { - if (!request.user.role.includes("SUPER_ADMIN")) { - throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); - } + // if (!request.user.role.includes("SUPER_ADMIN")) { + // throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); + // } const orgRoot = await this.orgRootRepository.findOne({ where: { id: requestBody.nodeId }, }); @@ -472,9 +472,9 @@ export class PermissionOrgController extends Controller { */ @Delete("{id}") async Delete(@Request() request: RequestWithUser, @Path() id: string) { - if (!request.user.role.includes("SUPER_ADMIN")) { - throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); - } + // if (!request.user.role.includes("SUPER_ADMIN")) { + // throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); + // } // const orgRoot = await this.orgRootRepository.findOne({ // where: { id: nodeId }, // relations: ["permissionOrgRoots"], diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 646276cf..de22564a 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -840,9 +840,13 @@ export class PositionController extends Controller { } let _null: any = null; posMaster.isDirector = requestBody.isDirector; - posMaster.isStaff = requestBody.isStaff == null || requestBody.isStaff == undefined ? _null : requestBody.isStaff; + posMaster.isStaff = + requestBody.isStaff == null || requestBody.isStaff == undefined ? _null : requestBody.isStaff; // posMaster.isOfficer = requestBody.isOfficer; - posMaster.positionSign = requestBody.positionSign == null || requestBody.positionSign == undefined ? _null : requestBody.positionSign; + posMaster.positionSign = + requestBody.positionSign == null || requestBody.positionSign == undefined + ? _null + : requestBody.positionSign; posMaster.posMasterNo = requestBody.posMasterNo; posMaster.posMasterNoPrefix = requestBody.posMasterNoPrefix; posMaster.posMasterNoSuffix = requestBody.posMasterNoSuffix; @@ -1101,6 +1105,7 @@ export class PositionController extends Controller { revisionId: string; type: number; isAll: boolean; + isBlank: boolean; page: number; pageSize: number; keyword?: string; @@ -1127,6 +1132,9 @@ export class PositionController extends Controller { searchShortName = `CONCAT(orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } + if (body.isBlank == true) { + typeCondition.current_holderId = IsNull(); + } } else if (body.type === 1) { typeCondition = { orgChild1Id: body.id, @@ -1138,6 +1146,9 @@ export class PositionController extends Controller { searchShortName = `CONCAT(orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } + if (body.isBlank == true) { + typeCondition.current_holderId = IsNull(); + } } else if (body.type === 2) { typeCondition = { orgChild2Id: body.id, @@ -1149,6 +1160,9 @@ export class PositionController extends Controller { searchShortName = `CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } + if (body.isBlank == true) { + typeCondition.current_holderId = IsNull(); + } } else if (body.type === 3) { typeCondition = { orgChild3Id: body.id, @@ -1160,11 +1174,17 @@ export class PositionController extends Controller { searchShortName = `CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } + if (body.isBlank == true) { + typeCondition.current_holderId = IsNull(); + } } else if (body.type === 4) { typeCondition = { orgChild4Id: body.id, }; searchShortName = `CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + if (body.isBlank == true) { + typeCondition.current_holderId = IsNull(); + } } let findPosition: any; let masterId = new Array();