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; }[]; }, ) { diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index bc059af6..09d81ccf 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,43 @@ export class ProfileController extends Controller { ]); return new HttpSuccess(); } + + @Post("noti-admin") + public async notiAllAdmin( + @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(); + } } 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;