From bfe281f3f30704d11160148d08bf46a5e357d4b0 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 10 Jul 2024 10:43:56 +0700 Subject: [PATCH] no message --- src/controllers/ProfileController.ts | 51 +++++++++++++++++++++++++--- src/entities/ProfileSalary.ts | 9 +++++ 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index bfddaa4d..aa40305c 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -4837,6 +4837,47 @@ export class ProfileController extends Controller { return new HttpSuccess({ data: mapDataProfile, total }); } + /** + * API ค้นหาข้อมูลทะเบียนประวัติที่เกี่ยวข้องคำสั่ง + * + * @summary ค้นหาข้อมูลทะเบียนประวัติที่เกี่ยวข้องคำสั่ง + * + */ + @Post("search/profile/command") + async searchProfileBycommand( + @Query("page") page: number = 1, + @Query("pageSize") pageSize: number = 10, + @Body() + body: { + commandType: string; + posno: string; + year: number; + }, + ) { + const [profiles, total] = await this.profileRepo + .createQueryBuilder("profile") + .leftJoinAndSelect("profile.profileSalary", "profileSalary") + // .where("YEAR(profileSalary.date) = :year", { year: body.year }) + // .where("profileSalary.refCommandNo LIKE :refCommandNo", { + // refCommandNo: `%${body.posno}%`, + // }) + // .andWhere("profileSalary.commandType LIKE :commandType", { + // commandType: `${body.commandType}`, + // }) + .skip((page - 1) * pageSize) + .take(pageSize) + .distinct(true) // Ensure unique profiles + .getManyAndCount(); + const _profiles = profiles.map((_data) => ({ + id: _data.id, + fullName: `${_data.prefix}${_data.firstName} ${_data.lastName}`, + citizenId: _data.citizenId, + posNo: _data.profileSalary.filter((x) => x.id != null)[0].refCommandNo, + position: _data.profileSalary.filter((x) => x.id != null)[0].position, + })); + + return new HttpSuccess({ data: _profiles, total }); + } /** * * @summary ปรับคนเป็นทดลองงาน (ADMIN) @@ -5023,7 +5064,7 @@ export class ProfileController extends Controller { * @summary (ADMIN) * */ - @Get("salarym/ock") + @Get("gensalary/latest") async calSalaryDate() { const profile = await this.profileRepo.find(); const _null: any = null; @@ -5054,15 +5095,15 @@ export class ProfileController extends Controller { }), ); await this.profileRepo.save(profiles); - return new HttpSuccess("zxczx"); + return new HttpSuccess(); } /** * * @summary (ADMIN) * */ - @Get("salarym/zxczxcsa") - async zxczxczxczxczxc() { + @Get("deleteprofile/all") + async deleteHistoryLatest() { const [profile, total] = await this.profileRepo .createQueryBuilder("profile") .leftJoinAndSelect("profile.current_holders", "current_holders") @@ -5096,6 +5137,6 @@ export class ProfileController extends Controller { } }), ); - return new HttpSuccess("zxczx"); + return new HttpSuccess(); } } diff --git a/src/entities/ProfileSalary.ts b/src/entities/ProfileSalary.ts index a6261eee..8f42db8f 100644 --- a/src/entities/ProfileSalary.ts +++ b/src/entities/ProfileSalary.ts @@ -119,6 +119,14 @@ export class ProfileSalary extends EntityBase { }) mouthSalaryAmount: Double; + // @Column({ + // nullable: true, + // comment: "ประเภทคำสั่ง", + // type: "text", + // default: null, + // }) + // commandType: string; + @Column({ nullable: true, comment: "เลขที่คำสั่ง", @@ -168,6 +176,7 @@ export class CreateProfileSalary { positionType: string | null; positionLevel: string | null; refCommandNo: string | null; + commandType?: string | null; templateDoc: string | null; }