diff --git a/src/controllers/ProfileAvatarController.ts b/src/controllers/ProfileAvatarController.ts index d68815a6..8e920d4a 100644 --- a/src/controllers/ProfileAvatarController.ts +++ b/src/controllers/ProfileAvatarController.ts @@ -36,6 +36,18 @@ export class ProfileAvatarController extends Controller { return new HttpSuccess(profile); } + @Get("profileId-admin/{id}") + async getProfileAdmin(@Path() id: string) { + const profile = await this.profileRepository.findOne({ + select: ["id", "avatar", "avatarName"], + where: { id }, + }); + + if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + + return new HttpSuccess(profile); + } + @Get("select/{profileId}/{id}") public async selectAvatar(@Path() profileId: string, @Path() id: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); diff --git a/src/controllers/ProfileAvatarEmployeeController.ts b/src/controllers/ProfileAvatarEmployeeController.ts index 5b1cb79f..0cf55d70 100644 --- a/src/controllers/ProfileAvatarEmployeeController.ts +++ b/src/controllers/ProfileAvatarEmployeeController.ts @@ -26,6 +26,31 @@ export class ProfileAvatarEmployeeController extends Controller { return new HttpSuccess(lists); } + @Get("profileEmployeeId/{id}") + async getProfile(@Path() id: string, @Request() req: RequestWithUser) { + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id); + const profile = await this.profileRepository.findOne({ + select: ["id", "avatar", "avatarName"], + where: { id }, + }); + + if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + + return new HttpSuccess(profile); + } + + @Get("profileEmployeeId-admin/{id}") + async getProfileAdmin(@Path() id: string) { + const profile = await this.profileRepository.findOne({ + select: ["id", "avatar", "avatarName"], + where: { id }, + }); + + if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + + return new HttpSuccess(profile); + } + @Get("select/{profileEmployeeId}/{id}") public async selectAvatarEmployee( @Path() profileEmployeeId: string, diff --git a/src/controllers/ProfileAvatarEmployeeTempController.ts b/src/controllers/ProfileAvatarEmployeeTempController.ts index ad2cbd58..336e51cc 100644 --- a/src/controllers/ProfileAvatarEmployeeTempController.ts +++ b/src/controllers/ProfileAvatarEmployeeTempController.ts @@ -26,6 +26,31 @@ export class ProfileAvatarEmployeeTempController extends Controller { return new HttpSuccess(lists); } + @Get("profileEmployeeId/{id}") + async getProfile(@Path() id: string, @Request() req: RequestWithUser) { + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_TEMP", id); + const profile = await this.profileRepository.findOne({ + select: ["id", "avatar", "avatarName"], + where: { id }, + }); + + if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + + return new HttpSuccess(profile); + } + + @Get("profileEmployeeId-admin/{id}") + async getProfileAdmin(@Path() id: string) { + const profile = await this.profileRepository.findOne({ + select: ["id", "avatar", "avatarName"], + where: { id }, + }); + + if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + + return new HttpSuccess(profile); + } + @Get("select/{profileEmployeeId}/{id}") public async selectAvatarEmployee( @Path() profileEmployeeId: string, diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 539e7bb3..46619129 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -2486,6 +2486,21 @@ export class ProfileController extends Controller { return new HttpSuccess(profile); } + @Get("admin/{id}") + async getProfileAdmin(@Path() id: string) { + const profile = await this.profileRepo.findOne({ + relations: { + posLevel: true, + posType: true, + }, + where: { id }, + }); + + if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + + return new HttpSuccess(profile); + } + // @Get("keycloak/{id}") // async getProfileByKeycloakId(@Path() id: string) { // const profile = await this.profileRepo.findOne({ diff --git a/src/controllers/ProfileDisciplineController.ts b/src/controllers/ProfileDisciplineController.ts index c02abb69..12e0ac32 100644 --- a/src/controllers/ProfileDisciplineController.ts +++ b/src/controllers/ProfileDisciplineController.ts @@ -76,6 +76,26 @@ export class ProfileDisciplineController extends Controller { return new HttpSuccess(lists); } + @Get("admin/{profileId}") + public async getDisciplineAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { + await new permission().PermissionGet(req, "SYS_SALARY_OFFICER"); + const lists = await this.disciplineRepository.find({ + where: { profileId: profileId }, + select: [ + "id", + "date", + "level", + "detail", + "unStigma", + "refCommandNo", + "refCommandDate", + "lastUpdateFullName", + "lastUpdatedAt", + ], + }); + return new HttpSuccess(lists); + } + @Get("history/{disciplineId}") @Example({ status: 200, diff --git a/src/controllers/ProfileDisciplineEmployeeController.ts b/src/controllers/ProfileDisciplineEmployeeController.ts index cfc4e820..9c05aee5 100644 --- a/src/controllers/ProfileDisciplineEmployeeController.ts +++ b/src/controllers/ProfileDisciplineEmployeeController.ts @@ -91,6 +91,26 @@ export class ProfileDisciplineEmployeeController extends Controller { return new HttpSuccess(lists); } + @Get("admin/{profileId}") + public async getDisciplineAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { + await new permission().PermissionGet(req, "SYS_WAGE"); + const lists = await this.disciplineRepository.find({ + where: { profileEmployeeId: profileId }, + select: [ + "id", + "date", + "level", + "detail", + "unStigma", + "refCommandNo", + "refCommandDate", + "lastUpdateFullName", + "lastUpdatedAt", + ], + }); + return new HttpSuccess(lists); + } + @Get("history/{disciplineId}") public async disciplineHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) { const _record = await this.disciplineRepository.findOneBy({ id: disciplineId }); diff --git a/src/controllers/ProfileDisciplineEmployeeTempController.ts b/src/controllers/ProfileDisciplineEmployeeTempController.ts index 63c0987a..93c7e2dc 100644 --- a/src/controllers/ProfileDisciplineEmployeeTempController.ts +++ b/src/controllers/ProfileDisciplineEmployeeTempController.ts @@ -91,6 +91,26 @@ export class ProfileDisciplineEmployeeTempController extends Controller { return new HttpSuccess(lists); } + @Get("admin/{profileId}") + public async getDisciplineAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { + await new permission().PermissionGet(req, "SYS_WAGE"); + const lists = await this.disciplineRepository.find({ + where: { profileEmployeeId: profileId }, + select: [ + "id", + "date", + "level", + "detail", + "unStigma", + "refCommandNo", + "refCommandDate", + "lastUpdateFullName", + "lastUpdatedAt", + ], + }); + return new HttpSuccess(lists); + } + @Get("history/{disciplineId}") public async disciplineHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) { await new permission().PermissionList(req, "SYS_REGISTRY_TEMP"); diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 5178ed91..d6dcc71c 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -1076,6 +1076,21 @@ export class ProfileEmployeeController extends Controller { return new HttpSuccess(profile); } + @Get("admin/{id}") + async detailProfileAdmin(@Path() id: string) { + const profile = await this.profileRepo.findOne({ + relations: { + posLevel: true, + posType: true, + }, + where: { id }, + }); + + if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + + return new HttpSuccess(profile); + } + /** * API รายการทะเบียนประวัติ * diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index c126a2d0..cff7ce54 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -1073,6 +1073,21 @@ export class ProfileEmployeeTempController extends Controller { return new HttpSuccess(profile); } + @Get("admin/{id}") + async detailProfileAdmin(@Path() id: string) { + const profile = await this.profileRepo.findOne({ + relations: { + posLevel: true, + posType: true, + }, + where: { id }, + }); + + if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + + return new HttpSuccess(profile); + } + /** * API รายการทะเบียนประวัติ * diff --git a/src/controllers/ProfileGovernmentController.ts b/src/controllers/ProfileGovernmentController.ts index f3352330..7652215f 100644 --- a/src/controllers/ProfileGovernmentController.ts +++ b/src/controllers/ProfileGovernmentController.ts @@ -238,6 +238,99 @@ export class ProfileGovernmentHistoryController extends Controller { return new HttpSuccess(data); } + @Get("admin/{profileId}") + public async getGovHistoryAdmin(@Path() profileId: string) { + const orgRevision = await this.orgRevisionRepository.findOne({ + select: ["id"], + where: { + orgRevisionIsDraft: false, + orgRevisionIsCurrent: true, + }, + }); + const record = await this.profileRepo.findOne({ + where: { id: profileId }, + relations: { + posType: true, + posLevel: true, + }, + }); + const posMaster = await this.posMasterRepo.findOne({ + where: { + orgRevisionId: orgRevision?.id, + current_holderId: profileId, + }, + order: { createdAt: "DESC" }, + relations: { + orgRoot: true, + orgChild1: true, + orgChild2: true, + orgChild3: true, + orgChild4: true, + }, + }); + const position = await this.positionRepo.findOne({ + where: { + positionIsSelected: true, + posMaster: { + orgRevisionId: orgRevision?.id, + current_holderId: profileId, + }, + }, + order: { createdAt: "DESC" }, + relations: { + posExecutive: true, + }, + }); + + if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + const fullNameParts = [ + posMaster == null || posMaster.orgChild4 == null ? null : posMaster.orgChild4.orgChild4Name, + posMaster == null || posMaster.orgChild3 == null ? null : posMaster.orgChild3.orgChild3Name, + posMaster == null || posMaster.orgChild2 == null ? null : posMaster.orgChild2.orgChild2Name, + posMaster == null || posMaster.orgChild1 == null ? null : posMaster.orgChild1.orgChild1Name, + posMaster == null || posMaster.orgRoot == null ? null : posMaster.orgRoot.orgRootName, + ]; + const org = fullNameParts.filter((part) => part !== undefined && part !== null).join("/"); + let orgShortName = ""; + if (posMaster != null) { + if (posMaster.orgChild1Id === null) { + orgShortName = posMaster.orgRoot?.orgRootShortName; + } else if (posMaster.orgChild2Id === null) { + orgShortName = posMaster.orgChild1?.orgChild1ShortName; + } else if (posMaster.orgChild3Id === null) { + orgShortName = posMaster.orgChild2?.orgChild2ShortName; + } else if (posMaster.orgChild4Id === null) { + orgShortName = posMaster.orgChild3?.orgChild3ShortName; + } else { + orgShortName = posMaster.orgChild4?.orgChild4ShortName; + } + } + const data = { + org: org, //สังกัด + positionField: position == null ? null : position.positionField, //สายงาน + position: record.position, //ตำแหน่ง + posLevel: record.posLevel == null ? null : record.posLevel.posLevelName, //ระดับ + posMasterNo: posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`, //เลขที่ตำแหน่ง + posType: record.posType == null ? null : record.posType.posTypeName, //ประเภท + posExecutive: + position == null || position.posExecutive == null + ? null + : position.posExecutive.posExecutiveName, //ตำแหน่งทางการบริหาร + positionArea: position == null ? null : position.positionArea, //ด้าน/สาขา + positionExecutiveField: position == null ? null : position.positionExecutiveField, //ด้านทางการบริหาร + dateLeave: record.birthDate == null ? null : calculateRetireDate(record.birthDate), + dateRetireLaw: record.dateRetireLaw ?? null, + govAge: record.dateStart == null ? null : calculateAge(record.dateStart), + dateAppoint: record.dateAppoint, + dateStart: record.dateStart, + govAgeAbsent: record.govAgeAbsent, + govAgePlus: record.govAgePlus, + reasonSameDate: record.reasonSameDate, + }; + + return new HttpSuccess(data); + } + /** * * @summary ประวัติข้อมูลราชการ by keycloak diff --git a/src/controllers/ProfileGovernmentEmployeeController.ts b/src/controllers/ProfileGovernmentEmployeeController.ts index 94be34bd..9b2f62f2 100644 --- a/src/controllers/ProfileGovernmentEmployeeController.ts +++ b/src/controllers/ProfileGovernmentEmployeeController.ts @@ -234,6 +234,89 @@ export class ProfileGovernmentEmployeeController extends Controller { return new HttpSuccess(data); } + @Get("admin/{profileEmployeeId}") + public async getGovHistoryAdmin(@Path() profileEmployeeId: string) { + const orgRevision = await this.orgRevisionRepository.findOne({ + select: ["id"], + where: { + orgRevisionIsDraft: false, + orgRevisionIsCurrent: true, + }, + }); + const record = await this.profileEmployeeRepo.findOne({ + where: { id: profileEmployeeId }, + relations: { + posType: true, + posLevel: true, + }, + }); + const posMaster = await this.posMasterRepo.findOne({ + where: { + orgRevisionId: orgRevision?.id, + current_holderId: profileEmployeeId, + }, + order: { createdAt: "DESC" }, + relations: { + orgRoot: true, + orgChild1: true, + orgChild2: true, + orgChild3: true, + orgChild4: true, + }, + }); + const position = await this.positionRepo.findOne({ + where: { + positionIsSelected: true, + posMaster: { + orgRevisionId: orgRevision?.id, + current_holderId: profileEmployeeId, + }, + }, + order: { createdAt: "DESC" }, + }); + + if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + const fullNameParts = [ + posMaster == null || posMaster.orgChild4 == null ? null : posMaster.orgChild4.orgChild4Name, + posMaster == null || posMaster.orgChild3 == null ? null : posMaster.orgChild3.orgChild3Name, + posMaster == null || posMaster.orgChild2 == null ? null : posMaster.orgChild2.orgChild2Name, + posMaster == null || posMaster.orgChild1 == null ? null : posMaster.orgChild1.orgChild1Name, + posMaster == null || posMaster.orgRoot == null ? null : posMaster.orgRoot.orgRootName, + ]; + const org = fullNameParts.filter((part) => part !== undefined && part !== null).join("/"); + let orgShortName = ""; + if (posMaster != null) { + if (posMaster.orgChild1Id === null) { + orgShortName = posMaster.orgRoot?.orgRootShortName; + } else if (posMaster.orgChild2Id === null) { + orgShortName = posMaster.orgChild1?.orgChild1ShortName; + } else if (posMaster.orgChild3Id === null) { + orgShortName = posMaster.orgChild2?.orgChild2ShortName; + } else if (posMaster.orgChild4Id === null) { + orgShortName = posMaster.orgChild3?.orgChild3ShortName; + } else { + orgShortName = posMaster.orgChild4?.orgChild4ShortName; + } + } + const data = { + org: org, //สังกัด + position: record.position, //ตำแหน่ง + posLevel: record.posLevel == null ? null : record.posLevel.posLevelName, //ระดับ + posMasterNo: posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`, //เลขที่ตำแหน่ง + posType: record.posType == null ? null : record.posType.posTypeName, //ประเภท + dateLeave: record.birthDate == null ? null : calculateRetireDate(record.birthDate), //วันเกษียณ + dateAppoint: record.dateAppoint, //วันที่สั่งบรรจุ + dateStart: record.dateStart, //วันที่เริ่มปฎิบัติงานราชการ + reasonSameDate: record.reasonSameDate, //เหตุผลที่วันที่ไม่ตรงกัน + dateRetire: record.dateRetire ?? null, //วันครบเกษียณอายุ + govAge: record.dateStart == null ? null : calculateAge(record.dateStart), //อายุราชการ + govAgeAbsent: record.govAgeAbsent ?? null, // ขาดราชการ + govAgePlus: record.govAgePlus, // อายุราชการเกื้อกูล + dateRetireLaw: record.dateRetireLaw ?? null, // วันที่เกษียฯอายุราชการตามกฎหมาย + }; + return new HttpSuccess(data); + } + /** * * @summary ประวัติข้อมูลราชการ by keycloak diff --git a/src/controllers/ProfileGovernmentEmployeeTempController.ts b/src/controllers/ProfileGovernmentEmployeeTempController.ts index 37621125..abab93ab 100644 --- a/src/controllers/ProfileGovernmentEmployeeTempController.ts +++ b/src/controllers/ProfileGovernmentEmployeeTempController.ts @@ -234,6 +234,90 @@ export class ProfileGovernmentEmployeeTempController extends Controller { return new HttpSuccess(data); } + @Get("admin/{profileEmployeeId}") + @Example({}) + public async getGovHistoryAdmin(@Path() profileEmployeeId: string) { + const orgRevision = await this.orgRevisionRepository.findOne({ + select: ["id"], + where: { + orgRevisionIsDraft: false, + orgRevisionIsCurrent: true, + }, + }); + const record = await this.profileEmployeeRepo.findOne({ + where: { id: profileEmployeeId }, + relations: { + posType: true, + posLevel: true, + }, + }); + const posMaster = await this.posMasterRepo.findOne({ + where: { + orgRevisionId: orgRevision?.id, + current_holderId: profileEmployeeId, + }, + order: { createdAt: "DESC" }, + relations: { + orgRoot: true, + orgChild1: true, + orgChild2: true, + orgChild3: true, + orgChild4: true, + }, + }); + const position = await this.positionRepo.findOne({ + where: { + positionIsSelected: true, + posMaster: { + orgRevisionId: orgRevision?.id, + current_holderId: profileEmployeeId, + }, + }, + order: { createdAt: "DESC" }, + }); + + if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + const fullNameParts = [ + posMaster == null || posMaster.orgChild4 == null ? null : posMaster.orgChild4.orgChild4Name, + posMaster == null || posMaster.orgChild3 == null ? null : posMaster.orgChild3.orgChild3Name, + posMaster == null || posMaster.orgChild2 == null ? null : posMaster.orgChild2.orgChild2Name, + posMaster == null || posMaster.orgChild1 == null ? null : posMaster.orgChild1.orgChild1Name, + posMaster == null || posMaster.orgRoot == null ? null : posMaster.orgRoot.orgRootName, + ]; + const org = fullNameParts.filter((part) => part !== undefined && part !== null).join("/"); + let orgShortName = ""; + if (posMaster != null) { + if (posMaster.orgChild1Id === null) { + orgShortName = posMaster.orgRoot?.orgRootShortName; + } else if (posMaster.orgChild2Id === null) { + orgShortName = posMaster.orgChild1?.orgChild1ShortName; + } else if (posMaster.orgChild3Id === null) { + orgShortName = posMaster.orgChild2?.orgChild2ShortName; + } else if (posMaster.orgChild4Id === null) { + orgShortName = posMaster.orgChild3?.orgChild3ShortName; + } else { + orgShortName = posMaster.orgChild4?.orgChild4ShortName; + } + } + const data = { + org: org, //สังกัด + position: record.position, //ตำแหน่ง + posLevel: record.posLevel == null ? null : record.posLevel.posLevelName, //ระดับ + posMasterNo: posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`, //เลขที่ตำแหน่ง + posType: record.posType == null ? null : record.posType.posTypeName, //ประเภท + dateLeave: record.birthDate == null ? null : calculateRetireDate(record.birthDate), //วันเกษียณ + dateAppoint: record.dateAppoint, //วันที่สั่งบรรจุ + dateStart: record.dateStart, //วันที่เริ่มปฎิบัติงานราชการ + reasonSameDate: record.reasonSameDate, //เหตุผลที่วันที่ไม่ตรงกัน + dateRetire: record.dateRetire ?? null, //วันครบเกษียณอายุ + govAge: record.dateStart == null ? null : calculateAge(record.dateStart), //อายุราชการ + govAgeAbsent: record.govAgeAbsent ?? null, // ขาดราชการ + govAgePlus: record.govAgePlus, // อายุราชการเกื้อกูล + dateRetireLaw: record.dateRetireLaw ?? null, // วันที่เกษียฯอายุราชการตามกฎหมาย + }; + return new HttpSuccess(data); + } + /** * * @summary ประวัติข้อมูลราชการ by keycloak diff --git a/src/controllers/ProfileLeaveController.ts b/src/controllers/ProfileLeaveController.ts index 3dcc6786..2af5f571 100644 --- a/src/controllers/ProfileLeaveController.ts +++ b/src/controllers/ProfileLeaveController.ts @@ -169,6 +169,16 @@ export class ProfileLeaveController extends Controller { return new HttpSuccess(record); } + @Get("admin/{profileId}") + public async getLeaveAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { + await new permission().PermissionGet(req, "SYS_SALARY_OFFICER"); + const record = await this.leaveRepo.find({ + relations: { leaveType: true }, + where: { profileId }, + }); + return new HttpSuccess(record); + } + @Get("history/{leaveId}") @Example({ status: 200, diff --git a/src/controllers/ProfileLeaveEmployeeController.ts b/src/controllers/ProfileLeaveEmployeeController.ts index 9064de06..e06f85ca 100644 --- a/src/controllers/ProfileLeaveEmployeeController.ts +++ b/src/controllers/ProfileLeaveEmployeeController.ts @@ -58,6 +58,16 @@ export class ProfileLeaveEmployeeController extends Controller { return new HttpSuccess(record); } + @Get("admin/{profileId}") + public async getLeaveAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { + await new permission().PermissionGet(req, "SYS_WAGE"); + const record = await this.leaveRepo.find({ + relations: { leaveType: true }, + where: { profileEmployeeId: profileId }, + }); + return new HttpSuccess(record); + } + @Get("history/{leaveId}") public async leaveHistory(@Path() leaveId: string, @Request() req: RequestWithUser) { const _record = await this.leaveRepo.findOneBy({ id: leaveId }); diff --git a/src/controllers/ProfileLeaveEmployeeTempController.ts b/src/controllers/ProfileLeaveEmployeeTempController.ts index 5e6002d1..aa413297 100644 --- a/src/controllers/ProfileLeaveEmployeeTempController.ts +++ b/src/controllers/ProfileLeaveEmployeeTempController.ts @@ -58,9 +58,19 @@ export class ProfileLeaveEmployeeTempController extends Controller { return new HttpSuccess(record); } + @Get("admin/{profileId}") + public async getLeaveAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { + await new permission().PermissionGet(req, "SYS_WAGE"); + const record = await this.leaveRepo.find({ + relations: { leaveType: true }, + where: { profileEmployeeId: profileId }, + }); + return new HttpSuccess(record); + } + @Get("history/{leaveId}") public async leaveHistory(@Path() leaveId: string, @Request() req: RequestWithUser) { - await new permission().PermissionList(req, "SYS_REGISTRY_TEMP"); + await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.leaveHistoryRepo.find({ relations: { leaveType: true }, where: { profileLeaveId: leaveId }, diff --git a/src/controllers/ProfileSalaryController.ts b/src/controllers/ProfileSalaryController.ts index 71891513..0efda698 100644 --- a/src/controllers/ProfileSalaryController.ts +++ b/src/controllers/ProfileSalaryController.ts @@ -81,6 +81,16 @@ export class ProfileSalaryController extends Controller { return new HttpSuccess(record); } + @Get("admin/{profileId}") + public async getSalaryAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { + await new permission().PermissionGet(req, "SYS_SALARY_OFFICER"); + const record = await this.salaryRepo.find({ + where: { profileId: profileId }, + order: { order: "ASC" }, + }); + return new HttpSuccess(record); + } + @Get("history/{salaryId}") @Example({ status: 200, diff --git a/src/controllers/ProfileSalaryEmployeeController.ts b/src/controllers/ProfileSalaryEmployeeController.ts index fdb3aa2f..b86d5563 100644 --- a/src/controllers/ProfileSalaryEmployeeController.ts +++ b/src/controllers/ProfileSalaryEmployeeController.ts @@ -49,10 +49,24 @@ export class ProfileSalaryEmployeeController extends Controller { @Get("{profileId}") public async getSalaryEmployee(@Path() profileId: string, @Request() req: RequestWithUser) { - const _record = await this.salaryRepo.findOneBy({ id: profileId }); - if (_record) { + // const _record = await this.salaryRepo.findOneBy({ id: profileId }); + // if (_record) { await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileId); - } + // } + const record = await this.salaryRepo.find({ + where: { profileEmployeeId: profileId }, + order: { order: "ASC" }, + }); + return new HttpSuccess(record); + } + + @Get("admin/{profileId}") + public async getSalaryEmployeeAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { + await new permission().PermissionGet(req, "SYS_WAGE"); + // const _record = await this.salaryRepo.findOneBy({ id: profileId }); + // if (_record) { + // await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileId); + // } const record = await this.salaryRepo.find({ where: { profileEmployeeId: profileId }, order: { order: "ASC" }, diff --git a/src/controllers/ProfileSalaryEmployeeTempController.ts b/src/controllers/ProfileSalaryEmployeeTempController.ts index e494f7ca..8f4be048 100644 --- a/src/controllers/ProfileSalaryEmployeeTempController.ts +++ b/src/controllers/ProfileSalaryEmployeeTempController.ts @@ -49,7 +49,17 @@ export class ProfileSalaryEmployeeTempController extends Controller { @Get("{profileId}") public async getSalaryEmployee(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionList(req, "SYS_REGISTRY_TEMP"); + await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + const record = await this.salaryRepo.find({ + where: { profileEmployeeId: profileId }, + order: { order: "ASC" }, + }); + return new HttpSuccess(record); + } + + @Get("admin/{profileId}") + public async getSalaryEmployeeAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { + await new permission().PermissionGet(req, "SYS_WAGE"); const record = await this.salaryRepo.find({ where: { profileEmployeeId: profileId }, order: { order: "ASC" },