From 4b6fd79264f4c85df9655f5f3f4f3f0f272ba2b3 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 9 Sep 2024 18:10:01 +0700 Subject: [PATCH] add parth admin history --- src/controllers/ProfileAbilityController.ts | 10 ++++----- .../ProfileAssessmentsEmployeeController.ts | 21 ++++++++++++++++-- ...rofileAssessmentsEmployeeTempController.ts | 22 +++++++++++++++++-- .../ProfileCertificateEmployeeController.ts | 15 +++++++++++-- ...rofileCertificateEmployeeTempController.ts | 15 +++++++++++-- .../ProfileDisciplineEmployeeController.ts | 13 +++++++++-- ...ProfileDisciplineEmployeeTempController.ts | 13 +++++++++-- .../ProfileDutyEmployeeController.ts | 13 +++++++++-- .../ProfileDutyEmployeeTempController.ts | 13 +++++++++-- .../ProfileEducationsEmployeeController.ts | 20 +++++++++++++++-- ...ProfileEducationsEmployeeTempController.ts | 20 +++++++++++++++-- .../ProfileHonorEmployeeController.ts | 15 +++++++++++-- .../ProfileHonorEmployeeTempController.ts | 15 +++++++++++-- .../ProfileInsigniaEmployeeController.ts | 20 +++++++++++++++-- .../ProfileInsigniaEmployeeTempController.ts | 20 +++++++++++++++-- .../ProfileLeaveEmployeeController.ts | 14 ++++++++++-- .../ProfileLeaveEmployeeTempController.ts | 14 ++++++++++-- .../ProfileOtherEmployeeController.ts | 13 +++++++++-- .../ProfileOtherEmployeeTempController.ts | 13 +++++++++-- .../ProfileSalaryEmployeeController.ts | 15 +++++++++++-- .../ProfileSalaryEmployeeTempController.ts | 15 +++++++++++-- .../ProfileTrainingEmployeeController.ts | 15 +++++++++++-- .../ProfileTrainingEmployeeTempController.ts | 15 +++++++++++-- 23 files changed, 309 insertions(+), 50 deletions(-) diff --git a/src/controllers/ProfileAbilityController.ts b/src/controllers/ProfileAbilityController.ts index 523353e5..108ab51f 100644 --- a/src/controllers/ProfileAbilityController.ts +++ b/src/controllers/ProfileAbilityController.ts @@ -66,12 +66,10 @@ export class ProfileAbilityController extends Controller { @Path() abilityId: string, @Request() req: RequestWithUser, ) { - const _record = await this.profileAbilityRepo.findOne({ - where: { id: abilityId }, - }); - if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); - } + const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId }); + if (_record) { + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + } const record = await this.profileAbilityHistoryRepo.find({ where: { profileAbilityId: abilityId }, diff --git a/src/controllers/ProfileAssessmentsEmployeeController.ts b/src/controllers/ProfileAssessmentsEmployeeController.ts index dd7b7b41..0ca9ab91 100644 --- a/src/controllers/ProfileAssessmentsEmployeeController.ts +++ b/src/controllers/ProfileAssessmentsEmployeeController.ts @@ -67,8 +67,8 @@ export class ProfileAssessmentsEmployeeController extends Controller { return new HttpSuccess(getProfileAssessments); } - @Get("history/{assessmentId}") - public async getProfileAssessmentsHistory( + @Get("admin/history/{assessmentId}") + public async getProfileAdminAssessmentsHistory( @Path() assessmentId: string, @Request() req: RequestWithUser, ) { @@ -89,6 +89,23 @@ export class ProfileAssessmentsEmployeeController extends Controller { return new HttpSuccess(record); } + @Get("history/{assessmentId}") + public async getProfileAssessmentsHistory( + @Path() assessmentId: string, + ) { + const record = await this.profileAssessmentsHistoryRepository.find({ + where: { + profileAssessmentId: assessmentId, + }, + order: { createdAt: "DESC" }, + }); + if (!record) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + } + + return new HttpSuccess(record); + } + @Post() public async profileAssessment( @Request() req: RequestWithUser, diff --git a/src/controllers/ProfileAssessmentsEmployeeTempController.ts b/src/controllers/ProfileAssessmentsEmployeeTempController.ts index ae7a834f..9d4e63c8 100644 --- a/src/controllers/ProfileAssessmentsEmployeeTempController.ts +++ b/src/controllers/ProfileAssessmentsEmployeeTempController.ts @@ -67,8 +67,8 @@ export class ProfileAssessmentsEmployeeTempController extends Controller { return new HttpSuccess(getProfileAssessments); } - @Get("history/{assessmentId}") - public async getProfileAssessmentsHistory( + @Get("admin/history/{assessmentId}") + public async getProfileAdminAssessmentsHistory( @Path() assessmentId: string, @Request() req: RequestWithUser, ) { @@ -87,6 +87,24 @@ export class ProfileAssessmentsEmployeeTempController extends Controller { return new HttpSuccess(record); } + @Get("history/{assessmentId}") + public async getProfileAssessmentsHistory( + @Path() assessmentId: string, + ) { + const record = await this.profileAssessmentsHistoryRepository.find({ + where: { + profileAssessmentId: assessmentId, + }, + order: { createdAt: "DESC" }, + }); + + if (!record) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + } + + return new HttpSuccess(record); + } + @Post() public async profileAssessment( @Request() req: RequestWithUser, diff --git a/src/controllers/ProfileCertificateEmployeeController.ts b/src/controllers/ProfileCertificateEmployeeController.ts index 3c4a2aeb..8ede9f2f 100644 --- a/src/controllers/ProfileCertificateEmployeeController.ts +++ b/src/controllers/ProfileCertificateEmployeeController.ts @@ -55,8 +55,8 @@ export class ProfileCertificateEmployeeController extends Controller { return new HttpSuccess(record); } - @Get("history/{certificateId}") - public async certificateHistory(@Path() certificateId: string, @Request() req: RequestWithUser) { + @Get("admin/history/{certificateId}") + public async certificateAdminHistory(@Path() certificateId: string, @Request() req: RequestWithUser) { const _record = await this.certificateRepo.findOneBy({ id: certificateId }); if (_record) { await new permission().PermissionOrgUserGet( @@ -73,6 +73,17 @@ export class ProfileCertificateEmployeeController extends Controller { }); return new HttpSuccess(record); } + + @Get("history/{certificateId}") + public async certificateHistory(@Path() certificateId: string) { + const record = await this.certificateHistoryRepo.find({ + where: { + profileCertificateId: certificateId, + }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } @Post() public async newCertificate( diff --git a/src/controllers/ProfileCertificateEmployeeTempController.ts b/src/controllers/ProfileCertificateEmployeeTempController.ts index ae494b85..6b5f7e17 100644 --- a/src/controllers/ProfileCertificateEmployeeTempController.ts +++ b/src/controllers/ProfileCertificateEmployeeTempController.ts @@ -55,8 +55,8 @@ export class ProfileCertificateEmployeeTempController extends Controller { return new HttpSuccess(record); } - @Get("history/{certificateId}") - public async certificateHistory(@Path() certificateId: string, @Request() req: RequestWithUser) { + @Get("admin/history/{certificateId}") + public async certificateAdminHistory(@Path() certificateId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.certificateHistoryRepo.find({ where: { @@ -67,6 +67,17 @@ export class ProfileCertificateEmployeeTempController extends Controller { return new HttpSuccess(record); } + @Get("history/{certificateId}") + public async certificateHistory(@Path() certificateId: string) { + const record = await this.certificateHistoryRepo.find({ + where: { + profileCertificateId: certificateId, + }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } + @Post() public async newCertificate( @Request() req: RequestWithUser, diff --git a/src/controllers/ProfileDisciplineEmployeeController.ts b/src/controllers/ProfileDisciplineEmployeeController.ts index 9463641e..3883288b 100644 --- a/src/controllers/ProfileDisciplineEmployeeController.ts +++ b/src/controllers/ProfileDisciplineEmployeeController.ts @@ -65,8 +65,8 @@ export class ProfileDisciplineEmployeeController extends Controller { return new HttpSuccess(lists); } - @Get("history/{disciplineId}") - public async disciplineHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) { + @Get("admin/history/{disciplineId}") + public async disciplineAdminHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) { const _record = await this.disciplineRepository.findOneBy({ id: disciplineId }); if (_record) { await new permission().PermissionOrgUserGet( @@ -82,6 +82,15 @@ export class ProfileDisciplineEmployeeController extends Controller { return new HttpSuccess(record); } + @Get("history/{disciplineId}") + public async disciplineHistory(@Path() disciplineId: string) { + const record = await this.disciplineHistoryRepository.find({ + where: { profileDisciplineId: disciplineId }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } + @Post() public async newDiscipline( @Request() req: RequestWithUser, diff --git a/src/controllers/ProfileDisciplineEmployeeTempController.ts b/src/controllers/ProfileDisciplineEmployeeTempController.ts index 18213655..c9a3cfa4 100644 --- a/src/controllers/ProfileDisciplineEmployeeTempController.ts +++ b/src/controllers/ProfileDisciplineEmployeeTempController.ts @@ -65,8 +65,8 @@ export class ProfileDisciplineEmployeeTempController extends Controller { return new HttpSuccess(lists); } - @Get("history/{disciplineId}") - public async disciplineHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) { + @Get("admin/history/{disciplineId}") + public async disciplineAdminHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.disciplineHistoryRepository.find({ where: { profileDisciplineId: disciplineId }, @@ -75,6 +75,15 @@ export class ProfileDisciplineEmployeeTempController extends Controller { return new HttpSuccess(record); } + @Get("history/{disciplineId}") + public async disciplineHistory(@Path() disciplineId: string) { + const record = await this.disciplineHistoryRepository.find({ + where: { profileDisciplineId: disciplineId }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } + @Post() public async newDiscipline( @Request() req: RequestWithUser, diff --git a/src/controllers/ProfileDutyEmployeeController.ts b/src/controllers/ProfileDutyEmployeeController.ts index f34b6631..9bdf00ef 100644 --- a/src/controllers/ProfileDutyEmployeeController.ts +++ b/src/controllers/ProfileDutyEmployeeController.ts @@ -51,8 +51,8 @@ export class ProfileDutyEmployeeController extends Controller { return new HttpSuccess(lists); } - @Get("history/{dutyId}") - public async dutyHistory(@Path() dutyId: string, @Request() req: RequestWithUser) { + @Get("admin/history/{dutyId}") + public async dutyAdminHistory(@Path() dutyId: string, @Request() req: RequestWithUser) { const _record = await this.dutyRepository.findOneBy({ id: dutyId }); if (_record) { await new permission().PermissionOrgUserGet( @@ -68,6 +68,15 @@ export class ProfileDutyEmployeeController extends Controller { return new HttpSuccess(record); } + @Get("history/{dutyId}") + public async dutyHistory(@Path() dutyId: string) { + const record = await this.dutyHistoryRepository.find({ + where: { profileDutyId: dutyId }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } + @Post() public async newDuty(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeDuty) { if (!body.profileEmployeeId) { diff --git a/src/controllers/ProfileDutyEmployeeTempController.ts b/src/controllers/ProfileDutyEmployeeTempController.ts index f39bd693..b4dcbb4f 100644 --- a/src/controllers/ProfileDutyEmployeeTempController.ts +++ b/src/controllers/ProfileDutyEmployeeTempController.ts @@ -51,8 +51,8 @@ export class ProfileDutyEmployeeTempController extends Controller { return new HttpSuccess(lists); } - @Get("history/{dutyId}") - public async dutyHistory(@Path() dutyId: string, @Request() req: RequestWithUser) { + @Get("admin/history/{dutyId}") + public async dutyAdminHistory(@Path() dutyId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.dutyHistoryRepository.find({ where: { profileDutyId: dutyId }, @@ -61,6 +61,15 @@ export class ProfileDutyEmployeeTempController extends Controller { return new HttpSuccess(record); } + @Get("history/{dutyId}") + public async dutyHistory(@Path() dutyId: string) { + const record = await this.dutyHistoryRepository.find({ + where: { profileDutyId: dutyId }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } + @Post() public async newDuty(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeDuty) { await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP"); diff --git a/src/controllers/ProfileEducationsEmployeeController.ts b/src/controllers/ProfileEducationsEmployeeController.ts index 179be788..6631cab8 100644 --- a/src/controllers/ProfileEducationsEmployeeController.ts +++ b/src/controllers/ProfileEducationsEmployeeController.ts @@ -64,8 +64,8 @@ export class ProfileEducationsEmployeeController extends Controller { return new HttpSuccess(getProfileEducation); } - @Get("history/{educationId}") - public async getProfileEducationHistory( + @Get("admin/history/{educationId}") + public async getProfileAdminEducationHistory( @Path() educationId: string, @Request() req: RequestWithUser, ) { @@ -90,6 +90,22 @@ export class ProfileEducationsEmployeeController extends Controller { return new HttpSuccess(record); } + @Get("history/{educationId}") + public async getProfileEducationHistory( + @Path() educationId: string, + ) { + const record = await this.profileEducationHistoryRepo.find({ + where: { + profileEducationId: educationId, + }, + order: { createdAt: "DESC" }, + }); + if (!record) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + } + return new HttpSuccess(record); + } + @Post() public async newProfileEducation( @Request() req: RequestWithUser, diff --git a/src/controllers/ProfileEducationsEmployeeTempController.ts b/src/controllers/ProfileEducationsEmployeeTempController.ts index 103e6e92..aa6cfda1 100644 --- a/src/controllers/ProfileEducationsEmployeeTempController.ts +++ b/src/controllers/ProfileEducationsEmployeeTempController.ts @@ -64,8 +64,8 @@ export class ProfileEducationsEmployeeTempController extends Controller { return new HttpSuccess(getProfileEducation); } - @Get("history/{educationId}") - public async getProfileEducationHistory( + @Get("admin/history/{educationId}") + public async getProfileAdminEducationHistory( @Path() educationId: string, @Request() req: RequestWithUser, ) { @@ -82,6 +82,22 @@ export class ProfileEducationsEmployeeTempController extends Controller { return new HttpSuccess(record); } + @Get("history/{educationId}") + public async getProfileEducationHistory( + @Path() educationId: string, + ) { + const record = await this.profileEducationHistoryRepo.find({ + where: { + profileEducationId: educationId, + }, + order: { createdAt: "DESC" }, + }); + if (!record) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + } + return new HttpSuccess(record); + } + @Post() public async newProfileEducation( @Request() req: RequestWithUser, diff --git a/src/controllers/ProfileHonorEmployeeController.ts b/src/controllers/ProfileHonorEmployeeController.ts index f992d526..4bdb7aa0 100644 --- a/src/controllers/ProfileHonorEmployeeController.ts +++ b/src/controllers/ProfileHonorEmployeeController.ts @@ -77,8 +77,8 @@ export class ProfileHonorEmployeeController extends Controller { return new HttpSuccess(record); } - @Get("history/{honorId}") - public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) { + @Get("admin/history/{honorId}") + public async honorAdminHistory(@Path() honorId: string, @Request() req: RequestWithUser) { const _record = await this.honorRepo.findOneBy({ id: honorId }); if (_record) { await new permission().PermissionOrgUserGet( @@ -97,6 +97,17 @@ export class ProfileHonorEmployeeController extends Controller { return new HttpSuccess(record); } + @Get("history/{honorId}") + public async honorHistory(@Path() honorId: string) { + const record = await this.honorHistoryRepo.find({ + where: { + profileHonorId: honorId, + }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } + @Post() public async newHonor(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeHonor) { if (!body.profileEmployeeId) { diff --git a/src/controllers/ProfileHonorEmployeeTempController.ts b/src/controllers/ProfileHonorEmployeeTempController.ts index 075e31ee..d653d348 100644 --- a/src/controllers/ProfileHonorEmployeeTempController.ts +++ b/src/controllers/ProfileHonorEmployeeTempController.ts @@ -77,8 +77,8 @@ export class ProfileHonorEmployeeTempController extends Controller { return new HttpSuccess(record); } - @Get("history/{honorId}") - public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) { + @Get("admin/history/{honorId}") + public async honorAdminHistory(@Path() honorId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.honorHistoryRepo.find({ where: { @@ -89,6 +89,17 @@ export class ProfileHonorEmployeeTempController extends Controller { return new HttpSuccess(record); } + @Get("history/{honorId}") + public async honorHistory(@Path() honorId: string) { + const record = await this.honorHistoryRepo.find({ + where: { + profileHonorId: honorId, + }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } + @Post() public async newHonor(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeHonor) { await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP"); diff --git a/src/controllers/ProfileInsigniaEmployeeController.ts b/src/controllers/ProfileInsigniaEmployeeController.ts index b2d4a613..2e522faa 100644 --- a/src/controllers/ProfileInsigniaEmployeeController.ts +++ b/src/controllers/ProfileInsigniaEmployeeController.ts @@ -67,8 +67,8 @@ export class ProfileInsigniaEmployeeController extends Controller { return new HttpSuccess(record); } - @Get("history/{InsigniaId}") - public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) { + @Get("admin/history/{InsigniaId}") + public async getInsigniaAdminHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) { const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId }); if (_record) { await new permission().PermissionOrgUserGet( @@ -91,6 +91,22 @@ export class ProfileInsigniaEmployeeController extends Controller { return new HttpSuccess(record); } + @Get("history/{InsigniaId}") + public async getInsigniaHistory(@Path() InsigniaId: string) { + const record = await this.insigniaHistoryRepo.find({ + relations: { + insignia: { + insigniaType: true, + }, + }, + where: { + profileInsigniaId: InsigniaId, + }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } + @Post() public async newInsignia( @Request() req: RequestWithUser, diff --git a/src/controllers/ProfileInsigniaEmployeeTempController.ts b/src/controllers/ProfileInsigniaEmployeeTempController.ts index fc22ca48..962e085a 100644 --- a/src/controllers/ProfileInsigniaEmployeeTempController.ts +++ b/src/controllers/ProfileInsigniaEmployeeTempController.ts @@ -67,8 +67,8 @@ export class ProfileInsigniaEmployeeTempController extends Controller { return new HttpSuccess(record); } - @Get("history/{InsigniaId}") - public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) { + @Get("admin/history/{InsigniaId}") + public async getInsigniaAdminHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.insigniaHistoryRepo.find({ relations: { @@ -84,6 +84,22 @@ export class ProfileInsigniaEmployeeTempController extends Controller { return new HttpSuccess(record); } + @Get("history/{InsigniaId}") + public async getInsigniaHistory(@Path() InsigniaId: string) { + const record = await this.insigniaHistoryRepo.find({ + relations: { + insignia: { + insigniaType: true, + }, + }, + where: { + profileInsigniaId: InsigniaId, + }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } + @Post() public async newInsignia( @Request() req: RequestWithUser, diff --git a/src/controllers/ProfileLeaveEmployeeController.ts b/src/controllers/ProfileLeaveEmployeeController.ts index f4858bb2..7320d6fe 100644 --- a/src/controllers/ProfileLeaveEmployeeController.ts +++ b/src/controllers/ProfileLeaveEmployeeController.ts @@ -70,8 +70,8 @@ export class ProfileLeaveEmployeeController extends Controller { return new HttpSuccess(record); } - @Get("history/{leaveId}") - public async leaveHistory(@Path() leaveId: string, @Request() req: RequestWithUser) { + @Get("admin/history/{leaveId}") + public async leaveAdminHistory(@Path() leaveId: string, @Request() req: RequestWithUser) { const _record = await this.leaveRepo.findOneBy({ id: leaveId }); if (_record) { await new permission().PermissionOrgUserGet( @@ -88,6 +88,16 @@ export class ProfileLeaveEmployeeController extends Controller { return new HttpSuccess(record); } + @Get("history/{leaveId}") + public async leaveHistory(@Path() leaveId: string) { + const record = await this.leaveHistoryRepo.find({ + relations: { leaveType: true }, + where: { profileLeaveId: leaveId }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } + @Post() public async newLeave(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeLeave) { if (!body.profileEmployeeId) { diff --git a/src/controllers/ProfileLeaveEmployeeTempController.ts b/src/controllers/ProfileLeaveEmployeeTempController.ts index 831480a8..b0f77d3c 100644 --- a/src/controllers/ProfileLeaveEmployeeTempController.ts +++ b/src/controllers/ProfileLeaveEmployeeTempController.ts @@ -70,8 +70,8 @@ export class ProfileLeaveEmployeeTempController extends Controller { return new HttpSuccess(record); } - @Get("history/{leaveId}") - public async leaveHistory(@Path() leaveId: string, @Request() req: RequestWithUser) { + @Get("admin/history/{leaveId}") + public async leaveAdminHistory(@Path() leaveId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.leaveHistoryRepo.find({ relations: { leaveType: true }, @@ -81,6 +81,16 @@ export class ProfileLeaveEmployeeTempController extends Controller { return new HttpSuccess(record); } + @Get("history/{leaveId}") + public async leaveHistory(@Path() leaveId: string) { + const record = await this.leaveHistoryRepo.find({ + relations: { leaveType: true }, + where: { profileLeaveId: leaveId }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } + @Post() public async newLeave(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeLeave) { await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP"); diff --git a/src/controllers/ProfileOtherEmployeeController.ts b/src/controllers/ProfileOtherEmployeeController.ts index 4b4c7033..4dfba612 100644 --- a/src/controllers/ProfileOtherEmployeeController.ts +++ b/src/controllers/ProfileOtherEmployeeController.ts @@ -55,8 +55,8 @@ export class ProfileOtherEmployeeController extends Controller { return new HttpSuccess(lists); } - @Get("history/{otherId}") - public async otherHistory(@Path() otherId: string, @Request() req: RequestWithUser) { + @Get("admin/history/{otherId}") + public async otherAdminHistory(@Path() otherId: string, @Request() req: RequestWithUser) { const _record = await this.otherRepository.findOneBy({ id: otherId }); if (_record) { await new permission().PermissionOrgUserGet( @@ -71,6 +71,15 @@ export class ProfileOtherEmployeeController extends Controller { }); return new HttpSuccess(record); } + + @Get("history/{otherId}") + public async otherHistory(@Path() otherId: string) { + const record = await this.otherHistoryRepository.find({ + where: { profileOtherId: otherId }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } @Post() public async newOther(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeOther) { diff --git a/src/controllers/ProfileOtherEmployeeTempController.ts b/src/controllers/ProfileOtherEmployeeTempController.ts index 647e01cf..1c04bdbc 100644 --- a/src/controllers/ProfileOtherEmployeeTempController.ts +++ b/src/controllers/ProfileOtherEmployeeTempController.ts @@ -56,8 +56,8 @@ export class ProfileOtherEmployeeTempController extends Controller { return new HttpSuccess(lists); } - @Get("history/{otherId}") - public async otherHistory(@Path() otherId: string, @Request() req: RequestWithUser) { + @Get("admin/history/{otherId}") + public async otherAdminHistory(@Path() otherId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.otherHistoryRepository.find({ where: { profileOtherId: otherId }, @@ -66,6 +66,15 @@ export class ProfileOtherEmployeeTempController extends Controller { return new HttpSuccess(record); } + @Get("history/{otherId}") + public async otherHistory(@Path() otherId: string) { + const record = await this.otherHistoryRepository.find({ + where: { profileOtherId: otherId }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } + @Post() public async newOther(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeOther) { await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP"); diff --git a/src/controllers/ProfileSalaryEmployeeController.ts b/src/controllers/ProfileSalaryEmployeeController.ts index 6c39900d..8fbf41e4 100644 --- a/src/controllers/ProfileSalaryEmployeeController.ts +++ b/src/controllers/ProfileSalaryEmployeeController.ts @@ -66,8 +66,8 @@ export class ProfileSalaryEmployeeController extends Controller { return new HttpSuccess(record); } - @Get("history/{salaryId}") - public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) { + @Get("admin/history/{salaryId}") + public async salaryAdminHistory(@Path() salaryId: string, @Request() req: RequestWithUser) { const _record = await this.salaryRepo.findOneBy({ id: salaryId }); if (_record) { await new permission().PermissionOrgUserGet( @@ -85,6 +85,17 @@ export class ProfileSalaryEmployeeController extends Controller { return new HttpSuccess(record); } + @Get("history/{salaryId}") + public async salaryHistory(@Path() salaryId: string) { + const record = await this.salaryHistoryRepo.find({ + where: { + profileSalaryId: salaryId, + }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } + @Post() public async newSalaryEmployee( @Request() req: RequestWithUser, diff --git a/src/controllers/ProfileSalaryEmployeeTempController.ts b/src/controllers/ProfileSalaryEmployeeTempController.ts index b23c4bf9..792f63fa 100644 --- a/src/controllers/ProfileSalaryEmployeeTempController.ts +++ b/src/controllers/ProfileSalaryEmployeeTempController.ts @@ -66,8 +66,8 @@ export class ProfileSalaryEmployeeTempController extends Controller { return new HttpSuccess(record); } - @Get("history/{salaryId}") - public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) { + @Get("admin/history/{salaryId}") + public async salaryAdminHistory(@Path() salaryId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.salaryHistoryRepo.find({ where: { @@ -78,6 +78,17 @@ export class ProfileSalaryEmployeeTempController extends Controller { return new HttpSuccess(record); } + @Get("history/{salaryId}") + public async salaryHistory(@Path() salaryId: string) { + const record = await this.salaryHistoryRepo.find({ + where: { + profileSalaryId: salaryId, + }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } + @Post() public async newSalaryEmployee( @Request() req: RequestWithUser, diff --git a/src/controllers/ProfileTrainingEmployeeController.ts b/src/controllers/ProfileTrainingEmployeeController.ts index 0f576ffb..1f26f604 100644 --- a/src/controllers/ProfileTrainingEmployeeController.ts +++ b/src/controllers/ProfileTrainingEmployeeController.ts @@ -56,8 +56,8 @@ export class ProfileTrainingEmployeeController extends Controller { return new HttpSuccess(record); } - @Get("history/{trainingId}") - public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) { + @Get("admin/history/{trainingId}") + public async trainingAdminHistory(@Path() trainingId: string, @Request() req: RequestWithUser) { const _record = await this.trainingRepo.findOneBy({ id: trainingId }); if (_record) { await new permission().PermissionOrgUserGet( @@ -76,6 +76,17 @@ export class ProfileTrainingEmployeeController extends Controller { return new HttpSuccess(record); } + @Get("history/{trainingId}") + public async trainingHistory(@Path() trainingId: string) { + const record = await this.trainingHistoryRepo.find({ + where: { + profileTrainingId: trainingId, + }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } + @Post() public async newTraining( @Request() req: RequestWithUser, diff --git a/src/controllers/ProfileTrainingEmployeeTempController.ts b/src/controllers/ProfileTrainingEmployeeTempController.ts index 942abac4..d0d69115 100644 --- a/src/controllers/ProfileTrainingEmployeeTempController.ts +++ b/src/controllers/ProfileTrainingEmployeeTempController.ts @@ -56,8 +56,8 @@ export class ProfileTrainingEmployeeTempController extends Controller { return new HttpSuccess(record); } - @Get("history/{trainingId}") - public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) { + @Get("admin/history/{trainingId}") + public async trainingAdminHistory(@Path() trainingId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.trainingHistoryRepo.find({ where: { @@ -68,6 +68,17 @@ export class ProfileTrainingEmployeeTempController extends Controller { return new HttpSuccess(record); } + @Get("history/{trainingId}") + public async trainingHistory(@Path() trainingId: string) { + const record = await this.trainingHistoryRepo.find({ + where: { + profileTrainingId: trainingId, + }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } + @Post() public async newTraining( @Request() req: RequestWithUser,