From 3e6212657076d745cac867b3bb19a74d712e57f0 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 16 May 2024 11:12:17 +0700 Subject: [PATCH 01/11] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=20fa?= =?UTF-8?q?mily?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileFamilyCoupleController.ts | 13 +++++++++---- .../ProfileFamilyCoupleEmployeeController.ts | 7 ++++++- src/controllers/ProfileFamilyFatherController.ts | 1 + .../ProfileFamilyFatherEmployeeController.ts | 1 + src/controllers/ProfileFamilyMotherController.ts | 1 + .../ProfileFamilyMotherEmployeeController.ts | 1 + 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/controllers/ProfileFamilyCoupleController.ts b/src/controllers/ProfileFamilyCoupleController.ts index c2d3d2e9..69a0efc2 100644 --- a/src/controllers/ProfileFamilyCoupleController.ts +++ b/src/controllers/ProfileFamilyCoupleController.ts @@ -33,7 +33,7 @@ export class ProfileFamilyCoupleController extends Controller { @Example({ status: 200, message: "สำเร็จ", - result: [{ + result: { id: "6207ae29-05ef-4abb-9a37-a887265d671e", couple: true, couplePrefix: "string", @@ -45,7 +45,7 @@ export class ProfileFamilyCoupleController extends Controller { coupleLive: true, relationship: "string", profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - }], + }, }) public async getFamilyCouple(@Path() profileId: string) { const profile = await this.profileRepo.findOne({ @@ -55,12 +55,13 @@ export class ProfileFamilyCoupleController extends Controller { if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } - const familyCouple = await this.ProfileFamilyCouple.find({ + const familyCouple = await this.ProfileFamilyCouple.findOne({ select: [ "id", "couple", "couplePrefix", "coupleFirstName", "coupleLastName", "coupleLastNameOld", "coupleCareer", "coupleCitizenId", "coupleLive", "relationship", "profileId", ], where: { profileId }, + order: { lastUpdatedAt: "DESC" }, }); return new HttpSuccess(familyCouple); @@ -150,6 +151,7 @@ export class ProfileFamilyCoupleController extends Controller { await this.ProfileFamilyCouple.save(familyCouple); if (familyCouple) { + profile.relationship = familyCouple.relationship //update profile.relationship const history: ProfileFamilyCoupleHistory = Object.assign(new ProfileFamilyCoupleHistory(), { profileFamilyCoupleId: familyCouple.id, couple: familyCouple.couple, @@ -165,7 +167,10 @@ export class ProfileFamilyCoupleController extends Controller { lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, }); - await this.ProfileFamilyCoupleHistory.save(history); + await Promise.all([ + this.profileRepo.save(profile), + this.ProfileFamilyCoupleHistory.save(history) + ]); } return new HttpSuccess(familyCouple.id); } diff --git a/src/controllers/ProfileFamilyCoupleEmployeeController.ts b/src/controllers/ProfileFamilyCoupleEmployeeController.ts index 8102a6fd..adc4252f 100644 --- a/src/controllers/ProfileFamilyCoupleEmployeeController.ts +++ b/src/controllers/ProfileFamilyCoupleEmployeeController.ts @@ -61,6 +61,7 @@ export class ProfileFamilyCoupleEmployeeController extends Controller { "coupleCareer", "coupleCitizenId", "coupleLive", "relationship", "profileEmployeeId", ], where: { profileEmployeeId }, + order: { lastUpdatedAt: "DESC" }, }); return new HttpSuccess(familyCouple); @@ -150,6 +151,7 @@ export class ProfileFamilyCoupleEmployeeController extends Controller { await this.ProfileFamilyCouple.save(familyCouple); if (familyCouple) { + profile.relationship = familyCouple.relationship //update profileEmployee.relationship const history: ProfileFamilyCoupleHistory = Object.assign(new ProfileFamilyCoupleHistory(), { profileFamilyCoupleId: familyCouple.id, couple: familyCouple.couple, @@ -165,7 +167,10 @@ export class ProfileFamilyCoupleEmployeeController extends Controller { lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, }); - await this.ProfileFamilyCoupleHistory.save(history); + await Promise.all([ + this.profileRepo.save(profile), + this.ProfileFamilyCoupleHistory.save(history) + ]); } return new HttpSuccess(familyCouple.id); } diff --git a/src/controllers/ProfileFamilyFatherController.ts b/src/controllers/ProfileFamilyFatherController.ts index 4a55103a..4334df05 100644 --- a/src/controllers/ProfileFamilyFatherController.ts +++ b/src/controllers/ProfileFamilyFatherController.ts @@ -58,6 +58,7 @@ export class ProfileFamilyFatherController extends Controller { "fatherCareer", "fatherCitizenId", "fatherLive", "profileId", ], where: { profileId }, + order: { lastUpdatedAt: "DESC" }, }); return new HttpSuccess(familyFather); diff --git a/src/controllers/ProfileFamilyFatherEmployeeController.ts b/src/controllers/ProfileFamilyFatherEmployeeController.ts index d494974a..0ab6e963 100644 --- a/src/controllers/ProfileFamilyFatherEmployeeController.ts +++ b/src/controllers/ProfileFamilyFatherEmployeeController.ts @@ -58,6 +58,7 @@ export class ProfileFamilyFatherEmployeeController extends Controller { "fatherCareer", "fatherCitizenId", "fatherLive", "profileEmployeeId", ], where: { profileEmployeeId }, + order: { lastUpdatedAt: "DESC" }, }); return new HttpSuccess(familyFather); diff --git a/src/controllers/ProfileFamilyMotherController.ts b/src/controllers/ProfileFamilyMotherController.ts index c2e60642..923331d7 100644 --- a/src/controllers/ProfileFamilyMotherController.ts +++ b/src/controllers/ProfileFamilyMotherController.ts @@ -58,6 +58,7 @@ export class ProfileFamilyMotherController extends Controller { "motherCareer", "motherCitizenId", "motherLive", "profileId", ], where: { profileId }, + order: { lastUpdatedAt: "DESC" }, }); return new HttpSuccess(familyMother); diff --git a/src/controllers/ProfileFamilyMotherEmployeeController.ts b/src/controllers/ProfileFamilyMotherEmployeeController.ts index 28889e7e..9569937f 100644 --- a/src/controllers/ProfileFamilyMotherEmployeeController.ts +++ b/src/controllers/ProfileFamilyMotherEmployeeController.ts @@ -58,6 +58,7 @@ export class ProfileFamilyMotherEmployeeController extends Controller { "motherCareer", "motherCitizenId", "motherLive", "profileEmployeeId", ], where: { profileEmployeeId }, + order: { lastUpdatedAt: "DESC" }, }); return new HttpSuccess(familyMother); From 701ab5af6efdd7e103df1319740100de0ad4ea30 Mon Sep 17 00:00:00 2001 From: AnandaTon Date: Thu, 16 May 2024 11:36:17 +0700 Subject: [PATCH 02/11] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84?= =?UTF-8?q?=E0=B8=82=E0=B8=9A=E0=B8=B1=E0=B8=84=E0=B8=9B=E0=B8=A3=E0=B8=B1?= =?UTF-8?q?=E0=B8=9A=20salary?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileDisciplineController.ts | 17 +---------------- .../ProfileLeaveEmployeeController.ts | 2 +- .../ProfileNopaidEmployeeController.ts | 16 +--------------- src/entities/ProfileSalaryEmployee.ts | 1 + 4 files changed, 4 insertions(+), 32 deletions(-) diff --git a/src/controllers/ProfileDisciplineController.ts b/src/controllers/ProfileDisciplineController.ts index e7690b77..5bbf85eb 100644 --- a/src/controllers/ProfileDisciplineController.ts +++ b/src/controllers/ProfileDisciplineController.ts @@ -34,24 +34,9 @@ export class ProfileDisciplineController extends Controller { private disciplineHistoryRepository = AppDataSource.getRepository(ProfileDisciplineHistory); @Get("{profileId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - date: "2024-03-12T10:09:47.000Z", - level: "string", - detail: "string", - unStigma: "string", - refCommandNo: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - }, - ], - }) public async getDiscipline(@Path() profileId: string) { const lists = await this.disciplineRepository.find({ - where: { profileId: profileId }, + where: { profileEmployeeId: profileId }, select: [ "id", "date", diff --git a/src/controllers/ProfileLeaveEmployeeController.ts b/src/controllers/ProfileLeaveEmployeeController.ts index 6fa06140..d62cb018 100644 --- a/src/controllers/ProfileLeaveEmployeeController.ts +++ b/src/controllers/ProfileLeaveEmployeeController.ts @@ -40,7 +40,7 @@ export class ProfileLeaveEmployeeController extends Controller { public async getLeave(@Path() profileId: string) { const record = await this.leaveRepo.find({ relations: { leaveType: true }, - where: { profileId }, + where: { profileEmployeeId: profileId }, }); return new HttpSuccess(record); } diff --git a/src/controllers/ProfileNopaidEmployeeController.ts b/src/controllers/ProfileNopaidEmployeeController.ts index fc54a656..bec7b723 100644 --- a/src/controllers/ProfileNopaidEmployeeController.ts +++ b/src/controllers/ProfileNopaidEmployeeController.ts @@ -34,23 +34,9 @@ export class ProfileNopaidEmployeeController extends Controller { private nopaidHistoryRepository = AppDataSource.getRepository(ProfileNopaidHistory); @Get("{profileId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - date: "2024-03-12T10:09:47.000Z", - reference: "string", - detail: "string", - refCommandNo: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - }, - ], - }) public async getNopaid(@Path() profileId: string) { const lists = await this.nopaidRepository.find({ - where: { profileId }, + where: { profileEmployeeId: profileId }, }); return new HttpSuccess(lists); } diff --git a/src/entities/ProfileSalaryEmployee.ts b/src/entities/ProfileSalaryEmployee.ts index 7b21dc74..4a19c04d 100644 --- a/src/entities/ProfileSalaryEmployee.ts +++ b/src/entities/ProfileSalaryEmployee.ts @@ -229,6 +229,7 @@ export class ProfileSalaryEmployee extends EntityBase { // commandNo: string; @Column({ + nullable: true, comment: "ประเภทคำสั่ง", type: "text", }) From 17d9958882b90c3d20d13fb22c07db0630fc9e1f Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 16 May 2024 11:41:26 +0700 Subject: [PATCH 03/11] no message --- src/controllers/ProfileAvatarController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/ProfileAvatarController.ts b/src/controllers/ProfileAvatarController.ts index 547782d4..83774c49 100644 --- a/src/controllers/ProfileAvatarController.ts +++ b/src/controllers/ProfileAvatarController.ts @@ -69,7 +69,7 @@ export class ProfileAvatarController extends Controller { Object.assign(data, { ...body, ...meta }); - await this.avatarRepository.save(data); + // await this.avatarRepository.save(data); let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}`; let fileName = `profile-${data.id}`; From 3ea5ec3486e8a3bee9b049ef1b45522e1fa31895 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 16 May 2024 12:13:46 +0700 Subject: [PATCH 04/11] =?UTF-8?q?=E0=B8=AD=E0=B8=B1=E0=B8=9E=E0=B8=A3?= =?UTF-8?q?=E0=B8=B9=E0=B8=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileAvatarController.ts | 26 +++++--- .../ProfileAvatarEmployeeController.ts | 59 ++++++++++++++++--- src/entities/ProfileEmployee.ts | 9 ++- 3 files changed, 77 insertions(+), 17 deletions(-) diff --git a/src/controllers/ProfileAvatarController.ts b/src/controllers/ProfileAvatarController.ts index 83774c49..3f2c60bb 100644 --- a/src/controllers/ProfileAvatarController.ts +++ b/src/controllers/ProfileAvatarController.ts @@ -44,6 +44,8 @@ export class ProfileAvatarController extends Controller { result.isActive = true; profile.avatar = result.avatar; profile.avatarName = result.avatarName; + await this.avatarRepository.save(result); + await this.profileRepository.save(profile); return new HttpSuccess(); } @@ -51,7 +53,6 @@ export class ProfileAvatarController extends Controller { public async newAvatar(@Request() req: RequestWithUser, @Body() body: CreateProfileAvatar) { const profile = await this.profileRepository.findOne({ where: { id: body.profileId }, - relations: ["profileAvatars"], }); if (!profile) { @@ -69,16 +70,10 @@ export class ProfileAvatarController extends Controller { Object.assign(data, { ...body, ...meta }); - // await this.avatarRepository.save(data); + await this.avatarRepository.save(data); let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}`; let fileName = `profile-${data.id}`; - await Promise.all( - profile.profileAvatars.map(async (item: any) => { - item.isActive = false; - await this.avatarRepository.save(item); - }), - ); data.isActive = true; data.avatar = avatar; data.avatarName = fileName; @@ -87,6 +82,21 @@ export class ProfileAvatarController extends Controller { profile.avatarName = fileName; await this.profileRepository.save(profile); + const _profile = await this.profileRepository.findOne({ + where: { id: body.profileId }, + relations: ["profileAvatars"], + }); + + if (!_profile) { + throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); + } + await Promise.all( + _profile.profileAvatars.map(async (item: any) => { + item.isActive = false; + await this.avatarRepository.save(item); + }), + ); + return new HttpSuccess({ avatar: avatar, avatarName: fileName }); } diff --git a/src/controllers/ProfileAvatarEmployeeController.ts b/src/controllers/ProfileAvatarEmployeeController.ts index e1a7a7d0..9159b645 100644 --- a/src/controllers/ProfileAvatarEmployeeController.ts +++ b/src/controllers/ProfileAvatarEmployeeController.ts @@ -14,20 +14,49 @@ export class ProfileAvatarEmployeeController extends Controller { private profileRepository = AppDataSource.getRepository(ProfileEmployee); private avatarRepository = AppDataSource.getRepository(ProfileAvatar); - @Get("{profileId}") - public async getAvatar(@Path() profileId: string) { + @Get("{profileEmployeeId}") + public async getAvatarEmployee(@Path() profileEmployeeId: string) { const lists = await this.avatarRepository.find({ - where: { profileEmployeeId: profileId }, + where: { profileEmployeeId }, }); return new HttpSuccess(lists); } + @Get("select/{profileEmployeeId}/{id}") + public async selectAvatarEmployee(@Path() profileEmployeeId: string, @Path() id: string) { + const result = await this.avatarRepository.findOneBy({ id: id }); + if (!result) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + } + const profile = await this.profileRepository.findOne({ + where: { id: profileEmployeeId }, + relations: ["profileAvatars"], + }); + if (!profile) { + throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); + } + await Promise.all( + profile.profileAvatars.map(async (item: any) => { + item.isActive = false; + await this.avatarRepository.save(item); + }), + ); + result.isActive = true; + profile.avatar = result.avatar; + profile.avatarName = result.avatarName; + await this.avatarRepository.save(result); + await this.profileRepository.save(profile); + return new HttpSuccess(); + } + @Post() - public async newAvatar( + public async newAvatarEmployee( @Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeAvatar, ) { - const profile = await this.profileRepository.findOneBy({ id: body.profileEmployeeId }); + const profile = await this.profileRepository.findOne({ + where: { id: body.profileEmployeeId }, + }); if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); @@ -45,17 +74,31 @@ export class ProfileAvatarEmployeeController extends Controller { Object.assign(data, { ...body, ...meta }); await this.avatarRepository.save(data); - let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}/profile-employee-${data.id}`; + let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}`; + let fileName = `profile-${data.id}`; + + data.isActive = true; data.avatar = avatar; + data.avatarName = fileName; await this.avatarRepository.save(data); profile.avatar = avatar; + profile.avatarName = fileName; await this.profileRepository.save(profile); - return new HttpSuccess(avatar); + const _profile = await this.profileRepository.findOne({ + where: { id: body.profileEmployeeId }, + relations: ["profileAvatars"], + }); + + if (!_profile) { + throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); + } + + return new HttpSuccess({ avatar: avatar, avatarName: fileName }); } @Delete("{avatarId}") - public async deleteAvatar(@Path() avatarId: string) { + public async deleteAvatarEmployee(@Path() avatarId: string) { const result = await this.avatarRepository.delete({ id: avatarId }); if (result.affected == undefined || result.affected <= 0) { diff --git a/src/entities/ProfileEmployee.ts b/src/entities/ProfileEmployee.ts index 4421a7fb..02d888d5 100644 --- a/src/entities/ProfileEmployee.ts +++ b/src/entities/ProfileEmployee.ts @@ -38,6 +38,13 @@ export class ProfileEmployee extends EntityBase { }) avatar: string; + @Column({ + nullable: true, + comment: "รูปถ่าย", + default: null, + }) + avatarName: string; + @Column({ nullable: true, comment: "ประเภทลูกจ้าง (perm->ลูกจ้างประจำ temp->ลูกจ้างชั่วคราว)", @@ -475,4 +482,4 @@ export type UpdateProfileAddressEmployee = { currentDistrictId?: string | null; currentSubDistrictId?: string | null; currentZipCode?: string | null; -}; \ No newline at end of file +}; From 61899e8431a3769332b0b0dbfa43fa618856536d Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 16 May 2024 12:18:51 +0700 Subject: [PATCH 05/11] no message --- src/controllers/ProfileAvatarController.ts | 24 +++++++++---------- .../ProfileAvatarEmployeeController.ts | 24 ++++++++++++------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/controllers/ProfileAvatarController.ts b/src/controllers/ProfileAvatarController.ts index 3f2c60bb..a97cb6a1 100644 --- a/src/controllers/ProfileAvatarController.ts +++ b/src/controllers/ProfileAvatarController.ts @@ -70,18 +70,6 @@ export class ProfileAvatarController extends Controller { Object.assign(data, { ...body, ...meta }); - await this.avatarRepository.save(data); - let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}`; - let fileName = `profile-${data.id}`; - - data.isActive = true; - data.avatar = avatar; - data.avatarName = fileName; - await this.avatarRepository.save(data); - profile.avatar = avatar; - profile.avatarName = fileName; - await this.profileRepository.save(profile); - const _profile = await this.profileRepository.findOne({ where: { id: body.profileId }, relations: ["profileAvatars"], @@ -97,6 +85,18 @@ export class ProfileAvatarController extends Controller { }), ); + await this.avatarRepository.save(data); + let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}`; + let fileName = `profile-${data.id}`; + + data.isActive = true; + data.avatar = avatar; + data.avatarName = fileName; + await this.avatarRepository.save(data); + profile.avatar = avatar; + profile.avatarName = fileName; + await this.profileRepository.save(profile); + return new HttpSuccess({ avatar: avatar, avatarName: fileName }); } diff --git a/src/controllers/ProfileAvatarEmployeeController.ts b/src/controllers/ProfileAvatarEmployeeController.ts index 9159b645..362902bc 100644 --- a/src/controllers/ProfileAvatarEmployeeController.ts +++ b/src/controllers/ProfileAvatarEmployeeController.ts @@ -73,6 +73,21 @@ export class ProfileAvatarEmployeeController extends Controller { Object.assign(data, { ...body, ...meta }); + const _profile = await this.profileRepository.findOne({ + where: { id: body.profileEmployeeId }, + relations: ["profileAvatars"], + }); + + if (!_profile) { + throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); + } + await Promise.all( + _profile.profileAvatars.map(async (item: any) => { + item.isActive = false; + await this.avatarRepository.save(item); + }), + ); + await this.avatarRepository.save(data); let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}`; let fileName = `profile-${data.id}`; @@ -85,15 +100,6 @@ export class ProfileAvatarEmployeeController extends Controller { profile.avatarName = fileName; await this.profileRepository.save(profile); - const _profile = await this.profileRepository.findOne({ - where: { id: body.profileEmployeeId }, - relations: ["profileAvatars"], - }); - - if (!_profile) { - throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); - } - return new HttpSuccess({ avatar: avatar, avatarName: fileName }); } From 62166c430eea1bdfcd26b61cadc7d19ce40f8f5b Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 16 May 2024 12:23:37 +0700 Subject: [PATCH 06/11] no message --- ...update_table_ProfileAvatar_add_isactive2.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/migration/1715836928018-update_table_ProfileAvatar_add_isactive2.ts diff --git a/src/migration/1715836928018-update_table_ProfileAvatar_add_isactive2.ts b/src/migration/1715836928018-update_table_ProfileAvatar_add_isactive2.ts new file mode 100644 index 00000000..e387096f --- /dev/null +++ b/src/migration/1715836928018-update_table_ProfileAvatar_add_isactive2.ts @@ -0,0 +1,18 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableProfileAvatarAddIsactive21715836928018 implements MigrationInterface { + name = 'UpdateTableProfileAvatarAddIsactive21715836928018' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`avatarName\` varchar(255) NULL COMMENT 'รูปถ่าย'`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`avatarName\` varchar(255) NULL COMMENT 'รูปถ่าย'`); + await queryRunner.query(`ALTER TABLE \`profileSalaryEmployee\` CHANGE \`commandTypeName\` \`commandTypeName\` text NULL COMMENT 'ประเภทคำสั่ง'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileSalaryEmployee\` CHANGE \`commandTypeName\` \`commandTypeName\` text NOT NULL COMMENT 'ประเภทคำสั่ง'`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`avatarName\``); + await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`avatarName\``); + } + +} From feb8da39473fcab40e4b71e820615dbe4e6ebb1d Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 16 May 2024 13:39:25 +0700 Subject: [PATCH 07/11] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1search=20avatar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 31 +++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index d2c87cf1..f9da44c6 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -196,7 +196,10 @@ export class ProfileController extends Controller { } if (body.citizenId.length !== 13) { - throw new HttpError(HttpStatus.NOT_FOUND, "กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชนให้ครบ 13 หลัก"); + throw new HttpError( + HttpStatus.NOT_FOUND, + "กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชนให้ครบ 13 หลัก", + ); } if (body.citizenId) { @@ -216,16 +219,16 @@ export class ProfileController extends Controller { citizenIdDigits[11] * 2; const calStp2 = cal % 11; let chkDigit = 11 - calStp2; - if(chkDigit === 10){ + if (chkDigit === 10) { chkDigit = 1; - }else if(chkDigit === 11){ + } else if (chkDigit === 11) { chkDigit = chkDigit % 10; } // else if(chkDigit === 11){ // chkDigit = cal % 10; // } - - if(citizenIdDigits[12] !== chkDigit){ + + if (citizenIdDigits[12] !== chkDigit) { throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"); } } @@ -245,7 +248,6 @@ export class ProfileController extends Controller { // profile.dateRetireLaw = calculateRetireDate(profile.birthDate); await this.profileRepo.save(profile); - return new HttpSuccess(); } @@ -331,9 +333,12 @@ export class ProfileController extends Controller { if (body.posTypeId && !(await this.posTypeRepo.findOneBy({ id: body.posTypeId }))) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้"); } - + if (body.citizenId && body.citizenId.length !== 13) { - throw new HttpError(HttpStatus.NOT_FOUND, "กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชนให้ครบ 13 หลัก"); + throw new HttpError( + HttpStatus.NOT_FOUND, + "กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชนให้ครบ 13 หลัก", + ); } if (body.citizenId) { @@ -353,16 +358,16 @@ export class ProfileController extends Controller { citizenIdDigits[11] * 2; const calStp2 = cal % 11; let chkDigit = 11 - calStp2; - if(chkDigit === 10){ + if (chkDigit === 10) { chkDigit = 1; - }else if(chkDigit === 11){ + } else if (chkDigit === 11) { chkDigit = chkDigit % 10; } // else if(chkDigit === 11){ // chkDigit = cal % 10; // } - - if(citizenIdDigits[12] !== chkDigit){ + + if (citizenIdDigits[12] !== chkDigit) { throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"); } } @@ -652,6 +657,8 @@ export class ProfileController extends Controller { return { id: _data.id, + avatar: _data.avatar, + avatarName: _data.avatarName, prefix: _data.prefix, rank: _data.rank, firstName: _data.firstName, From 4676b62a6fb20c0bb61384f45f8ef72ad1e647b1 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 16 May 2024 14:10:08 +0700 Subject: [PATCH 08/11] no message --- src/entities/ProfileSalary.ts | 2 ++ ...update_table_ProfileAvatar_add_isactive3.ts | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/migration/1715843317765-update_table_ProfileAvatar_add_isactive3.ts diff --git a/src/entities/ProfileSalary.ts b/src/entities/ProfileSalary.ts index 908f8db6..5a423a3a 100644 --- a/src/entities/ProfileSalary.ts +++ b/src/entities/ProfileSalary.ts @@ -16,9 +16,11 @@ import { ProfileSalaryHistory } from "./ProfileSalaryHistory"; @Entity("profileSalary") export class ProfileSalary extends EntityBase { @Column({ + nullable: true, length: 40, comment: "คีย์นอก(FK)ของตาราง profile", type: "uuid", + default: null, }) profileId: string; diff --git a/src/migration/1715843317765-update_table_ProfileAvatar_add_isactive3.ts b/src/migration/1715843317765-update_table_ProfileAvatar_add_isactive3.ts new file mode 100644 index 00000000..300e279c --- /dev/null +++ b/src/migration/1715843317765-update_table_ProfileAvatar_add_isactive3.ts @@ -0,0 +1,18 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableProfileAvatarAddIsactive31715843317765 implements MigrationInterface { + name = 'UpdateTableProfileAvatarAddIsactive31715843317765' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileSalary\` DROP FOREIGN KEY \`FK_7534d36579c78107ba08a96be6f\``); + await queryRunner.query(`ALTER TABLE \`profileSalary\` CHANGE \`profileId\` \`profileId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง profile'`); + await queryRunner.query(`ALTER TABLE \`profileSalary\` ADD CONSTRAINT \`FK_7534d36579c78107ba08a96be6f\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileSalary\` DROP FOREIGN KEY \`FK_7534d36579c78107ba08a96be6f\``); + await queryRunner.query(`ALTER TABLE \`profileSalary\` CHANGE \`profileId\` \`profileId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง profile'`); + await queryRunner.query(`ALTER TABLE \`profileSalary\` ADD CONSTRAINT \`FK_7534d36579c78107ba08a96be6f\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + +} From fe6b5b5b0499f83eecc9a3098b3037d206758007 Mon Sep 17 00:00:00 2001 From: AnandaTon Date: Thu, 16 May 2024 14:10:17 +0700 Subject: [PATCH 09/11] Update ProfileDisciplineController.ts --- src/controllers/ProfileDisciplineController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/ProfileDisciplineController.ts b/src/controllers/ProfileDisciplineController.ts index 5bbf85eb..cb374bb9 100644 --- a/src/controllers/ProfileDisciplineController.ts +++ b/src/controllers/ProfileDisciplineController.ts @@ -36,7 +36,7 @@ export class ProfileDisciplineController extends Controller { @Get("{profileId}") public async getDiscipline(@Path() profileId: string) { const lists = await this.disciplineRepository.find({ - where: { profileEmployeeId: profileId }, + where: { profileId: profileId }, select: [ "id", "date", From 3b5096c0050f83a05702043f46332871461271be Mon Sep 17 00:00:00 2001 From: AnandaTon Date: Thu, 16 May 2024 15:03:29 +0700 Subject: [PATCH 10/11] =?UTF-8?q?fix=20SalaryEmployee=20=E0=B8=A5=E0=B8=9A?= =?UTF-8?q?=E0=B9=84=E0=B8=9F=E0=B8=A5=E0=B9=8C=20=E0=B8=A3=E0=B8=A7?= =?UTF-8?q?=E0=B8=A1=E0=B9=84=E0=B8=9F=E0=B8=A5=E0=B9=8C=20=E0=B9=80?= =?UTF-8?q?=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1=20field?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OrganizationUnauthorizeController.ts | 6 +- src/controllers/ProfileEmployeeController.ts | 34 +- .../ProfileSalaryEmployeeController.ts | 18 +- src/entities/ProfileEmployee.ts | 6 +- src/entities/ProfileSalary.ts | 23 +- src/entities/ProfileSalaryEmployee.ts | 448 ------------------ src/entities/ProfileSalaryEmployeeHistory.ts | 440 ----------------- 7 files changed, 55 insertions(+), 920 deletions(-) delete mode 100644 src/entities/ProfileSalaryEmployee.ts delete mode 100644 src/entities/ProfileSalaryEmployeeHistory.ts diff --git a/src/controllers/OrganizationUnauthorizeController.ts b/src/controllers/OrganizationUnauthorizeController.ts index eb232e63..7086622a 100644 --- a/src/controllers/OrganizationUnauthorizeController.ts +++ b/src/controllers/OrganizationUnauthorizeController.ts @@ -277,7 +277,7 @@ export class OrganizationUnauthorizeController extends Controller { .leftJoinAndSelect("employeePosMaster.orgChild3", "orgChild3") .leftJoinAndSelect("employeePosMaster.orgChild4", "orgChild4") .leftJoinAndSelect("employeePosMaster.positions", "positions") - .leftJoinAndSelect("current_holder.profileSalary", "profileSalary") + .leftJoinAndSelect("current_holder.profileSalarys", "profileSalarys") .leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines") .leftJoinAndSelect("current_holder.posLevel", "posLevel") .leftJoinAndSelect("current_holder.posType", "posType") @@ -370,9 +370,9 @@ export class OrganizationUnauthorizeController extends Controller { } const amount = - item.current_holder == null || item.current_holder.profileSalary.length == 0 + item.current_holder == null || item.current_holder.profileSalarys.length == 0 ? null - : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount; + : item.current_holder.profileSalarys.sort((a: any, b: any) => b.date - a.date)[0].amount; let datePeriodStart = new Date( `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, ); diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 05d58bd1..19bcbf13 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -73,9 +73,12 @@ export class ProfileEmployeeController extends Controller { if (body.posTypeId && !(await this.posTypeRepo.findOneBy({ id: body.posTypeId }))) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้"); } - + if (body.citizenId.length !== 13) { - throw new HttpError(HttpStatus.NOT_FOUND, "กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชนให้ครบ 13 หลัก"); + throw new HttpError( + HttpStatus.NOT_FOUND, + "กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชนให้ครบ 13 หลัก", + ); } if (body.citizenId) { @@ -95,16 +98,16 @@ export class ProfileEmployeeController extends Controller { citizenIdDigits[11] * 2; const calStp2 = cal % 11; let chkDigit = 11 - calStp2; - if(chkDigit === 10){ + if (chkDigit === 10) { chkDigit = 1; - }else if(chkDigit === 11){ + } else if (chkDigit === 11) { chkDigit = chkDigit % 10; } // else if(chkDigit === 11){ // chkDigit = cal % 10; // } - - if(citizenIdDigits[12] !== chkDigit){ + + if (citizenIdDigits[12] !== chkDigit) { throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"); } } @@ -155,7 +158,10 @@ export class ProfileEmployeeController extends Controller { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้"); } if (body.citizenId && body.citizenId.length !== 13) { - throw new HttpError(HttpStatus.NOT_FOUND, "กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชนให้ครบ 13 หลัก"); + throw new HttpError( + HttpStatus.NOT_FOUND, + "กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชนให้ครบ 13 หลัก", + ); } if (body.citizenId) { @@ -175,16 +181,16 @@ export class ProfileEmployeeController extends Controller { citizenIdDigits[11] * 2; const calStp2 = cal % 11; let chkDigit = 11 - calStp2; - if(chkDigit === 10){ + if (chkDigit === 10) { chkDigit = 1; - }else if(chkDigit === 11){ + } else if (chkDigit === 11) { chkDigit = chkDigit % 10; } // else if(chkDigit === 11){ // chkDigit = cal % 10; // } - - if(citizenIdDigits[12] !== chkDigit){ + + if (citizenIdDigits[12] !== chkDigit) { throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"); } } @@ -1047,7 +1053,7 @@ export class ProfileEmployeeController extends Controller { .leftJoinAndSelect("employeePosMaster.orgChild3", "orgChild3") .leftJoinAndSelect("employeePosMaster.orgChild4", "orgChild4") .leftJoinAndSelect("employeePosMaster.positions", "positions") - .leftJoinAndSelect("current_holder.profileSalary", "profileSalary") + .leftJoinAndSelect("current_holder.profileSalarys", "profileSalarys") .leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines") .leftJoinAndSelect("current_holder.posLevel", "posLevel") .leftJoinAndSelect("current_holder.posType", "posType") @@ -1145,9 +1151,9 @@ export class ProfileEmployeeController extends Controller { } const amount = - item.current_holder == null || item.current_holder.profileSalary.length == 0 + item.current_holder == null || item.current_holder.profileSalarys.length == 0 ? null - : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount; + : item.current_holder.profileSalarys.sort((a: any, b: any) => b.date - a.date)[0].amount; let datePeriodStart = new Date( `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, ); diff --git a/src/controllers/ProfileSalaryEmployeeController.ts b/src/controllers/ProfileSalaryEmployeeController.ts index 724dcbe0..890bc7a8 100644 --- a/src/controllers/ProfileSalaryEmployeeController.ts +++ b/src/controllers/ProfileSalaryEmployeeController.ts @@ -15,9 +15,9 @@ import { import { AppDataSource } from "../database/data-source"; import { CreateProfileSalaryEmployee, - ProfileSalaryEmployee, + ProfileSalary, UpdateProfileSalaryEmployee, -} from "../entities/ProfileSalaryEmployee"; +} from "../entities/ProfileSalary"; import HttpSuccess from "../interfaces/http-success"; import HttpStatus from "../interfaces/http-status"; import HttpError from "../interfaces/http-error"; @@ -31,13 +31,13 @@ import { LessThan, MoreThan } from "typeorm"; @Security("bearerAuth") export class ProfileSalaryEmployeeController extends Controller { private profileRepo = AppDataSource.getRepository(ProfileEmployee); - private salaryRepo = AppDataSource.getRepository(ProfileSalaryEmployee); + private salaryRepo = AppDataSource.getRepository(ProfileSalary); private salaryHistoryRepo = AppDataSource.getRepository(ProfileSalaryHistory); @Get("{profileId}") public async getSalary(@Path() profileId: string) { const record = await this.salaryRepo.find({ - where: { profileId: profileId }, + where: { profileEmployeeId: profileId }, order: { order: "ASC" }, }); return new HttpSuccess(record); @@ -56,22 +56,22 @@ export class ProfileSalaryEmployeeController extends Controller { @Request() req: RequestWithUser, @Body() body: CreateProfileSalaryEmployee, ) { - if (!body.profileId) { - throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); + if (!body.profileEmployeeId) { + throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); } - const profile = await this.profileRepo.findOneBy({ id: body.profileId }); + const profile = await this.profileRepo.findOneBy({ id: body.profileEmployeeId }); if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const dest_item = await this.salaryRepo.findOne({ - where: { profileId: body.profileId }, + where: { profileId: body.profileEmployeeId }, order: { order: "DESC" }, }); - const data = new ProfileSalaryEmployee(); + const data = new ProfileSalary(); const meta = { order: dest_item == null ? 1 : dest_item.order + 1, diff --git a/src/entities/ProfileEmployee.ts b/src/entities/ProfileEmployee.ts index 02d888d5..dcfabc9f 100644 --- a/src/entities/ProfileEmployee.ts +++ b/src/entities/ProfileEmployee.ts @@ -3,7 +3,7 @@ import { EntityBase } from "./base/Base"; import { EmployeePosLevel } from "./EmployeePosLevel"; import { EmployeePosType } from "./EmployeePosType"; import { EmployeePosMaster } from "./EmployeePosMaster"; -import { ProfileSalaryEmployee } from "./ProfileSalaryEmployee"; +import { ProfileSalary } from "./ProfileSalary"; import { ProfileCertificate } from "./ProfileCertificate"; import { ProfileTraining } from "./ProfileTraining"; import { ProfileInsignia } from "./ProfileInsignia"; @@ -236,8 +236,8 @@ export class ProfileEmployee extends EntityBase { @OneToMany(() => EmployeePosMaster, (v) => v.next_holder) next_holders: EmployeePosMaster[]; - @OneToMany(() => ProfileSalaryEmployee, (v) => v.profile) - profileSalary: ProfileSalaryEmployee[]; + @OneToMany(() => ProfileSalary, (v) => v.profile) + profileSalarys: ProfileSalary[]; @OneToMany(() => ProfileCertificate, (v) => v.profileEmployee) profileCertificates: ProfileCertificate[]; diff --git a/src/entities/ProfileSalary.ts b/src/entities/ProfileSalary.ts index 5a423a3a..1f568f7d 100644 --- a/src/entities/ProfileSalary.ts +++ b/src/entities/ProfileSalary.ts @@ -175,9 +175,26 @@ export class CreateProfileSalaryEmployee { mouthSalaryAmount?: Double | null; posNo: string | null; position: string | null; - positionLine: string | null; - positionPathSide: string | null; - positionExecutive: string | null; + // positionLine: string | null; + // positionPathSide: string | null; + // positionExecutive: string | null; + positionType: string | null; + positionLevel: string | null; + refCommandNo: string | null; + templateDoc: string | null; +} + +export class UpdateProfileSalaryEmployee { + profileEmployeeId: string | null; + date?: Date | null; + amount?: Double | null; + positionSalaryAmount?: Double | null; + mouthSalaryAmount?: Double | null; + posNo: string | null; + position: string | null; + // positionLine: string | null; + // positionPathSide: string | null; + // positionExecutive: string | null; positionType: string | null; positionLevel: string | null; refCommandNo: string | null; diff --git a/src/entities/ProfileSalaryEmployee.ts b/src/entities/ProfileSalaryEmployee.ts deleted file mode 100644 index 4a19c04d..00000000 --- a/src/entities/ProfileSalaryEmployee.ts +++ /dev/null @@ -1,448 +0,0 @@ -import { Entity, Column, OneToMany, JoinColumn, ManyToOne, Double } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { ProfileSalaryEmployeeHistory } from "./ProfileSalaryEmployeeHistory"; -import { ProfileEmployee } from "./ProfileEmployee"; - -@Entity("profileSalaryEmployee") -export class ProfileSalaryEmployee extends EntityBase { - @Column({ - comment: "วันที่", - type: "datetime", - nullable: true, - }) - date: Date; - - @Column({ - comment: "เงินเดือนฐาน", - default: 0, - nullable: true, - type: "double", - }) - amount: Double; - - @Column({ - comment: "เงินประจำตำแหน่ง", - default: 0, - nullable: true, - type: "double", - }) - positionSalaryAmount: Double; - - @Column({ - comment: "เงินค่าตอบแทนรายเดือน", - default: 0, - nullable: true, - type: "double", - }) - mouthSalaryAmount: Double; - - @Column({ - length: 40, - comment: "คีย์นอก(FK)ของตาราง profile", - type: "uuid", - }) - profileId: string; - - @Column({ - comment: "สถานะการใช้งาน", - default: false, - }) - isActive: boolean; - - @Column({ - nullable: true, - comment: "ตำแหน่ง (รายละเอียด)", - type: "text", - default: null, - }) - salaryClass: string; - - @Column({ - nullable: true, - comment: "เอกสารอ้างอิง", - type: "text", - default: null, - }) - salaryRef: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id เลขที่ตำแหน่ง", - type: "uuid", - default: null, - }) - posNoId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id เลขที่ตำแหน่ง", - type: "uuid", - default: null, - }) - positionId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id สังกัด", - type: "uuid", - default: null, - }) - ocId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id ตำแหน่งทางการบริหาร", - type: "uuid", - default: null, - }) - positionExecutiveId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id ด้านทางการบริหาร", - type: "uuid", - default: null, - }) - positionExecutiveSideId: string; - - @Column({ - nullable: true, - length: 40, - comment: "", - type: "uuid", - default: null, - }) - positionLevelId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id สายงาน", - type: "uuid", - default: null, - }) - positionLineId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id ด้าน/สาขา", - type: "uuid", - default: null, - }) - positionPathSideId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id ประเภทตำแหน่ง", - type: "uuid", - default: null, - }) - positionTypeId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id ชื่อย่อหน่วยงาน", - type: "uuid", - default: null, - }) - organizationShortNameId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id กลุ่มงาน", - type: "uuid", - default: null, - }) - positionEmployeeGroupId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id ระดับชั้นงาน", - type: "uuid", - default: null, - }) - positionEmployeeLevelId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id ตำแหน่ง", - type: "uuid", - default: null, - }) - positionEmployeePositionId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id ด้านของตำแหน่ง", - type: "uuid", - default: null, - }) - positionEmployeePositionSideId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id เลขที่ตำแหน่งลูกจ้าง", - default: null, - }) - posNoEmployee: string; - - @Column({ - nullable: true, - type: "datetime", - comment: "เอกสารอ้างอิง (ลงวันที่)", - default: null, - }) - refCommandDate: Date; - - @Column({ - nullable: true, - comment: "เอกสารอ้างอิง (เลขที่คำสั่ง)", - type: "text", - default: null, - }) - refCommandNo: string; - - @Column({ - nullable: true, - comment: "ลำดับ", - default: null, - }) - order: number; - - // @Column({ - // comment: "เลขที่คำสั่ง", - // type: "text", - // }) - // commandNo: string; - - @Column({ - nullable: true, - comment: "ประเภทคำสั่ง", - type: "text", - }) - commandTypeName: string; - - @Column({ - nullable: true, - comment: "ประเภทตำแหน่งกรณีพิเศษ", - type: "text", - default: null, - }) - salaryStatus: string; - - @OneToMany( - () => ProfileSalaryEmployeeHistory, - (profileSalaryHistory) => profileSalaryHistory.histories, - ) - profileSalaryHistories: ProfileSalaryEmployeeHistory[]; - - @ManyToOne(() => ProfileEmployee, (profile) => profile.profileSalary) - @JoinColumn({ name: "profileId" }) - profile: ProfileEmployee; -} - -export class CreateProfileSalaryEmployee { - @Column({ - type: "datetime", - }) - date: Date; - - @Column({ - type: "double", - }) - amount: Double; - - @Column({ - type: "double", - }) - positionSalaryAmount: Double; - - @Column({ - type: "double", - }) - mouthSalaryAmount: Double; - - @Column({ - type: "uuid", - }) - profileId: string; - - // @Column() - // isActive: boolean; - - // @Column() - // salaryClass: string | null; - - // @Column() - // salaryRef: string | null; - - // @Column("uuid") - // posNoId: string | null; - - // @Column("uuid") - // positionId: string | null; - - // @Column("uuid") - // ocId: string | null; - - // @Column("uuid") - // positionExecutiveId : string | null; - - // @Column("uuid") - // positionExecutiveSideId : string | null; - - // @Column("uuid") - // positionLevelId : string | null; - - // @Column("uuid") - // positionLineId : string | null; - - // @Column("uuid") - // positionPathSideId : string | null; - - // @Column("uuid") - // positionTypeId : string | null; - - // @Column("uuid") - // organizationShortNameId : string | null; - - // @Column("uuid") - // positionEmployeeGroupId : string | null; - - // @Column("uuid") - // positionEmployeeLevelId : string | null; - - // @Column("uuid") - // positionEmployeePositionId : string | null; - - // @Column("uuid") - // positionEmployeePositionSideId : string | null; - - // @Column() - // posNoEmployee : string | null; - - // @Column() - // refCommandDate: Date | null; - - // @Column() - // refCommandNo: string | null; - - // @Column() - // order: number | null; - - // @Column() - // commandNo: string; - - // @Column() - // commandTypeName: string; - - // @Column() - // salaryStatus: string | null; -} - -export class UpdateProfileSalaryEmployee { - @Column({ - type: "datetime", - }) - date: Date; - - @Column({ - type: "double", - }) - amount: Double; - - @Column({ - type: "double", - }) - positionSalaryAmount: Double; - - @Column({ - type: "double", - }) - mouthSalaryAmount: Double; - - // @Column() - // isActive: boolean; - - // @Column() - // salaryClass: string; - - // @Column() - // salaryRef: string; - - // @Column("uuid") - // posNoId: string; - - // @Column("uuid") - // positionId: string; - - // @Column("uuid") - // ocId: string; - - // @Column("uuid") - // positionExecutiveId : string; - - // @Column("uuid") - // positionExecutiveSideId : string; - - // @Column("uuid") - // positionLevelId : string; - - // @Column("uuid") - // positionLineId : string; - - // @Column("uuid") - // positionPathSideId : string; - - // @Column("uuid") - // positionTypeId : string; - - // @Column("uuid") - // organizationShortNameId : string; - - // @Column("uuid") - // positionEmployeeGroupId : string; - - // @Column("uuid") - // positionEmployeeLevelId : string; - - // @Column("uuid") - // positionEmployeePositionId : string; - - // @Column("uuid") - // positionEmployeePositionSideId : string; - - // @Column() - // posNoEmployee : string; - - // @Column() - // refCommandDate: Date; - - // @Column() - // refCommandNo: string; - - // @Column() - // order: number; - - // @Column() - // commandNo: string; - - // @Column() - // commandTypeName: string; - - // @Column() - // salaryStatus: string; -} diff --git a/src/entities/ProfileSalaryEmployeeHistory.ts b/src/entities/ProfileSalaryEmployeeHistory.ts deleted file mode 100644 index 855fcc07..00000000 --- a/src/entities/ProfileSalaryEmployeeHistory.ts +++ /dev/null @@ -1,440 +0,0 @@ -import { Entity, Column, JoinColumn, ManyToOne, Double } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { ProfileSalaryEmployee } from "./ProfileSalaryEmployee"; - -@Entity("profileSalaryEmployeeHistory") -export class ProfileSalaryEmployeeHistory extends EntityBase { - @Column({ - comment: "วันที่", - type: "datetime", - nullable: true, - }) - date: Date; - - @Column({ - comment: "เงินเดือนฐาน", - default: 0, - nullable: true, - type: "double", - }) - amount: Double; - - @Column({ - comment: "เงินประจำตำแหน่ง", - default: 0, - nullable: true, - type: "double", - }) - positionSalaryAmount: Double; - - @Column({ - comment: "เงินค่าตอบแทนรายเดือน", - default: 0, - nullable: true, - type: "double", - }) - mouthSalaryAmount: Double; - - @Column({ - length: 40, - comment: "คีย์นอก(FK)ของตาราง profile", - type: "uuid", - }) - profileId: string; - - @Column({ - comment: "สถานะการใช้งาน", - default: false, - }) - isActive: boolean; - - @Column({ - nullable: true, - comment: "ตำแหน่ง (รายละเอียด)", - type: "text", - default: null, - }) - salaryClass: string; - - @Column({ - nullable: true, - comment: "เอกสารอ้างอิง", - type: "text", - default: null, - }) - salaryRef: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id เลขที่ตำแหน่ง", - type: "uuid", - default: null, - }) - posNoId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id เลขที่ตำแหน่ง", - type: "uuid", - default: null, - }) - positionId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id สังกัด", - type: "uuid", - default: null, - }) - ocId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id ตำแหน่งทางการบริหาร", - type: "uuid", - default: null, - }) - positionExecutiveId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id ด้านทางการบริหาร", - type: "uuid", - default: null, - }) - positionExecutiveSideId: string; - - @Column({ - nullable: true, - length: 40, - comment: "", - type: "uuid", - default: null, - }) - positionLevelId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id สายงาน", - type: "uuid", - default: null, - }) - positionLineId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id ด้าน/สาขา", - type: "uuid", - default: null, - }) - positionPathSideId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id ประเภทตำแหน่ง", - type: "uuid", - default: null, - }) - positionTypeId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id ชื่อย่อหน่วยงาน", - type: "uuid", - default: null, - }) - organizationShortNameId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id กลุ่มงาน", - type: "uuid", - default: null, - }) - positionEmployeeGroupId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id ระดับชั้นงาน", - type: "uuid", - default: null, - }) - positionEmployeeLevelId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id ตำแหน่ง", - type: "uuid", - default: null, - }) - positionEmployeePositionId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id ด้านของตำแหน่ง", - type: "uuid", - default: null, - }) - positionEmployeePositionSideId: string; - - @Column({ - nullable: true, - length: 40, - comment: "Id เลขที่ตำแหน่งลูกจ้าง", - default: null, - }) - posNoEmployee: string; - - @Column({ - nullable: true, - type: "datetime", - comment: "เอกสารอ้างอิง (ลงวันที่)", - default: null, - }) - refCommandDate: Date; - - @Column({ - nullable: true, - comment: "เอกสารอ้างอิง (เลขที่คำสั่ง)", - type: "text", - default: null, - }) - refCommandNo: string; - - @Column({ - nullable: true, - comment: "ลำดับ", - default: null, - }) - order: number; - - @Column({ - comment: "เลขที่คำสั่ง", - type: "text", - }) - commandNo: string; - - @Column({ - comment: "ประเภทคำสั่ง", - type: "text", - }) - commandTypeName: string; - - @Column({ - nullable: true, - comment: "ประเภทตำแหน่งกรณีพิเศษ", - type: "text", - default: null, - }) - salaryStatus: string; - - @ManyToOne(() => ProfileSalaryEmployee, (profileSalary) => profileSalary.profileSalaryHistories) - @JoinColumn({ name: "profileSalaryId" }) - histories: ProfileSalaryEmployee; -} - -export class CreateProfileSalaryEmployeeHistory { - @Column({ - type: "datetime", - }) - date: Date; - - @Column({ - type: "double", - }) - amount: Double; - - @Column({ - type: "double", - }) - positionSalaryAmount: Double; - - @Column({ - type: "double", - }) - mouthSalaryAmount: Double; - - @Column({ - type: "uuid", - }) - profileId: string; - - // @Column() - // isActive: boolean; - - // @Column() - // salaryClass: string | null; - - // @Column() - // salaryRef: string | null; - - // @Column("uuid") - // posNoId: string | null; - - // @Column("uuid") - // positionId: string | null; - - // @Column("uuid") - // ocId: string | null; - - // @Column("uuid") - // positionExecutiveId : string | null; - - // @Column("uuid") - // positionExecutiveSideId : string | null; - - // @Column("uuid") - // positionLevelId : string | null; - - // @Column("uuid") - // positionLineId : string | null; - - // @Column("uuid") - // positionPathSideId : string | null; - - // @Column("uuid") - // positionTypeId : string | null; - - // @Column("uuid") - // organizationShortNameId : string | null; - - // @Column("uuid") - // positionEmployeeGroupId : string | null; - - // @Column("uuid") - // positionEmployeeLevelId : string | null; - - // @Column("uuid") - // positionEmployeePositionId : string | null; - - // @Column("uuid") - // positionEmployeePositionSideId : string | null; - - // @Column() - // posNoEmployee : string | null; - - // @Column() - // refCommandDate: Date | null; - - // @Column() - // refCommandNo: string | null; - - // @Column() - // order: number | null; - - // @Column() - // commandNo: string; - - // @Column() - // commandTypeName: string; - - // @Column() - // salaryStatus: string | null; -} - -export class UpdateProfileSalaryEmployeeHistory { - @Column({ - type: "datetime", - }) - date: Date; - - @Column({ - type: "double", - }) - amount: Double; - - @Column({ - type: "double", - }) - positionSalaryAmount: Double; - - @Column({ - type: "double", - }) - mouthSalaryAmount: Double; - - // @Column() - // isActive: boolean; - - // @Column() - // salaryClass: string | null; - - // @Column() - // salaryRef: string | null; - - // @Column("uuid") - // posNoId: string | null; - - // @Column("uuid") - // positionId: string | null; - - // @Column("uuid") - // ocId: string | null; - - // @Column("uuid") - // positionExecutiveId : string | null; - - // @Column("uuid") - // positionExecutiveSideId : string | null; - - // @Column("uuid") - // positionLevelId : string | null; - - // @Column("uuid") - // positionLineId : string | null; - - // @Column("uuid") - // positionPathSideId : string | null; - - // @Column("uuid") - // positionTypeId : string | null; - - // @Column("uuid") - // organizationShortNameId : string | null; - - // @Column("uuid") - // positionEmployeeGroupId : string | null; - - // @Column("uuid") - // positionEmployeeLevelId : string | null; - - // @Column("uuid") - // positionEmployeePositionId : string | null; - - // @Column("uuid") - // positionEmployeePositionSideId : string | null; - - // @Column() - // posNoEmployee : string | null; - - // @Column() - // refCommandDate: Date | null; - - // @Column() - // refCommandNo: string | null; - - // @Column() - // order: number | null; - - // @Column() - // commandNo: string; - - // @Column() - // commandTypeName: string; - - // @Column() - // salaryStatus: string | null; -} From d26337caf345518cf52d72402a6185429de303c4 Mon Sep 17 00:00:00 2001 From: AnandaTon Date: Thu, 16 May 2024 15:16:00 +0700 Subject: [PATCH 11/11] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=8A?= =?UTF-8?q?=E0=B8=B7=E0=B9=88=E0=B8=AD=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileSalaryEmployeeController.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/controllers/ProfileSalaryEmployeeController.ts b/src/controllers/ProfileSalaryEmployeeController.ts index 890bc7a8..fe23df2b 100644 --- a/src/controllers/ProfileSalaryEmployeeController.ts +++ b/src/controllers/ProfileSalaryEmployeeController.ts @@ -35,7 +35,7 @@ export class ProfileSalaryEmployeeController extends Controller { private salaryHistoryRepo = AppDataSource.getRepository(ProfileSalaryHistory); @Get("{profileId}") - public async getSalary(@Path() profileId: string) { + public async getSalaryEmployee(@Path() profileId: string) { const record = await this.salaryRepo.find({ where: { profileEmployeeId: profileId }, order: { order: "ASC" }, @@ -52,7 +52,7 @@ export class ProfileSalaryEmployeeController extends Controller { } @Post() - public async newSalary( + public async newSalaryEmployee( @Request() req: RequestWithUser, @Body() body: CreateProfileSalaryEmployee, ) { @@ -89,7 +89,7 @@ export class ProfileSalaryEmployeeController extends Controller { } @Patch("{salaryId}") - public async editSalary( + public async editSalaryEmployee( @Request() req: RequestWithUser, @Body() body: UpdateProfileSalaryEmployee, @Path() salaryId: string, @@ -112,7 +112,7 @@ export class ProfileSalaryEmployeeController extends Controller { } @Delete("{salaryId}") - public async deleteSalary(@Path() salaryId: string) { + public async deleteSalaryEmployee(@Path() salaryId: string) { await this.salaryHistoryRepo.delete({ profileSalaryId: salaryId, }); @@ -127,7 +127,7 @@ export class ProfileSalaryEmployeeController extends Controller { } @Get("swap/{direction}/{salaryId}") - public async swapSalary(@Path() direction: string, salaryId: string) { + public async swapSalaryEmployee(@Path() direction: string, salaryId: string) { const source_item = await this.salaryRepo.findOne({ where: { id: salaryId } }); if (source_item == null) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); const sourceOrder = source_item.order;