diff --git a/src/controllers/ProfileChangeNameController.ts b/src/controllers/ProfileChangeNameController.ts index fa88a252..0261666f 100644 --- a/src/controllers/ProfileChangeNameController.ts +++ b/src/controllers/ProfileChangeNameController.ts @@ -112,6 +112,7 @@ export class ProfileChangeNameController extends Controller { profile.firstName = body.firstName ?? profile.firstName; profile.lastName = body.lastName ?? profile.lastName; profile.prefix = body.prefix ?? profile.prefix; + profile.rank = body.rank ?? profile.rank; profile.prefixMain = profile.rank ?? profile.prefix; await this.profileRepository.save(profile, { data: req }); setLogDataDiff(req, { before, after: profile }); @@ -184,6 +185,7 @@ export class ProfileChangeNameController extends Controller { profile.firstName = body.firstName ?? profile.firstName; profile.lastName = body.lastName ?? profile.lastName; profile.prefix = body.prefix ?? profile.prefix; + profile.rank = body.rank ?? profile.rank; profile.prefixMain = profile.rank ?? profile.prefix; await this.profileRepository.save(profile, { data: req }); setLogDataDiff(req, { before: before_profile, after: profile }); diff --git a/src/controllers/ProfileChangeNameEmployeeController.ts b/src/controllers/ProfileChangeNameEmployeeController.ts index 0a6f2ff0..91dd3d55 100644 --- a/src/controllers/ProfileChangeNameEmployeeController.ts +++ b/src/controllers/ProfileChangeNameEmployeeController.ts @@ -118,6 +118,7 @@ export class ProfileChangeNameEmployeeController extends Controller { profile.firstName = body.firstName ?? profile.firstName; profile.lastName = body.lastName ?? profile.lastName; profile.prefix = body.prefix ?? profile.prefix; + profile.rank = body.rank ?? profile.rank; profile.prefixMain = profile.rank ?? profile.prefix; await this.profileEmployeeRepo.save(profile, { data: req }); setLogDataDiff(req, { before, after: profile }); @@ -191,6 +192,7 @@ export class ProfileChangeNameEmployeeController extends Controller { profile.firstName = body.firstName ?? profile.firstName; profile.lastName = body.lastName ?? profile.lastName; profile.prefix = body.prefix ?? profile.prefix; + profile.rank = body.rank ?? profile.rank; profile.prefixMain = profile.rank ?? profile.prefix; await this.profileEmployeeRepo.save(profile); } diff --git a/src/controllers/ProfileChangeNameEmployeeTempController.ts b/src/controllers/ProfileChangeNameEmployeeTempController.ts index 92e1e2f3..7f7b39aa 100644 --- a/src/controllers/ProfileChangeNameEmployeeTempController.ts +++ b/src/controllers/ProfileChangeNameEmployeeTempController.ts @@ -109,6 +109,7 @@ export class ProfileChangeNameEmployeeTempController extends Controller { profile.firstName = body.firstName ?? profile.firstName; profile.lastName = body.lastName ?? profile.lastName; profile.prefix = body.prefix ?? profile.prefix; + profile.rank = body.rank ?? profile.rank; profile.prefixMain = profile.rank ?? profile.prefix; await this.profileEmployeeRepo.save(profile, { data: req }); setLogDataDiff(req, { before, after: profile }); @@ -179,6 +180,7 @@ export class ProfileChangeNameEmployeeTempController extends Controller { profile.firstName = body.firstName ?? profile.firstName; profile.lastName = body.lastName ?? profile.lastName; profile.prefix = body.prefix ?? profile.prefix; + profile.rank = body.rank ?? profile.rank; profile.prefixMain = profile.rank ?? profile.prefix; await this.profileEmployeeRepo.save(profile); } diff --git a/src/entities/ProfileChangeName.ts b/src/entities/ProfileChangeName.ts index b02117fc..61e64c24 100644 --- a/src/entities/ProfileChangeName.ts +++ b/src/entities/ProfileChangeName.ts @@ -31,6 +31,14 @@ export class ProfileChangeName extends EntityBase { }) prefix: string; + @Column({ + nullable: true, + comment: "ยศ", + length: 40, + default: null, + }) + rank: string; + @Column({ nullable: true, length: 100, @@ -103,6 +111,7 @@ export class CreateProfileChangeName { profileId: string | null; prefixId: string | null; prefix: string | null; + rank: string | null; firstName: string | null; lastName: string | null; status: string | null; @@ -113,6 +122,7 @@ export class CreateProfileChangeNameEmployee { profileEmployeeId: string | null; prefixId: string | null; prefix: string | null; + rank: string | null; firstName: string | null; lastName: string | null; status: string | null; @@ -122,6 +132,7 @@ export class CreateProfileChangeNameEmployee { export type UpdateProfileChangeName = { prefixId?: string | null; prefix?: string | null; + rank?: string | null; firstName?: string | null; lastName?: string | null; status?: string | null; diff --git a/src/entities/ProfileChangeNameHistory.ts b/src/entities/ProfileChangeNameHistory.ts index 5d296161..5d58a9f7 100644 --- a/src/entities/ProfileChangeNameHistory.ts +++ b/src/entities/ProfileChangeNameHistory.ts @@ -20,6 +20,14 @@ export class ProfileChangeNameHistory extends EntityBase { }) prefix: string; + @Column({ + nullable: true, + comment: "ยศ", + length: 40, + default: null, + }) + rank: string; + @Column({ nullable: true, length: 100, @@ -79,6 +87,7 @@ export class CreateProfileChangeNameHistory { profileChangeNameId: string | null; prefixId: string | null; prefix: string | null; + rank: string | null; firstName: string | null; lastName: string | null; status: string | null; @@ -89,6 +98,7 @@ export type UpdateProfileChangeNameHistory = { profileChangeNameId?: string | null; prefixId?: string | null; prefix?: string | null; + rank?: string | null; firstName?: string | null; lastName?: string | null; status?: string | null; diff --git a/src/migration/1781174051201-update_profileChangeName_add_field_rank.ts b/src/migration/1781174051201-update_profileChangeName_add_field_rank.ts new file mode 100644 index 00000000..b3ec5f92 --- /dev/null +++ b/src/migration/1781174051201-update_profileChangeName_add_field_rank.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateProfileChangeNameAddFieldRank1781174051201 implements MigrationInterface { + name = 'UpdateProfileChangeNameAddFieldRank1781174051201' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileChangeNameHistory\` ADD \`rank\` varchar(40) NULL COMMENT 'ยศ'`); + await queryRunner.query(`ALTER TABLE \`profileChangeName\` ADD \`rank\` varchar(40) NULL COMMENT 'ยศ'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileChangeName\` DROP COLUMN \`rank\``); + await queryRunner.query(`ALTER TABLE \`profileChangeNameHistory\` DROP COLUMN \`rank\``); + } + +}