From ad08061836dd5ad78483c557c28a85b7d1580c85 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 27 Mar 2024 13:48:06 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B8=9C=E0=B8=B9=E0=B9=89=E0=B8=9A=E0=B8=B1=E0=B8=87=E0=B8=84?= =?UTF-8?q?=E0=B8=B1=E0=B8=9A=E0=B8=9A=E0=B8=B1=E0=B8=8D=E0=B8=8A=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 59 +++++++++++++++++++ .../ProfileGovernmentController.ts | 15 +++++ src/entities/Profile.ts | 8 +++ src/entities/ProfileGovernment.ts | 10 ++++ ...ate_table_profilegov_add_reasonSameDate.ts | 18 ++++++ 5 files changed, 110 insertions(+) create mode 100644 src/migration/1711521703929-update_table_profilegov_add_reasonSameDate.ts diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 40ccb74f..a5e60960 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -44,6 +44,65 @@ export class ProfileController extends Controller { private posLevelRepo = AppDataSource.getRepository(PosLevel); private posTypeRepo = AppDataSource.getRepository(PosType); + /** + * + * + * @param {string} id Id ทะเบียนประวัติ + */ + @Get("placement/{id}") + async getProfilePlacement(@Path() id: string) { + const profile = await this.profileRepo.findOne({ + where: { id }, + }); + + if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + + const _caregiver = await this.profileRepo.find({ + relations: { posLevel: true, posType: true }, + }); + const _commander = await this.profileRepo.find({ + relations: { posLevel: true, posType: true }, + }); + const _chairman = await this.profileRepo.find({ + relations: { posLevel: true, posType: true }, + }); + + const caregiver = _caregiver.map((_data) => ({ + id: _data.id, + prefix: _data.prefix, + firstName: _data.firstName, + lastName: _data.lastName, + citizenId: _data.citizenId, + position: _data.position, + posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName, + posType: _data.posType == null ? null : _data.posType.posTypeName, + isDirector: true, + })); + const commander = _commander.map((_data) => ({ + id: _data.id, + prefix: _data.prefix, + firstName: _data.firstName, + lastName: _data.lastName, + citizenId: _data.citizenId, + position: _data.position, + posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName, + posType: _data.posType == null ? null : _data.posType.posTypeName, + isDirector: true, + })); + const chairman = _chairman.map((_data) => ({ + id: _data.id, + prefix: _data.prefix, + firstName: _data.firstName, + lastName: _data.lastName, + citizenId: _data.citizenId, + position: _data.position, + posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName, + posType: _data.posType == null ? null : _data.posType.posTypeName, + isDirector: true, + })); + return new HttpSuccess({ caregiver, commander, chairman }); + } + /** * API สร้างทะเบียนประวัติ * diff --git a/src/controllers/ProfileGovernmentController.ts b/src/controllers/ProfileGovernmentController.ts index 44302887..624a2525 100644 --- a/src/controllers/ProfileGovernmentController.ts +++ b/src/controllers/ProfileGovernmentController.ts @@ -36,6 +36,11 @@ export class ProfileGovernmentHistoryController extends Controller { private positionRepo = AppDataSource.getRepository(Position); private posMasterRepo = AppDataSource.getRepository(PosMaster); + /** + * + * @summary ข้อมูลราชการ + * + */ @Get("{profileId}") @Example({}) public async getGovHistory(@Path() profileId: string) { @@ -127,6 +132,11 @@ export class ProfileGovernmentHistoryController extends Controller { return new HttpSuccess(data); } + /** + * + * @summary ประวัติข้อมูลราชการ + * + */ @Get("history/{profileId}") @Example({}) public async govHistory(@Path() profileId: string) { @@ -168,6 +178,11 @@ export class ProfileGovernmentHistoryController extends Controller { // return new HttpSuccess(); // } + /** + * + * @summary แก้ไขข้อมูลราชการ + * + */ @Patch("{profileId}") public async editGov( @Request() req: RequestWithUser, diff --git a/src/entities/Profile.ts b/src/entities/Profile.ts index f1e54cf4..5a8310cc 100644 --- a/src/entities/Profile.ts +++ b/src/entities/Profile.ts @@ -185,6 +185,14 @@ export class Profile extends EntityBase { }) birthDate: Date; + @Column({ + nullable: true, + comment: "เหตุผลกรณีวันไม่ตรงกัน", + length: 255, + default: null, + }) + reasonSameDate: string; + @Column({ nullable: true, comment: "เชื้อชาติ", diff --git a/src/entities/ProfileGovernment.ts b/src/entities/ProfileGovernment.ts index d577b2dd..1b35fcb4 100644 --- a/src/entities/ProfileGovernment.ts +++ b/src/entities/ProfileGovernment.ts @@ -44,15 +44,25 @@ export class ProfileGovernment extends EntityBase { default: null, }) govAgePlus: number; + + @Column({ + nullable: true, + comment: "เหตุผลกรณีวันไม่ตรงกัน", + length: 255, + default: null, + }) + reasonSameDate: string; } export type CreateProfileGovernment = { profileId: string; dateAppoint?: Date | null; dateStart?: Date | null; + reasonSameDate?: string | null; }; export type UpdateProfileGovernment = { dateAppoint?: Date | null; dateStart?: Date | null; + reasonSameDate?: string | null; }; diff --git a/src/migration/1711521703929-update_table_profilegov_add_reasonSameDate.ts b/src/migration/1711521703929-update_table_profilegov_add_reasonSameDate.ts new file mode 100644 index 00000000..7a86e018 --- /dev/null +++ b/src/migration/1711521703929-update_table_profilegov_add_reasonSameDate.ts @@ -0,0 +1,18 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableProfilegovAddReasonSameDate1711521703929 implements MigrationInterface { + name = 'UpdateTableProfilegovAddReasonSameDate1711521703929' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileGovernment\` ADD \`reasonSameDate\` varchar(255) NULL COMMENT 'เหตุผลกรณีวันไม่ตรงกัน'`); + await queryRunner.query(`ALTER TABLE \`profile\` ADD \`reasonSameDate\` varchar(255) NULL COMMENT 'เหตุผลกรณีวันไม่ตรงกัน'`); + await queryRunner.query(`ALTER TABLE \`profileHistory\` ADD \`reasonSameDate\` varchar(255) NULL COMMENT 'เหตุผลกรณีวันไม่ตรงกัน'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileHistory\` DROP COLUMN \`reasonSameDate\``); + await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`reasonSameDate\``); + await queryRunner.query(`ALTER TABLE \`profileGovernment\` DROP COLUMN \`reasonSameDate\``); + } + +}