From ab138c2e04cdeb0e5b3baeb84c0cf0eff6e27fa7 Mon Sep 17 00:00:00 2001 From: JoolsoftAdmin Date: Tue, 13 Aug 2024 10:25:58 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=8A=E0=B8=B7?= =?UTF-8?q?=E0=B9=88=E0=B8=AD=E0=B8=AA=E0=B8=B4=E0=B8=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileAbilityController.ts | 10 +++++----- src/controllers/ProfileAddressController.ts | 2 +- src/controllers/ProfileAssessmentsController.ts | 11 +++++++---- src/controllers/ProfileAvatarController.ts | 4 ++-- src/controllers/ProfileCertificateController.ts | 7 +++---- src/controllers/ProfileChangeNameController.ts | 8 ++++---- src/controllers/ProfileChildrenController.ts | 8 ++++---- src/controllers/ProfileController.ts | 2 +- src/controllers/ProfileDisciplineController.ts | 6 +++--- src/controllers/ProfileDutyController.ts | 6 +++--- src/controllers/ProfileEducationsController.ts | 11 +++++++---- src/controllers/ProfileFamilyCoupleController.ts | 6 +++--- src/controllers/ProfileFamilyFatherController.ts | 4 ++-- src/controllers/ProfileFamilyMotherController.ts | 4 ++-- src/controllers/ProfileGovernmentController.ts | 2 +- src/controllers/ProfileHonorController.ts | 6 +++--- src/controllers/ProfileInsigniaController.ts | 13 ++++++++----- src/controllers/ProfileLeaveController.ts | 8 ++++---- src/controllers/ProfileNopaidController.ts | 6 +++--- src/controllers/ProfileOtherController.ts | 6 +++--- src/controllers/ProfileSalaryController.ts | 6 +++--- src/controllers/ProfileTrainingController.ts | 6 +++--- src/interfaces/permission.ts | 2 ++ 23 files changed, 77 insertions(+), 67 deletions(-) diff --git a/src/controllers/ProfileAbilityController.ts b/src/controllers/ProfileAbilityController.ts index 5414f07f..edd7ca4e 100644 --- a/src/controllers/ProfileAbilityController.ts +++ b/src/controllers/ProfileAbilityController.ts @@ -133,7 +133,7 @@ export class ProfileAbilityController extends Controller { @Request() req: RequestWithUser, @Body() body: CreateProfileAbility, ) { - await new permission().PermissionCreate(req,"SYS_REGISTRY"); + await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER"); if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } @@ -164,7 +164,7 @@ export class ProfileAbilityController extends Controller { @Request() req: RequestWithUser, @Path() abilityId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const record = await this.profileAbilityRepo.findOneBy({ id: abilityId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -186,12 +186,12 @@ export class ProfileAbilityController extends Controller { } @Delete("{abilityId}") - public async deleteProfileAbility(@Path() abilityId: string, @Request() req: RequestWithUser,) { - await new permission().PermissionDelete(req,"SYS_REGISTRY"); + public async deleteProfileAbility(@Path() abilityId: string, @Request() req: RequestWithUser) { + await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER"); await this.profileAbilityHistoryRepo.delete({ profileAbilityId: abilityId, }); - + const result = await this.profileAbilityRepo.delete({ id: abilityId }); if (result.affected == undefined || result.affected <= 0) diff --git a/src/controllers/ProfileAddressController.ts b/src/controllers/ProfileAddressController.ts index be87a538..8054d9c3 100644 --- a/src/controllers/ProfileAddressController.ts +++ b/src/controllers/ProfileAddressController.ts @@ -182,7 +182,7 @@ export class ProfileAddressController extends Controller { @Request() req: RequestWithUser, @Path() profileId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const record = await this.profileRepo.findOneBy({ id: profileId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); diff --git a/src/controllers/ProfileAssessmentsController.ts b/src/controllers/ProfileAssessmentsController.ts index 6accbfe4..4898acf4 100644 --- a/src/controllers/ProfileAssessmentsController.ts +++ b/src/controllers/ProfileAssessmentsController.ts @@ -146,7 +146,7 @@ export class ProfileAssessmentsController extends Controller { @Request() req: RequestWithUser, @Body() body: CreateProfileAssessment, ) { - await new permission().PermissionCreate(req,"SYS_REGISTRY"); + await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER"); if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } @@ -176,7 +176,7 @@ export class ProfileAssessmentsController extends Controller { @Request() req: RequestWithUser, @Path() assessmentId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -197,8 +197,11 @@ export class ProfileAssessmentsController extends Controller { } @Delete("{assessmentId}") - public async deleteProfileAssessment(@Path() assessmentId: string, @Request() req: RequestWithUser) { - await new permission().PermissionDelete(req,"SYS_REGISTRY"); + public async deleteProfileAssessment( + @Path() assessmentId: string, + @Request() req: RequestWithUser, + ) { + await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER"); await this.profileAssessmentsHistoryRepository.delete({ profileAssessmentId: assessmentId, }); diff --git a/src/controllers/ProfileAvatarController.ts b/src/controllers/ProfileAvatarController.ts index 9b176354..3eb7e0a4 100644 --- a/src/controllers/ProfileAvatarController.ts +++ b/src/controllers/ProfileAvatarController.ts @@ -63,7 +63,7 @@ export class ProfileAvatarController extends Controller { @Post() public async newAvatar(@Request() req: RequestWithUser, @Body() body: CreateProfileAvatar) { - await new permission().PermissionCreate(req,"SYS_REGISTRY"); + await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER"); const profile = await this.profileRepository.findOne({ where: { id: body.profileId }, }); @@ -115,7 +115,7 @@ export class ProfileAvatarController extends Controller { @Delete("{avatarId}") public async deleteAvatar(@Path() avatarId: string, @Request() req: RequestWithUser) { - await new permission().PermissionDelete(req,"SYS_REGISTRY"); + await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER"); const result = await this.avatarRepository.delete({ id: avatarId }); if (result.affected == undefined || result.affected <= 0) { diff --git a/src/controllers/ProfileCertificateController.ts b/src/controllers/ProfileCertificateController.ts index aece1c2a..b2496bf9 100644 --- a/src/controllers/ProfileCertificateController.ts +++ b/src/controllers/ProfileCertificateController.ts @@ -72,7 +72,6 @@ export class ProfileCertificateController extends Controller { return new HttpSuccess(record); } - @Get("history/{certificateId}") @Example({ status: 200, @@ -122,7 +121,7 @@ export class ProfileCertificateController extends Controller { @Request() req: RequestWithUser, @Body() body: CreateProfileCertificate, ) { - await new permission().PermissionCreate(req,"SYS_REGISTRY"); + await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER"); if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } @@ -155,7 +154,7 @@ export class ProfileCertificateController extends Controller { @Body() body: UpdateProfileCertificate, @Path() certificateId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const record = await this.certificateRepo.findOneBy({ id: certificateId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -178,7 +177,7 @@ export class ProfileCertificateController extends Controller { @Delete("{certificateId}") public async deleteCertificate(@Path() certificateId: string, @Request() req: RequestWithUser) { - await new permission().PermissionDelete(req,"SYS_REGISTRY"); + await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER"); await this.certificateHistoryRepo.delete({ profileCertificateId: certificateId, }); diff --git a/src/controllers/ProfileChangeNameController.ts b/src/controllers/ProfileChangeNameController.ts index 372588fb..839c1283 100644 --- a/src/controllers/ProfileChangeNameController.ts +++ b/src/controllers/ProfileChangeNameController.ts @@ -119,7 +119,7 @@ export class ProfileChangeNameController extends Controller { @Request() req: RequestWithUser, @Body() body: CreateProfileChangeName, ) { - await new permission().PermissionCreate(req,"SYS_REGISTRY"); + await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER"); if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } @@ -165,7 +165,7 @@ export class ProfileChangeNameController extends Controller { @Body() body: UpdateProfileChangeName, @Path() changeNameId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const record = await this.changeNameRepository.findOneBy({ id: changeNameId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -214,8 +214,8 @@ export class ProfileChangeNameController extends Controller { } @Delete("{changeNameId}") - public async deleteTraning(@Path() changeNameId: string, @Request() req: RequestWithUser,) { - await new permission().PermissionDelete(req,"SYS_REGISTRY"); + public async deleteTraning(@Path() changeNameId: string, @Request() req: RequestWithUser) { + await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER"); await this.changeNameHistoryRepository.delete({ profileChangeNameId: changeNameId, }); diff --git a/src/controllers/ProfileChildrenController.ts b/src/controllers/ProfileChildrenController.ts index 70021fca..f00ef633 100644 --- a/src/controllers/ProfileChildrenController.ts +++ b/src/controllers/ProfileChildrenController.ts @@ -65,7 +65,7 @@ export class ProfileChildrenController extends Controller { @Post() public async newChildren(@Request() req: RequestWithUser, @Body() body: CreateProfileChildren) { - await new permission().PermissionCreate(req,"SYS_REGISTRY"); + await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER"); const profile = await this.profileRepository.findOneBy({ id: body.profileId }); if (!profile) { @@ -108,7 +108,7 @@ export class ProfileChildrenController extends Controller { @Body() body: UpdateProfileChildren, @Path() childrenId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const record = await this.childrenRepository.findOneBy({ id: childrenId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -135,8 +135,8 @@ export class ProfileChildrenController extends Controller { } @Delete("{childrenId}") - public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser,) { - await new permission().PermissionDelete(req,"SYS_REGISTRY"); + public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser) { + await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER"); await this.childrenHistoryRepository.delete({ profileChildrenId: childrenId, }); diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index df343da9..fc3abee5 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -2277,7 +2277,7 @@ export class ProfileController extends Controller { @Path() id: string, @Body() body: UpdateProfile, ) { - await new permission().PermissionUpdate(request, "SYS_REGISTRY"); + await new permission().PermissionUpdate(request, "SYS_REGISTRY_OFFICER"); const exists = !!body.citizenId && (await this.profileRepo.findOne({ diff --git a/src/controllers/ProfileDisciplineController.ts b/src/controllers/ProfileDisciplineController.ts index ced55b63..948527d1 100644 --- a/src/controllers/ProfileDisciplineController.ts +++ b/src/controllers/ProfileDisciplineController.ts @@ -124,7 +124,7 @@ export class ProfileDisciplineController extends Controller { @Request() req: RequestWithUser, @Body() body: CreateProfileDiscipline, ) { - await new permission().PermissionCreate(req,"SYS_REGISTRY"); + await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER"); if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } @@ -157,7 +157,7 @@ export class ProfileDisciplineController extends Controller { @Body() body: UpdateProfileDiscipline, @Path() disciplineId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const record = await this.disciplineRepository.findOneBy({ id: disciplineId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -180,7 +180,7 @@ export class ProfileDisciplineController extends Controller { @Delete("{disciplineId}") public async deleteDiscipline(@Path() disciplineId: string, @Request() req: RequestWithUser) { - await new permission().PermissionDelete(req,"SYS_REGISTRY"); + await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER"); await this.disciplineHistoryRepository.delete({ profileDisciplineId: disciplineId, }); diff --git a/src/controllers/ProfileDutyController.ts b/src/controllers/ProfileDutyController.ts index 31c17037..c46f21dd 100644 --- a/src/controllers/ProfileDutyController.ts +++ b/src/controllers/ProfileDutyController.ts @@ -128,7 +128,7 @@ export class ProfileDutyController extends Controller { @Post() public async newDuty(@Request() req: RequestWithUser, @Body() body: CreateProfileDuty) { - await new permission().PermissionCreate(req,"SYS_REGISTRY"); + await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER"); if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } @@ -161,7 +161,7 @@ export class ProfileDutyController extends Controller { @Body() body: UpdateProfileDuty, @Path() dutyId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const record = await this.dutyRepository.findOneBy({ id: dutyId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -181,7 +181,7 @@ export class ProfileDutyController extends Controller { @Delete("{dutyId}") public async deleteDuty(@Path() dutyId: string, @Request() req: RequestWithUser) { - await new permission().PermissionDelete(req,"SYS_REGISTRY"); + await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER"); await this.dutyHistoryRepository.delete({ profileDutyId: dutyId, }); diff --git a/src/controllers/ProfileEducationsController.ts b/src/controllers/ProfileEducationsController.ts index 5ae7821a..717b326c 100644 --- a/src/controllers/ProfileEducationsController.ts +++ b/src/controllers/ProfileEducationsController.ts @@ -181,7 +181,7 @@ export class ProfileEducationsController extends Controller { @Request() req: RequestWithUser, @Body() body: CreateProfileEducation, ) { - await new permission().PermissionCreate(req,"SYS_REGISTRY"); + await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER"); if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } @@ -212,7 +212,7 @@ export class ProfileEducationsController extends Controller { @Request() req: RequestWithUser, @Path() educationId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const record = await this.profileEducationRepo.findOneBy({ id: educationId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -234,8 +234,11 @@ export class ProfileEducationsController extends Controller { } @Delete("{educationId}") - public async deleteProfileEducation(@Path() educationId: string, @Request() req: RequestWithUser) { - await new permission().PermissionDelete(req,"SYS_REGISTRY"); + public async deleteProfileEducation( + @Path() educationId: string, + @Request() req: RequestWithUser, + ) { + await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER"); await this.profileEducationHistoryRepo.delete({ profileEducationId: educationId, }); diff --git a/src/controllers/ProfileFamilyCoupleController.ts b/src/controllers/ProfileFamilyCoupleController.ts index a5243916..89d77613 100644 --- a/src/controllers/ProfileFamilyCoupleController.ts +++ b/src/controllers/ProfileFamilyCoupleController.ts @@ -149,7 +149,7 @@ export class ProfileFamilyCoupleController extends Controller { return new HttpSuccess(mapData); } - + @Get("history/{profileId}") @Example({ status: 200, @@ -220,7 +220,7 @@ export class ProfileFamilyCoupleController extends Controller { @Request() req: RequestWithUser, @Body() body: CreateProfileFamilyCouple, ) { - await new permission().PermissionCreate(req,"SYS_REGISTRY"); + await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER"); const familyCouple = Object.assign(new ProfileFamilyCouple(), body); if (!familyCouple) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -267,7 +267,7 @@ export class ProfileFamilyCoupleController extends Controller { @Body() body: UpdateProfileFamilyCouple, @Path() profileId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const familyCouple = await this.ProfileFamilyCouple.findOneBy({ profileId: profileId }); if (!familyCouple) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); diff --git a/src/controllers/ProfileFamilyFatherController.ts b/src/controllers/ProfileFamilyFatherController.ts index a0860261..25ee303f 100644 --- a/src/controllers/ProfileFamilyFatherController.ts +++ b/src/controllers/ProfileFamilyFatherController.ts @@ -206,7 +206,7 @@ export class ProfileFamilyFatherController extends Controller { @Request() req: RequestWithUser, @Body() body: CreateProfileFamilyFather, ) { - await new permission().PermissionCreate(req,"SYS_REGISTRY"); + await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER"); const familyFather = Object.assign(new ProfileFamilyFather(), body); if (!familyFather) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -247,7 +247,7 @@ export class ProfileFamilyFatherController extends Controller { @Body() body: UpdateProfileFamilyFather, @Path() profileId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const familyFather = await this.ProfileFamilyFather.findOneBy({ profileId: profileId }); if (!familyFather) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); diff --git a/src/controllers/ProfileFamilyMotherController.ts b/src/controllers/ProfileFamilyMotherController.ts index 798c60ef..032613f9 100644 --- a/src/controllers/ProfileFamilyMotherController.ts +++ b/src/controllers/ProfileFamilyMotherController.ts @@ -206,7 +206,7 @@ export class ProfileFamilyMotherController extends Controller { @Request() req: RequestWithUser, @Body() body: CreateProfileFamilyMother, ) { - await new permission().PermissionCreate(req,"SYS_REGISTRY"); + await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER"); const familyMother = Object.assign(new ProfileFamilyMother(), body); if (!familyMother) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -247,7 +247,7 @@ export class ProfileFamilyMotherController extends Controller { @Body() body: UpdateProfileFamilyMother, @Path() profileId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const familyMother = await this.ProfileFamilyMother.findOneBy({ profileId: profileId }); if (!familyMother) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); diff --git a/src/controllers/ProfileGovernmentController.ts b/src/controllers/ProfileGovernmentController.ts index cef1adbf..73905a42 100644 --- a/src/controllers/ProfileGovernmentController.ts +++ b/src/controllers/ProfileGovernmentController.ts @@ -293,7 +293,7 @@ export class ProfileGovernmentHistoryController extends Controller { @Body() body: UpdateProfileGovernment, @Path() profileId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const record = await this.profileRepo.findOne({ where: { id: profileId }, }); diff --git a/src/controllers/ProfileHonorController.ts b/src/controllers/ProfileHonorController.ts index 57a84874..70e7b447 100644 --- a/src/controllers/ProfileHonorController.ts +++ b/src/controllers/ProfileHonorController.ts @@ -138,7 +138,7 @@ export class ProfileHonorController extends Controller { @Post() public async newHonor(@Request() req: RequestWithUser, @Body() body: CreateProfileHonor) { - await new permission().PermissionCreate(req,"SYS_REGISTRY"); + await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER"); if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } @@ -171,7 +171,7 @@ export class ProfileHonorController extends Controller { @Body() body: UpdateProfileHonor, @Path() honorId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const record = await this.honorRepo.findOneBy({ id: honorId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -191,7 +191,7 @@ export class ProfileHonorController extends Controller { @Delete("{honorId}") public async deleteTraning(@Path() honorId: string, @Request() req: RequestWithUser) { - await new permission().PermissionDelete(req,"SYS_REGISTRY"); + await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER"); await this.honorHistoryRepo.delete({ profileHonorId: honorId, }); diff --git a/src/controllers/ProfileInsigniaController.ts b/src/controllers/ProfileInsigniaController.ts index 82b5ce07..2c616fa4 100644 --- a/src/controllers/ProfileInsigniaController.ts +++ b/src/controllers/ProfileInsigniaController.ts @@ -166,7 +166,7 @@ export class ProfileInsigniaController extends Controller { @Post() public async newInsignia(@Request() req: RequestWithUser, @Body() body: CreateProfileInsignia) { - await new permission().PermissionCreate(req,"SYS_REGISTRY"); + await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER"); if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } @@ -206,7 +206,7 @@ export class ProfileInsigniaController extends Controller { @Body() body: UpdateProfileInsignia, @Path() insigniaId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const record = await this.insigniaRepo.findOneBy({ id: insigniaId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -233,7 +233,7 @@ export class ProfileInsigniaController extends Controller { @Delete("{insigniaId}") public async deleteInsignia(@Path() insigniaId: string, @Request() req: RequestWithUser) { - await new permission().PermissionDelete(req,"SYS_REGISTRY"); + await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER"); await this.insigniaHistoryRepo.delete({ profileInsigniaId: insigniaId, }); @@ -248,7 +248,10 @@ export class ProfileInsigniaController extends Controller { } @Post("dump-db") - public async newInsigniaDumpDB(@Request() req: RequestWithUser, @Body() body: CreateProfileInsignia) { + public async newInsigniaDumpDB( + @Request() req: RequestWithUser, + @Body() body: CreateProfileInsignia, + ) { if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } @@ -276,7 +279,7 @@ export class ProfileInsigniaController extends Controller { }; Object.assign(data, { ...body, ...meta }); - data.insigniaId = insignia.id + data.insigniaId = insignia.id; await this.insigniaRepo.save(data); return new HttpSuccess(); diff --git a/src/controllers/ProfileLeaveController.ts b/src/controllers/ProfileLeaveController.ts index 0f9eea8b..cfb2f9a2 100644 --- a/src/controllers/ProfileLeaveController.ts +++ b/src/controllers/ProfileLeaveController.ts @@ -247,7 +247,7 @@ export class ProfileLeaveController extends Controller { @Post() public async newLeave(@Request() req: RequestWithUser, @Body() body: CreateProfileLeave) { - await new permission().PermissionCreate(req,"SYS_REGISTRY"); + await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER"); if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } @@ -286,7 +286,7 @@ export class ProfileLeaveController extends Controller { @Body() body: UpdateProfileLeave, @Path() leaveId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const record = await this.leaveRepo.findOneBy({ id: leaveId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -313,7 +313,7 @@ export class ProfileLeaveController extends Controller { @Delete("{leaveId}") public async deleteLeave(@Path() leaveId: string, @Request() req: RequestWithUser) { - await new permission().PermissionDelete(req,"SYS_REGISTRY"); + await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER"); await this.leaveHistoryRepo.delete({ profileLeaveId: leaveId, }); @@ -339,7 +339,7 @@ export class ProfileLeaveController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const leaveType = await this.leaveTypeRepository.findOne({ - where: { name: body.leaveTypeId } + where: { name: body.leaveTypeId }, }); if (!leaveType) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทลานี้"); diff --git a/src/controllers/ProfileNopaidController.ts b/src/controllers/ProfileNopaidController.ts index 3475c911..e055722b 100644 --- a/src/controllers/ProfileNopaidController.ts +++ b/src/controllers/ProfileNopaidController.ts @@ -96,7 +96,7 @@ export class ProfileNopaidController extends Controller { @Post() public async newNopaid(@Request() req: RequestWithUser, @Body() body: CreateProfileNopaid) { - await new permission().PermissionCreate(req,"SYS_REGISTRY"); + await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER"); if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } @@ -129,7 +129,7 @@ export class ProfileNopaidController extends Controller { @Body() body: UpdateProfileNopaid, @Path() nopaidId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const record = await this.nopaidRepository.findOneBy({ id: nopaidId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -152,7 +152,7 @@ export class ProfileNopaidController extends Controller { @Delete("{nopaidId}") public async deleteNopaid(@Path() nopaidId: string, @Request() req: RequestWithUser) { - await new permission().PermissionDelete(req,"SYS_REGISTRY"); + await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER"); await this.nopaidHistoryRepository.delete({ profileNopaidId: nopaidId, }); diff --git a/src/controllers/ProfileOtherController.ts b/src/controllers/ProfileOtherController.ts index 2575e926..d6cb2bde 100644 --- a/src/controllers/ProfileOtherController.ts +++ b/src/controllers/ProfileOtherController.ts @@ -93,7 +93,7 @@ export class ProfileOtherController extends Controller { @Post() public async newOther(@Request() req: RequestWithUser, @Body() body: CreateProfileOther) { - await new permission().PermissionCreate(req,"SYS_REGISTRY"); + await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER"); if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } @@ -126,7 +126,7 @@ export class ProfileOtherController extends Controller { @Body() body: UpdateProfileOther, @Path() otherId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const record = await this.otherRepository.findOneBy({ id: otherId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -149,7 +149,7 @@ export class ProfileOtherController extends Controller { @Delete("{otherId}") public async deleteOther(@Path() otherId: string, @Request() req: RequestWithUser) { - await new permission().PermissionDelete(req,"SYS_REGISTRY"); + await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER"); await this.otherHistoryRepository.delete({ profileOtherId: otherId, }); diff --git a/src/controllers/ProfileSalaryController.ts b/src/controllers/ProfileSalaryController.ts index 3a17eb17..1048e341 100644 --- a/src/controllers/ProfileSalaryController.ts +++ b/src/controllers/ProfileSalaryController.ts @@ -140,7 +140,7 @@ export class ProfileSalaryController extends Controller { @Post() public async newSalary(@Request() req: RequestWithUser, @Body() body: CreateProfileSalary) { - await new permission().PermissionCreate(req,"SYS_REGISTRY"); + await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER"); if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } @@ -179,7 +179,7 @@ export class ProfileSalaryController extends Controller { @Body() body: UpdateProfileSalary, @Path() salaryId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const record = await this.salaryRepo.findOneBy({ id: salaryId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -199,7 +199,7 @@ export class ProfileSalaryController extends Controller { @Delete("{salaryId}") public async deleteSalary(@Path() salaryId: string, @Request() req: RequestWithUser) { - await new permission().PermissionDelete(req,"SYS_REGISTRY"); + await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER"); await this.salaryHistoryRepo.delete({ profileSalaryId: salaryId, }); diff --git a/src/controllers/ProfileTrainingController.ts b/src/controllers/ProfileTrainingController.ts index eb34c688..cbf6735e 100644 --- a/src/controllers/ProfileTrainingController.ts +++ b/src/controllers/ProfileTrainingController.ts @@ -139,7 +139,7 @@ export class ProfileTrainingController extends Controller { @Post() public async newTraining(@Request() req: RequestWithUser, @Body() body: CreateProfileTraining) { - await new permission().PermissionCreate(req,"SYS_REGISTRY"); + await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER"); if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } @@ -172,7 +172,7 @@ export class ProfileTrainingController extends Controller { @Body() body: UpdateProfileTraining, @Path() trainingId: string, ) { - await new permission().PermissionUpdate(req,"SYS_REGISTRY"); + await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); const record = await this.trainingRepo.findOneBy({ id: trainingId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -192,7 +192,7 @@ export class ProfileTrainingController extends Controller { @Delete("{trainingId}") public async deleteTraining(@Path() trainingId: string, @Request() req: RequestWithUser) { - await new permission().PermissionDelete(req,"SYS_REGISTRY"); + await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER"); await this.trainingHistoryRepo.delete({ profileTrainingId: trainingId, }); diff --git a/src/interfaces/permission.ts b/src/interfaces/permission.ts index 74bb1de4..fd5dd737 100644 --- a/src/interfaces/permission.ts +++ b/src/interfaces/permission.ts @@ -19,6 +19,8 @@ import HttpStatus from "./http-status"; class CheckAuth { public async Permission(req: RequestWithUser, system: string, action: string) { + console.log(req); + await new CallAPI() .GetData(req, "/org/permission") .then((x) => {