From 281c5c7dfd58ddeb49c23d8217b32bb4e7b9e561 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 27 Aug 2024 16:49:29 +0700 Subject: [PATCH] fix --- src/controllers/ProfileEmployeeController.ts | 62 +++++++++---------- .../ProfileEmployeeTempController.ts | 20 +++--- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 71b5472c..5178ed91 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -2893,7 +2893,7 @@ export class ProfileEmployeeController extends Controller { @Path() profileEmployeeId: string, @Body() body: UpdateInformationProfileEmployee, ) { - // await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", profileEmployeeId);//ไม่แน่ใจEMPปิดไว้ก่อน + await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", profileEmployeeId); const profileEmp = await this.profileRepo.findOneBy({ id: profileEmployeeId }); if (!profileEmp) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้"); @@ -2922,7 +2922,7 @@ export class ProfileEmployeeController extends Controller { */ @Get("information/{profileEmployeeId}") async getInformationById(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - // await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);//ไม่แน่ใจEMPปิดไว้ก่อน + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const profileInformation = await this.profileRepo.findOne({ where: { id: profileEmployeeId }, }); @@ -2953,7 +2953,7 @@ export class ProfileEmployeeController extends Controller { */ @Get("information/history/{profileEmployeeId}") async getInformationHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - // await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileEmployeeId);//ไม่แน่ใจEMPปิดไว้ก่อน + await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileEmployeeId); const profileInformation = await this.profileRepo.find({ relations: { information_histories: true, @@ -2998,7 +2998,7 @@ export class ProfileEmployeeController extends Controller { @Path() profileEmployeeId: string, @Request() req: RequestWithUser, ) { - // await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileEmployeeId);//ไม่แน่ใจEMPปิดไว้ก่อน + await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileEmployeeId); const employment = await this.employmentRepository.find({ where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, @@ -3023,13 +3023,13 @@ export class ProfileEmployeeController extends Controller { const employment = await this.employmentRepository.findOne({ where: { id: id }, }); - // if (employment) { - // await new permission().PermissionOrgUserGet( - // req, - // "SYS_REGISTRY_EMP", - // employment.profileEmployeeId, - // ); - // }//ไม่แน่ใจEMPปิดไว้ก่อน + if (employment) { + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + employment.profileEmployeeId, + ); + } return new HttpSuccess(employment); } @@ -3045,13 +3045,13 @@ export class ProfileEmployeeController extends Controller { const employment = await this.employmentRepository.findOne({ where: { id: id }, }); - // if (employment) { - // await new permission().PermissionOrgUserList( - // req, - // "SYS_REGISTRY_EMP", - // employment.profileEmployeeId, - // ); - // }//ไม่แน่ใจEMPปิดไว้ก่อน + if (employment) { + await new permission().PermissionOrgUserList( + req, + "SYS_REGISTRY_EMP", + employment.profileEmployeeId, + ); + } const employmentHistory = await this.employmentHistoryRepository.find({ where: { profileEmployeeEmploymentId: id }, order: { lastUpdatedAt: "ASC" }, @@ -3076,7 +3076,7 @@ export class ProfileEmployeeController extends Controller { where: { id: profileEmployeeId }, }); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - // await new permission().PermissionOrgUserList(request, "SYS_REGISTRY_EMP", profile.id);//ไม่แน่ใจEMPปิดไว้ก่อน + await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", profile.id); const employment = new ProfileEmployeeEmployment(); // const history = new ProfileEmployeeEmploymentHistory(); @@ -3111,13 +3111,13 @@ export class ProfileEmployeeController extends Controller { const employment = await this.employmentRepository.findOne({ where: { id: id }, }); - // if (employment) { - // await new permission().PermissionOrgUserDelete( - // request, - // "SYS_REGISTRY_EMP", - // employment.profileEmployeeId, - // ); - // }//ไม่แน่ใจEMPปิดไว้ก่อน + if (employment) { + await new permission().PermissionOrgUserDelete( + request, + "SYS_REGISTRY_EMP", + employment.profileEmployeeId, + ); + } await this.employmentHistoryRepository.delete({ profileEmployeeEmploymentId: id, }); @@ -3144,11 +3144,11 @@ export class ProfileEmployeeController extends Controller { ) { const employment = await this.employmentRepository.findOneBy({ id }); if (!employment) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - // await new permission().PermissionOrgUserUpdate( - // request, - // "SYS_REGISTRY_EMP", - // employment.profileEmployeeId, - // );//ไม่แน่ใจEMPปิดไว้ก่อน + await new permission().PermissionOrgUserUpdate( + request, + "SYS_REGISTRY_EMP", + employment.profileEmployeeId, + ); const history = new ProfileEmployeeEmploymentHistory(); Object.assign(history, { ...employment, id: undefined }); diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 49d8b78d..3120d350 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -2891,7 +2891,7 @@ export class ProfileEmployeeTempController extends Controller { @Path() profileEmployeeId: string, @Body() body: UpdateInformationProfileEmployee, ) { - // await new permission().PermissionUpdate(request, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน + await new permission().PermissionUpdate(request, "SYS_REGISTRY_TEMP"); const profileEmp = await this.profileRepo.findOneBy({ id: profileEmployeeId }); if (!profileEmp) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้"); @@ -2920,7 +2920,7 @@ export class ProfileEmployeeTempController extends Controller { */ @Get("information/{profileEmployeeId}") async getInformationById(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - // await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน + await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const profileInformation = await this.profileRepo.findOne({ where: { id: profileEmployeeId }, }); @@ -2951,7 +2951,7 @@ export class ProfileEmployeeTempController extends Controller { */ @Get("information/history/{profileEmployeeId}") async getInformationHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - // await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน + await new permission().PermissionList(req, "SYS_REGISTRY_TEMP"); const profileInformation = await this.profileRepo.find({ relations: { information_histories: true, @@ -2996,7 +2996,7 @@ export class ProfileEmployeeTempController extends Controller { @Path() profileEmployeeId: string, @Request() req: RequestWithUser, ) { - // await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน + await new permission().PermissionList(req, "SYS_REGISTRY_TEMP"); const employment = await this.employmentRepository.find({ where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, @@ -3018,7 +3018,7 @@ export class ProfileEmployeeTempController extends Controller { */ @Get("employment/id/{id}") async GetEmploymentById(@Path() id: string, @Request() req: RequestWithUser) { - // await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน + await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const employment = await this.employmentRepository.findOne({ where: { id: id }, }); @@ -3034,7 +3034,7 @@ export class ProfileEmployeeTempController extends Controller { */ @Get("employment/history/{id}") async GetHistoryEmploymentById(@Path() id: string, @Request() req: RequestWithUser) { - // await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน + await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const employmentHistory = await this.employmentHistoryRepository.find({ where: { profileEmployeeEmploymentId: id }, order: { lastUpdatedAt: "ASC" }, @@ -3055,7 +3055,7 @@ export class ProfileEmployeeTempController extends Controller { @Body() body: CreateEmploymentProfileEmployee, @Request() request: RequestWithUser, ) { - // await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน + await new permission().PermissionUpdate(request, "SYS_REGISTRY_TEMP"); const profile = await this.profileRepo.findOne({ where: { id: profileEmployeeId }, }); @@ -3090,8 +3090,8 @@ export class ProfileEmployeeTempController extends Controller { * @param {string} id Id ข้อมูลการจ้าง */ @Delete("employment/{id}") - async DeleteEmployment(@Path() id: string) { - // await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน + async DeleteEmployment(@Path() id: string, @Request() req: RequestWithUser) { + await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP"); await this.employmentHistoryRepository.delete({ profileEmployeeEmploymentId: id, }); @@ -3116,7 +3116,7 @@ export class ProfileEmployeeTempController extends Controller { @Path() id: string, @Body() body: UpdateEmploymentProfileEmployee, ) { - // await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน + await new permission().PermissionUpdate(request, "SYS_REGISTRY_TEMP"); const employment = await this.employmentRepository.findOneBy({ id }); if (!employment) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");