From 5f947d492485e1dafa2e589e3420a03dc49eaf5b Mon Sep 17 00:00:00 2001 From: kittapath Date: Tue, 12 Nov 2024 13:38:07 +0700 Subject: [PATCH 1/4] no message --- src/entities/ProfileLeave.ts | 6 +++--- src/entities/ProfileSalary.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/entities/ProfileLeave.ts b/src/entities/ProfileLeave.ts index 666156d0..b3884f2f 100644 --- a/src/entities/ProfileLeave.ts +++ b/src/entities/ProfileLeave.ts @@ -120,9 +120,9 @@ export class CreateProfileLeave { dateLeaveStart: Date | null; dateLeaveEnd: Date | null; leaveDays: number | null; - leaveCount: number | null; - totalLeave: number | null; - status: string | null; + leaveCount?: number | null; + totalLeave?: number | null; + status?: string | null; reason: string | null; } diff --git a/src/entities/ProfileSalary.ts b/src/entities/ProfileSalary.ts index 8931826a..c3e6adc7 100644 --- a/src/entities/ProfileSalary.ts +++ b/src/entities/ProfileSalary.ts @@ -194,7 +194,7 @@ export class CreateProfileSalary { positionType: string | null; positionLevel: string | null; refCommandNo: string | null; - commandId: string | null; + commandId?: string | null; // commandType?: string | null; templateDoc: string | null; isGovernment?: boolean | null; @@ -204,7 +204,7 @@ export class CreateProfileSalaryEmployee { profileEmployeeId: string | null; date?: Date | null; amount?: Double | null; - commandId: string | null; + commandId?: string | null; positionSalaryAmount?: Double | null; mouthSalaryAmount?: Double | null; posNo: string | null; From 0f757f10e73546a7e910ae2e0140f66b222d8c4f Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 12 Nov 2024 14:09:20 +0700 Subject: [PATCH 2/4] fix issue #708 --- src/controllers/CommandController.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index cb1e97c6..cde51643 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -3451,6 +3451,7 @@ export class CommandController extends Controller { posMasterId: posMaster.id, positionIsSelected: true, }, + relations: ["posType", "posLevel"] }); const dest_item = await this.salaryRepo.findOne({ where: { profileId: profile?.id }, @@ -3468,8 +3469,8 @@ export class CommandController extends Controller { mouthSalaryAmount: item.mouthSalaryAmount, posNo: shortName ?? null, position: position?.positionName ?? null, - positionType: position?.posTypeId ?? null, - positionLevel: position?.posLevelId ?? null, + positionType: position?.posType.posTypeName ?? null, + positionLevel: position?.posLevel.posLevelName ?? null, refCommandNo: `${item.commandNo}/${Extension.ToThaiYear(item.commandYear)}`, templateDoc: item.templateDoc, order: dest_item == null ? 1 : dest_item.order + 1, @@ -3521,13 +3522,13 @@ export class CommandController extends Controller { body: { refIds: { refId: string; - commandAffectDate: Date | null; - commandNo: string | null; - commandYear: number; - templateDoc: string | null; - amount: Double | null; - positionSalaryAmount: Double | null; - mouthSalaryAmount: Double | null; + // commandAffectDate: Date | null; + // commandNo: string | null; + // commandYear: number; + // templateDoc: string | null; + // amount: Double | null; + // positionSalaryAmount: Double | null; + // mouthSalaryAmount: Double | null; }[]; }, ) { From 8d5b125dd0f9aff61ac7a544336c888c413e7bdb Mon Sep 17 00:00:00 2001 From: kittapath Date: Tue, 12 Nov 2024 16:51:06 +0700 Subject: [PATCH 3/4] noti admin --- src/controllers/ProfileController.ts | 70 ++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 14 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index bc059af6..43d72833 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -69,6 +69,7 @@ import { ProfileFamilyMotherHistory } from "../entities/ProfileFamilyMotherHisto import { ProfileFamilyCoupleHistory } from "../entities/ProfileFamilyCoupleHistory"; import { viewDirector } from "../entities/view/viewDirector"; import { viewDirectorActing } from "../entities/view/viewDirectorActing"; +import CallAPI from "../interfaces/call-api"; @Route("api/v1/org/profile") @Tags("Profile") @Security("bearerAuth") @@ -228,20 +229,23 @@ export class ProfileController extends Controller { where: { profileId: id }, order: { lastUpdatedAt: "DESC" }, }); - const Education = educations && educations.length > 0 - ? educations.map((item) => ({ - institute: item.institute ? item.institute : "-", - date: - item.startDate && item.endDate - ? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}` - : "-", - degree: item.degree && item.field ? `${item.degree} ${item.field}` : "-", - })) - : [{ - institute: "-", - date: "-", - degree: "-", - }] + const Education = + educations && educations.length > 0 + ? educations.map((item) => ({ + institute: item.institute ? item.institute : "-", + date: + item.startDate && item.endDate + ? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}` + : "-", + degree: item.degree && item.field ? `${item.degree} ${item.field}` : "-", + })) + : [ + { + institute: "-", + date: "-", + degree: "-", + }, + ]; const mapData = { // Id: profile.id, @@ -7874,4 +7878,42 @@ export class ProfileController extends Controller { ]); return new HttpSuccess(); } + @Post("state-next") + public async stateNext( + @Request() req: RequestWithUser, + @Body() + body: { + subject: string; + body: string; + }, + ) { + if (!req.user.role.includes("SUPER_ADMIN")) + throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ส่งข้อความ"); + const profileNoti = await this.profileRepo.find({ + where: { + roleKeycloaks: { + name: "ADMIN", + }, + }, + }); + profileNoti.map((x) => ({ + receiverUserId: x.id, + notiLink: "", + })); + await new CallAPI() + .PostData(req, "/placement/noti/profiles", { + subject: body.subject, + body: body.body, + receiverUserIds: profileNoti, + payload: "", //แนบไฟล์ + isSendMail: true, + isSendInbox: true, + isSendNotification: true, + }) + .catch((error) => { + console.error("Error calling API:", error); + }); + + return new HttpSuccess(); + } } From 032420520605cb7f8826f7b5374f6a5fbbb42579 Mon Sep 17 00:00:00 2001 From: kittapath Date: Tue, 12 Nov 2024 16:51:48 +0700 Subject: [PATCH 4/4] noti all admin --- src/controllers/ProfileController.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 43d72833..09d81ccf 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -7878,8 +7878,9 @@ export class ProfileController extends Controller { ]); return new HttpSuccess(); } - @Post("state-next") - public async stateNext( + + @Post("noti-admin") + public async notiAllAdmin( @Request() req: RequestWithUser, @Body() body: {