From 25a7a8e1a8928899000be6fd6d66c3f0986ac188 Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 17 Oct 2024 19:26:33 +0700 Subject: [PATCH] no message --- src/controllers/CommandController.ts | 19 +++++++++++++++++++ src/controllers/ProfileEditController.ts | 17 ++++++++++++++++- src/entities/ProfileSalary.ts | 14 ++++++++++++++ ...554-update_profilesalary_dateGovernment.ts | 16 ++++++++++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/migration/1729159077554-update_profilesalary_dateGovernment.ts diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 33ef6533..be46b076 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -2759,6 +2759,25 @@ export class CommandController extends Controller { ) { return new HttpSuccess(); } + @Post("command38/officer/report/delete") + public async command38SalaryOfficerDelete( + @Request() req: RequestWithUser, + @Body() + body: { + refIds: { + refId: string; + commandAffectDate: Date | null; + commandNo: string | null; + commandYear: number; + templateDoc: string | null; + amount: Double | null; + positionSalaryAmount: Double | null; + mouthSalaryAmount: Double | null; + }[]; + }, + ) { + return new HttpSuccess(); + } commandTypePath(commandCode: string) { switch (commandCode) { diff --git a/src/controllers/ProfileEditController.ts b/src/controllers/ProfileEditController.ts index f1b9d7c8..24e74c9f 100644 --- a/src/controllers/ProfileEditController.ts +++ b/src/controllers/ProfileEditController.ts @@ -20,6 +20,7 @@ import { Profile } from "../entities/Profile"; import { CreateProfileEdit, EditProfileEdit, ProfileEdit } from "../entities/ProfileEdit"; import { RequestWithUser } from "../middlewares/user"; import { Brackets } from "typeorm"; +import CallAPI from "../interfaces/call-api"; @Route("api/v1/org/profile/edit") @Tags("ProfileEdit") @@ -184,7 +185,10 @@ export class ProfileEditController extends Controller { @Post() public async newProfileEdit(@Request() req: RequestWithUser, @Body() body: CreateProfileEdit) { - const profile = await this.profileRepo.findOneBy({ keycloak: req.user.sub }); + const profile = await this.profileRepo.findOne({ + where: { keycloak: req.user.sub }, + relations: ["posLevel", "posLevel.posLevelName", "posType", "posType.posTypeName"], + }); if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } @@ -203,6 +207,17 @@ export class ProfileEditController extends Controller { data.status = "PENDING"; await this.profileEditRepo.save(data); + await new CallAPI() + .PostData(req, "/org/workflow/add-workflow", { + refId: data.id, + sysName: "REGISTRY_PROFILE", + posLevelName: profile.posLevel.posLevelName, + posTypeName: profile.posType.posTypeName, + }) + .catch((error) => { + console.error("Error calling API:", error); + }); + return new HttpSuccess(data.id); } diff --git a/src/entities/ProfileSalary.ts b/src/entities/ProfileSalary.ts index 91458be0..2103b6cd 100644 --- a/src/entities/ProfileSalary.ts +++ b/src/entities/ProfileSalary.ts @@ -141,6 +141,20 @@ export class ProfileSalary extends EntityBase { }) order: number; + @Column({ + comment: "วันที่", + type: "datetime", + nullable: true, + }) + dateGovernment: Date; + + @Column({ + nullable: true, + comment: "เข้ารับราชการ", + default: null, + }) + isGovernment: boolean; + @OneToMany(() => ProfileSalaryHistory, (profileSalaryHistory) => profileSalaryHistory.histories) profileSalaryHistories: ProfileSalaryHistory[]; diff --git a/src/migration/1729159077554-update_profilesalary_dateGovernment.ts b/src/migration/1729159077554-update_profilesalary_dateGovernment.ts new file mode 100644 index 00000000..0daecd55 --- /dev/null +++ b/src/migration/1729159077554-update_profilesalary_dateGovernment.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateProfilesalaryDateGovernment1729159077554 implements MigrationInterface { + name = 'UpdateProfilesalaryDateGovernment1729159077554' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileSalary\` ADD \`dateGovernment\` datetime NULL COMMENT 'วันที่'`); + await queryRunner.query(`ALTER TABLE \`profileSalary\` ADD \`isGovernment\` tinyint NULL COMMENT 'เข้ารับราชการ'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileSalary\` DROP COLUMN \`isGovernment\``); + await queryRunner.query(`ALTER TABLE \`profileSalary\` DROP COLUMN \`dateGovernment\``); + } + +}