diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 4cb88806..ec8b76f9 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -2096,6 +2096,9 @@ export class CommandController extends Controller { refCommandNo?: string | null; salaryRef?: string | null; commandId?: string | null; + amount?: Double | null; + positionSalaryAmount?: Double | null; + mouthSalaryAmount?: Double | null; }[]; }, ) { @@ -2133,11 +2136,9 @@ export class CommandController extends Controller { profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, positionExecutive: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, - amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, - positionSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, - mouthSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, + amount: item.amount ? item.amount : null, + positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null, + mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 @@ -2176,6 +2177,9 @@ export class CommandController extends Controller { refCommandNo?: string | null; salaryRef?: string | null; commandId?: string | null; + amount?: Double | null; + positionSalaryAmount?: Double | null; + mouthSalaryAmount?: Double | null; }[]; }, ) { @@ -2226,11 +2230,9 @@ export class CommandController extends Controller { profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, positionExecutive: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, - amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, - positionSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, - mouthSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, + amount: item.amount ? item.amount : null, + positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null, + mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 diff --git a/src/controllers/DevelopmentRequestController.ts b/src/controllers/DevelopmentRequestController.ts index 10ec4363..0169650c 100644 --- a/src/controllers/DevelopmentRequestController.ts +++ b/src/controllers/DevelopmentRequestController.ts @@ -174,7 +174,8 @@ export class DevelopmentRequestController extends Controller { @Get("admin/{id}") public async getDevelopmentRequestByUser(@Path() id: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_OFFICER"); + let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_OFFICER"); const data = await this.developmentRequestRepository.findOne({ where: { id: id }, relations: ["developmentProjects"], @@ -301,7 +302,7 @@ export class DevelopmentRequestController extends Controller { }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER"); - + if (requestBody.status == "APPROVE" && record.status == "PENDING") { let profileDevelopment = new ProfileDevelopment(); const meta = { diff --git a/src/controllers/OrgRootController.ts b/src/controllers/OrgRootController.ts index 44b29eb8..7ef3eed5 100644 --- a/src/controllers/OrgRootController.ts +++ b/src/controllers/OrgRootController.ts @@ -72,6 +72,7 @@ export class OrgRootController extends Controller { orgRootPhoneIn: orgRoot.orgRootPhoneIn, orgRootFax: orgRoot.orgRootFax, orgRevisionId: orgRoot.orgRevisionId, + isDeputy: orgRoot.isDeputy, orgCode: orgRoot.orgRootCode + "00", }; return new HttpSuccess(getOrgRoot); @@ -102,6 +103,24 @@ export class OrgRootController extends Controller { @Request() request: RequestWithUser, ) { await new permission().PermissionCreate(request, "SYS_ORG"); + + if (requestBody.isDeputy == true) { + const orgRevision = await this.orgRevisionRepository.findOne({ + where: { id: requestBody.orgRevisionId }, + relations: ["orgRoots"], + }); + if (orgRevision != null) { + await Promise.all( + orgRevision.orgRoots + .filter((x: OrgRoot) => x.isDeputy == true) + .map(async (item: OrgRoot) => { + item.isDeputy = false; + await this.orgRootRepository.save(item); + }), + ); + } + } + const validOrgRootRanks = ["DEPARTMENT", "OFFICE", "DIVISION", "SECTION"]; if (!validOrgRootRanks.includes(requestBody.orgRootRank.toUpperCase())) { throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. orgRootRank"); @@ -193,6 +212,23 @@ export class OrgRootController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. orgRo otRank"); } + if (requestBody.isDeputy == true) { + const orgRevision = await this.orgRevisionRepository.findOne({ + where: { id: requestBody.orgRevisionId }, + relations: ["orgRoots"], + }); + if (orgRevision != null) { + await Promise.all( + orgRevision.orgRoots + .filter((x: OrgRoot) => x.isDeputy == true) + .map(async (item: OrgRoot) => { + item.isDeputy = false; + await this.orgRootRepository.save(item); + }), + ); + } + } + const revisionIdExits = await this.orgRevisionRepository.findOne({ where: { id: requestBody.orgRevisionId }, }); diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index e4c80cdd..55171542 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -732,6 +732,7 @@ export class OrganizationController extends Controller { // ) .select([ "orgRoot.id", + "orgRoot.isDeputy", "orgRoot.orgRootName", "orgRoot.orgRootShortName", "orgRoot.orgRootCode", @@ -906,6 +907,7 @@ export class OrganizationController extends Controller { orgRootName: orgRoot.orgRootName, responsibility: orgRoot.responsibility, isOfficer: false, + isDeputy: orgRoot.isDeputy, labelName: orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName, totalPosition: await this.posMasterRepository.count({ @@ -1552,6 +1554,7 @@ export class OrganizationController extends Controller { }) .select([ "orgRoot.id", + "orgRoot.isDeputy", "orgRoot.orgRootName", "orgRoot.orgRootShortName", "orgRoot.orgRootCode", @@ -1685,6 +1688,7 @@ export class OrganizationController extends Controller { orgTreeFax: orgRoot.orgRootFax, orgRevisionId: orgRoot.orgRevisionId, orgRootName: orgRoot.orgRootName, + isDeputy: orgRoot.isDeputy, responsibility: orgRoot.responsibility, labelName: orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName, @@ -2322,6 +2326,7 @@ export class OrganizationController extends Controller { ) .select([ "orgRoot.id", + "orgRoot.isDeputy", "orgRoot.orgRootName", "orgRoot.orgRootShortName", "orgRoot.orgRootCode", @@ -2495,6 +2500,7 @@ export class OrganizationController extends Controller { orgTreeFax: orgRoot.orgRootFax, orgRevisionId: orgRoot.orgRevisionId, orgRootName: orgRoot.orgRootName, + isDeputy:orgRoot.isDeputy, responsibility: orgRoot.responsibility, labelName: orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName, @@ -6561,6 +6567,24 @@ export class OrganizationController extends Controller { const check = orgRevision.orgChild1s.find((x) => x.isOfficer == true); return new HttpSuccess(check != null); } + /** + * API เช็ค org ในระบบ + * + * @summary - เช็ค org ในระบบ (ADMIN) + * + */ + @Get("check/root/{id}") + async findIsDeputyRoot(@Path() id: string, @Request() request: RequestWithUser) { + const orgRevision = await this.orgRevisionRepository.findOne({ + where: { id }, + relations: ["orgRoots"], + }); + if (!orgRevision) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); + } + const check = orgRevision.orgRoots.find((x) => x.isDeputy == true); + return new HttpSuccess(check != null); + } public async listAuthSysOrgFuncByRevisionIdN( request: RequestWithUser, system: string, diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 22e48fec..24672cb5 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -2152,7 +2152,8 @@ export class PositionController extends Controller { */ @Get("history/{id}") async getHistoryPosMater(@Path() id: string, @Request() request: RequestWithUser) { - await new permission().PermissionGet(request, "SYS_ORG"); + let _workflow = await new permission().Workflow(request, id, "SYS_ORG"); + if (_workflow == false) await new permission().PermissionGet(request, "SYS_ORG"); const posMaster = await this.posMasterRepository.findOne({ where: { id }, }); diff --git a/src/controllers/ProfileAbilityController.ts b/src/controllers/ProfileAbilityController.ts index 54bb531c..41409586 100644 --- a/src/controllers/ProfileAbilityController.ts +++ b/src/controllers/ProfileAbilityController.ts @@ -51,7 +51,9 @@ export class ProfileAbilityController extends Controller { @Get("{profileId}") public async detailProfileAbility(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const getProfileAbilityId = await this.profileAbilityRepo.find({ where: { profileId: profileId }, order: { createdAt: "ASC" }, @@ -69,7 +71,9 @@ export class ProfileAbilityController extends Controller { ) { const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + let _workflow = await new permission().Workflow(req, abilityId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } const record = await this.profileAbilityHistoryRepo.find({ diff --git a/src/controllers/ProfileAbilityEmployeeController.ts b/src/controllers/ProfileAbilityEmployeeController.ts index 9287a9d5..b77f2ba1 100644 --- a/src/controllers/ProfileAbilityEmployeeController.ts +++ b/src/controllers/ProfileAbilityEmployeeController.ts @@ -54,7 +54,9 @@ export class ProfileAbilityEmployeeController extends Controller { @Path() profileEmployeeId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const getProfileAbilityId = await this.profileAbilityRepo.find({ where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, @@ -72,11 +74,13 @@ export class ProfileAbilityEmployeeController extends Controller { ) { const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId }); if (_record) { - await new permission().PermissionOrgUserGet( - req, - "SYS_REGISTRY_EMP", - _record.profileEmployeeId, - ); + let _workflow = await new permission().Workflow(req, abilityId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.profileAbilityHistoryRepo.find({ where: { profileAbilityId: abilityId }, diff --git a/src/controllers/ProfileAbilityEmployeeTempController.ts b/src/controllers/ProfileAbilityEmployeeTempController.ts index d49d91c0..60c3d023 100644 --- a/src/controllers/ProfileAbilityEmployeeTempController.ts +++ b/src/controllers/ProfileAbilityEmployeeTempController.ts @@ -54,7 +54,8 @@ export class ProfileAbilityEmployeeTempController extends Controller { @Path() profileEmployeeId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const getProfileAbilityId = await this.profileAbilityRepo.find({ where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, @@ -72,7 +73,8 @@ export class ProfileAbilityEmployeeTempController extends Controller { ) { const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId }); if (_record) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, abilityId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); } const record = await this.profileAbilityHistoryRepo.find({ where: { profileAbilityId: abilityId }, diff --git a/src/controllers/ProfileAddressController.ts b/src/controllers/ProfileAddressController.ts index 4adccbbe..d552d86d 100644 --- a/src/controllers/ProfileAddressController.ts +++ b/src/controllers/ProfileAddressController.ts @@ -51,7 +51,9 @@ export class ProfileAddressController extends Controller { */ @Get("{profileId}") public async detailProfileAddress(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const getProfileAddress = await this.profileRepo.findOne({ where: { id: profileId }, select: [ @@ -125,7 +127,9 @@ export class ProfileAddressController extends Controller { @Path() profileId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const record = await this.profileAddressHistoryRepo.find({ where: { profileId: profileId }, relations: [ diff --git a/src/controllers/ProfileAddressEmployeeController.ts b/src/controllers/ProfileAddressEmployeeController.ts index f9e4d80c..453f5fcf 100644 --- a/src/controllers/ProfileAddressEmployeeController.ts +++ b/src/controllers/ProfileAddressEmployeeController.ts @@ -55,7 +55,9 @@ export class ProfileAddressEmployeeController extends Controller { @Path() profileEmployeeId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const getProfileAddress = await this.profileEmployeeRepo.findOne({ where: { id: profileEmployeeId }, select: [ @@ -129,7 +131,9 @@ export class ProfileAddressEmployeeController extends Controller { @Path() profileId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); const record = await this.profileAddressHistoryRepo.find({ where: { profileEmployeeId: profileId }, relations: [ diff --git a/src/controllers/ProfileAddressEmployeeTempController.ts b/src/controllers/ProfileAddressEmployeeTempController.ts index 8802ae55..d8d7e916 100644 --- a/src/controllers/ProfileAddressEmployeeTempController.ts +++ b/src/controllers/ProfileAddressEmployeeTempController.ts @@ -55,7 +55,8 @@ export class ProfileAddressEmployeeTempController extends Controller { @Path() profileEmployeeId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const getProfileAddress = await this.profileEmployeeRepo.findOne({ where: { id: profileEmployeeId }, select: [ @@ -129,7 +130,8 @@ export class ProfileAddressEmployeeTempController extends Controller { @Path() profileId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.profileAddressHistoryRepo.find({ where: { profileEmployeeId: profileId }, relations: [ diff --git a/src/controllers/ProfileAssessmentsController.ts b/src/controllers/ProfileAssessmentsController.ts index b0338f9a..ca81cb53 100644 --- a/src/controllers/ProfileAssessmentsController.ts +++ b/src/controllers/ProfileAssessmentsController.ts @@ -55,7 +55,9 @@ export class ProfileAssessmentsController extends Controller { @Path() profileId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const getProfileAssessments = await this.profileAssessmentsRepository.find({ where: { profileId: profileId }, order: { createdAt: "ASC" }, @@ -77,7 +79,9 @@ export class ProfileAssessmentsController extends Controller { }, }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + let _workflow = await new permission().Workflow(req, assessmentId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } const record = await this.profileAssessmentsHistoryRepository.find({ diff --git a/src/controllers/ProfileAssessmentsEmployeeController.ts b/src/controllers/ProfileAssessmentsEmployeeController.ts index 96d1339e..034218f4 100644 --- a/src/controllers/ProfileAssessmentsEmployeeController.ts +++ b/src/controllers/ProfileAssessmentsEmployeeController.ts @@ -55,7 +55,9 @@ export class ProfileAssessmentsEmployeeController extends Controller { @Path() profileEmployeeId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const getProfileAssessments = await this.profileAssessmentsRepository.find({ where: { profileEmployeeId: profileEmployeeId, @@ -75,11 +77,13 @@ export class ProfileAssessmentsEmployeeController extends Controller { ) { const _record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId }); if (_record) { - await new permission().PermissionOrgUserGet( - req, - "SYS_REGISTRY_EMP", - _record.profileEmployeeId, - ); + let _workflow = await new permission().Workflow(req, assessmentId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.profileAssessmentsHistoryRepository.find({ where: { diff --git a/src/controllers/ProfileAssessmentsEmployeeTempController.ts b/src/controllers/ProfileAssessmentsEmployeeTempController.ts index e0f0ba57..d9e2b47a 100644 --- a/src/controllers/ProfileAssessmentsEmployeeTempController.ts +++ b/src/controllers/ProfileAssessmentsEmployeeTempController.ts @@ -55,7 +55,8 @@ export class ProfileAssessmentsEmployeeTempController extends Controller { @Path() profileEmployeeId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const getProfileAssessments = await this.profileAssessmentsRepository.find({ where: { profileEmployeeId: profileEmployeeId, @@ -73,7 +74,8 @@ export class ProfileAssessmentsEmployeeTempController extends Controller { @Path() assessmentId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, assessmentId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.profileAssessmentsHistoryRepository.find({ where: { profileAssessmentId: assessmentId, diff --git a/src/controllers/ProfileAvatarController.ts b/src/controllers/ProfileAvatarController.ts index a5a11da9..98db7ca6 100644 --- a/src/controllers/ProfileAvatarController.ts +++ b/src/controllers/ProfileAvatarController.ts @@ -17,7 +17,9 @@ export class ProfileAvatarController extends Controller { @Get("{profileId}") public async getAvatar(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.avatarRepository.find({ where: { profileId: profileId }, order: { createdAt: "ASC" }, @@ -27,7 +29,9 @@ export class ProfileAvatarController extends Controller { @Get("profileId/{id}") async getProfile(@Path() id: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id); + let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id); const profile = await this.profileRepository.findOne({ where: { id }, }); diff --git a/src/controllers/ProfileAvatarEmployeeController.ts b/src/controllers/ProfileAvatarEmployeeController.ts index 9fb0d8a2..21f9f536 100644 --- a/src/controllers/ProfileAvatarEmployeeController.ts +++ b/src/controllers/ProfileAvatarEmployeeController.ts @@ -20,7 +20,9 @@ export class ProfileAvatarEmployeeController extends Controller { @Path() profileEmployeeId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const lists = await this.avatarRepository.find({ where: { profileEmployeeId }, order: { createdAt: "ASC" }, @@ -30,7 +32,9 @@ export class ProfileAvatarEmployeeController extends Controller { @Get("profileEmployeeId/{id}") async getProfile(@Path() id: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id); + let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id); const profile = await this.profileRepository.findOne({ where: { id }, }); diff --git a/src/controllers/ProfileAvatarEmployeeTempController.ts b/src/controllers/ProfileAvatarEmployeeTempController.ts index 829fc32a..f16944a9 100644 --- a/src/controllers/ProfileAvatarEmployeeTempController.ts +++ b/src/controllers/ProfileAvatarEmployeeTempController.ts @@ -20,7 +20,8 @@ export class ProfileAvatarEmployeeTempController extends Controller { @Path() profileEmployeeId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.avatarRepository.find({ where: { profileEmployeeId }, order: { createdAt: "ASC" }, @@ -30,7 +31,8 @@ export class ProfileAvatarEmployeeTempController extends Controller { @Get("profileEmployeeId/{id}") async getProfile(@Path() id: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const profile = await this.profileRepository.findOne({ where: { id }, }); diff --git a/src/controllers/ProfileCertificateController.ts b/src/controllers/ProfileCertificateController.ts index 1109f1f2..4cdcf024 100644 --- a/src/controllers/ProfileCertificateController.ts +++ b/src/controllers/ProfileCertificateController.ts @@ -48,7 +48,9 @@ export class ProfileCertificateController extends Controller { @Get("{profileId}") public async getCertificate(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const record = await this.certificateRepo.find({ where: { profileId: profileId }, order: { createdAt: "ASC" }, @@ -63,7 +65,9 @@ export class ProfileCertificateController extends Controller { ) { const _record = await this.certificateRepo.findOneBy({ id: certificateId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + let _workflow = await new permission().Workflow(req, certificateId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } const record = await this.certificateHistoryRepo.find({ where: { diff --git a/src/controllers/ProfileCertificateEmployeeController.ts b/src/controllers/ProfileCertificateEmployeeController.ts index 04d045e8..db2e9dde 100644 --- a/src/controllers/ProfileCertificateEmployeeController.ts +++ b/src/controllers/ProfileCertificateEmployeeController.ts @@ -48,7 +48,9 @@ export class ProfileCertificateEmployeeController extends Controller { @Get("{profileEmployeeId}") public async getCertificate(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const record = await this.certificateRepo.find({ where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, @@ -63,11 +65,13 @@ export class ProfileCertificateEmployeeController extends Controller { ) { const _record = await this.certificateRepo.findOneBy({ id: certificateId }); if (_record) { - await new permission().PermissionOrgUserGet( - req, - "SYS_REGISTRY_EMP", - _record.profileEmployeeId, - ); + let _workflow = await new permission().Workflow(req, certificateId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.certificateHistoryRepo.find({ where: { diff --git a/src/controllers/ProfileCertificateEmployeeTempController.ts b/src/controllers/ProfileCertificateEmployeeTempController.ts index 26879ac8..66f9d3cc 100644 --- a/src/controllers/ProfileCertificateEmployeeTempController.ts +++ b/src/controllers/ProfileCertificateEmployeeTempController.ts @@ -48,7 +48,8 @@ export class ProfileCertificateEmployeeTempController extends Controller { @Get("{profileEmployeeId}") public async getCertificate(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.certificateRepo.find({ where: { profileEmployeeId }, order: { createdAt: "ASC" }, @@ -61,7 +62,8 @@ export class ProfileCertificateEmployeeTempController extends Controller { @Path() certificateId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, certificateId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.certificateHistoryRepo.find({ where: { profileCertificateId: certificateId, diff --git a/src/controllers/ProfileChangeNameController.ts b/src/controllers/ProfileChangeNameController.ts index addc0e40..60deb04f 100644 --- a/src/controllers/ProfileChangeNameController.ts +++ b/src/controllers/ProfileChangeNameController.ts @@ -49,7 +49,9 @@ export class ProfileChangeNameController extends Controller { @Get("{profileId}") public async getChangeName(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.changeNameRepository.find({ where: { profileId: profileId }, order: { createdAt: "ASC" }, @@ -61,7 +63,9 @@ export class ProfileChangeNameController extends Controller { public async changeNameHistory(@Path() changeNameId: string, @Request() req: RequestWithUser) { const _record = await this.changeNameRepository.findOneBy({ id: changeNameId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + let _workflow = await new permission().Workflow(req, changeNameId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } const record = await this.changeNameHistoryRepository.find({ where: { profileChangeNameId: changeNameId }, diff --git a/src/controllers/ProfileChangeNameEmployeeController.ts b/src/controllers/ProfileChangeNameEmployeeController.ts index b2ca5892..6aaa011d 100644 --- a/src/controllers/ProfileChangeNameEmployeeController.ts +++ b/src/controllers/ProfileChangeNameEmployeeController.ts @@ -49,7 +49,9 @@ export class ProfileChangeNameEmployeeController extends Controller { @Get("{profileEmployeeId}") public async getChangeName(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const lists = await this.changeNameRepository.find({ where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, @@ -61,11 +63,13 @@ export class ProfileChangeNameEmployeeController extends Controller { public async changeNameHistory(@Path() changeNameId: string, @Request() req: RequestWithUser) { const _record = await this.changeNameRepository.findOneBy({ id: changeNameId }); if (_record) { - await new permission().PermissionOrgUserGet( - req, - "SYS_REGISTRY_EMP", - _record.profileEmployeeId, - ); + let _workflow = await new permission().Workflow(req, changeNameId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.changeNameHistoryRepository.find({ where: { profileChangeNameId: changeNameId }, diff --git a/src/controllers/ProfileChangeNameEmployeeTempController.ts b/src/controllers/ProfileChangeNameEmployeeTempController.ts index 84a77f1d..9b78073e 100644 --- a/src/controllers/ProfileChangeNameEmployeeTempController.ts +++ b/src/controllers/ProfileChangeNameEmployeeTempController.ts @@ -49,7 +49,8 @@ export class ProfileChangeNameEmployeeTempController extends Controller { @Get("{profileEmployeeId}") public async getChangeName(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.changeNameRepository.find({ where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, @@ -59,7 +60,8 @@ export class ProfileChangeNameEmployeeTempController extends Controller { @Get("history/{changeNameId}") public async changeNameHistory(@Path() changeNameId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, changeNameId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.changeNameHistoryRepository.find({ where: { profileChangeNameId: changeNameId }, order: { createdAt: "DESC" }, diff --git a/src/controllers/ProfileChildrenController.ts b/src/controllers/ProfileChildrenController.ts index d98ee6d5..205352d1 100644 --- a/src/controllers/ProfileChildrenController.ts +++ b/src/controllers/ProfileChildrenController.ts @@ -49,7 +49,9 @@ export class ProfileChildrenController extends Controller { @Get("{profileId}") public async getChildren(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.childrenRepository.find({ where: { profileId: profileId }, order: { createdAt: "ASC" }, @@ -61,7 +63,9 @@ export class ProfileChildrenController extends Controller { public async childrenHistory(@Path() childrenId: string, @Request() req: RequestWithUser) { const _record = await this.childrenRepository.findOneBy({ id: childrenId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + let _workflow = await new permission().Workflow(req, childrenId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } const record = await this.childrenHistoryRepository.find({ where: { profileChildrenId: childrenId }, diff --git a/src/controllers/ProfileChildrenEmployeeController.ts b/src/controllers/ProfileChildrenEmployeeController.ts index 3088c7e4..1d4f46d6 100644 --- a/src/controllers/ProfileChildrenEmployeeController.ts +++ b/src/controllers/ProfileChildrenEmployeeController.ts @@ -49,7 +49,9 @@ export class ProfileChildrenEmployeeController extends Controller { @Get("{profileEmployeeId}") public async getChildren(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const lists = await this.childrenRepository.find({ where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, @@ -61,11 +63,13 @@ export class ProfileChildrenEmployeeController extends Controller { public async childrenHistory(@Path() childrenId: string, @Request() req: RequestWithUser) { const _record = await this.childrenRepository.findOneBy({ id: childrenId }); if (_record) { - await new permission().PermissionOrgUserGet( - req, - "SYS_REGISTRY_EMP", - _record.profileEmployeeId, - ); + let _workflow = await new permission().Workflow(req, childrenId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.childrenHistoryRepository.find({ where: { profileChildrenId: childrenId }, diff --git a/src/controllers/ProfileChildrenEmployeeTempController.ts b/src/controllers/ProfileChildrenEmployeeTempController.ts index 8d232c0a..874af63c 100644 --- a/src/controllers/ProfileChildrenEmployeeTempController.ts +++ b/src/controllers/ProfileChildrenEmployeeTempController.ts @@ -49,7 +49,8 @@ export class ProfileChildrenEmployeeTempController extends Controller { @Get("{profileEmployeeId}") public async getChildren(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.childrenRepository.find({ where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, @@ -59,7 +60,8 @@ export class ProfileChildrenEmployeeTempController extends Controller { @Get("history/{childrenId}") public async childrenHistory(@Path() childrenId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, childrenId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.childrenHistoryRepository.find({ where: { profileChildrenId: childrenId }, order: { createdAt: "DESC" }, diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 26c3264f..3a9e797a 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -113,7 +113,7 @@ export class ProfileController extends Controller { */ @Get("kp7-short/{id}") async kp7ShortById(@Path() id: string, @Request() req: RequestWithUser) { - // await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id); + //await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id); const orgRevision = await this.orgRevisionRepo.findOne({ where: { orgRevisionIsCurrent: true }, }); @@ -283,7 +283,7 @@ export class ProfileController extends Controller { */ @Get("kk1/{id}") public async getKk1(@Path() id: string, @Request() req: RequestWithUser) { - // await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id); + //await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id); const profiles = await this.profileRepo.findOne({ // select: [ // "citizenId", @@ -1234,7 +1234,7 @@ export class ProfileController extends Controller { */ @Get("commander/{profileId}") async getProfileCommanderUser(@Request() request: RequestWithUser, @Path() profileId: string) { - // await new permission().PermissionOrgUserGet(request, "SYS_REGISTRY_OFFICER", profileId);//ไม่แน่ใจOFFปิดไว้ก่อน + //await new permission().PermissionOrgUserGet(request, "SYS_REGISTRY_OFFICER", profileId); //ไม่แน่ใจOFFปิดไว้ก่อน const profile = await this.profileRepo.findOne({ where: { id: profileId }, }); @@ -2752,7 +2752,9 @@ export class ProfileController extends Controller { */ @Get("{id}") async getProfile(@Request() req: RequestWithUser, @Path() id: string) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id); + let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id); let profile: any = await this.profileRepo.findOne({ relations: { posLevel: true, @@ -2798,7 +2800,7 @@ export class ProfileController extends Controller { @Get("history/{id}") async getProfileHistory(@Path() id: string, @Request() req: RequestWithUser) { - // await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id);//ไม่แน่ใจOFFปิดไว้ก่อน + //await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id); //ไม่แน่ใจOFFปิดไว้ก่อน const profile = await this.profileHistoryRepo.find({ relations: { posLevel: true, @@ -3975,7 +3977,7 @@ export class ProfileController extends Controller { */ @Get("profileid/position/{id}") async getProfileByProfileid(@Request() request: RequestWithUser, @Path() id: string) { - // await new permission().PermissionOrgUserGet(request, "SYS_REGISTRY_OFFICER", id);//ไม่แน่ใจOFFปิดไว้ก่อน + //await new permission().PermissionOrgUserGet(request, "SYS_REGISTRY_OFFICER", id); //ไม่แน่ใจOFFปิดไว้ก่อน const profile = await this.profileRepo.findOne({ where: { id: id }, relations: [ @@ -4208,7 +4210,7 @@ export class ProfileController extends Controller { if (!profile) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); } - // await new permission().PermissionOrgUserGet(request, "SYS_REGISTRY_OFFICER", profile.id);//ไม่แน่ใจOFFปิดไว้ก่อน + //await new permission().PermissionOrgUserGet(request, "SYS_REGISTRY_OFFICER", profile.id); //ไม่แน่ใจOFFปิดไว้ก่อน return new HttpSuccess(profile); } @@ -4228,7 +4230,7 @@ export class ProfileController extends Controller { if (!profile) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); } - // await new permission().PermissionOrgUserGet(request, "SYS_REGISTRY_OFFICER", profile.id);//ไม่แน่ใจOFFปิดไว้ก่อน + //await new permission().PermissionOrgUserGet(request, "SYS_REGISTRY_OFFICER", profile.id); //ไม่แน่ใจOFFปิดไว้ก่อน const orgRevisionPublish = await this.orgRevisionRepo .createQueryBuilder("orgRevision") @@ -4343,7 +4345,7 @@ export class ProfileController extends Controller { */ @Get("profileempid/position/{id}") async getProfileByProfileempid(@Request() request: RequestWithUser, @Path() id: string) { - // await new permission().PermissionOrgUserGet(request, "SYS_REGISTRY_OFFICER", id);//ไม่แน่ใจOFFปิดไว้ก่อน + //await new permission().PermissionOrgUserGet(request, "SYS_REGISTRY_OFFICER", id); //ไม่แน่ใจOFFปิดไว้ก่อน const profile = await this.profileEmpRepo.findOne({ where: { id: id }, relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"], @@ -5671,7 +5673,7 @@ export class ProfileController extends Controller { */ @Get("profileid/retire/{year}") async getProfileByRetireYear(@Path() year: number, @Request() req: RequestWithUser) { - // await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id);//ไม่แน่ใจOFFปิดไว้ก่อน + //await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id); //ไม่แน่ใจOFFปิดไว้ก่อน const profiles = await this.profileRepo .createQueryBuilder("profile") .leftJoinAndSelect("profile.posLevel", "posLevel") @@ -6363,15 +6365,16 @@ export class ProfileController extends Controller { return new HttpSuccess(); } - /** + /** * API แก้ไขเบอร์โทรศัพท์ * - * @summary แก้ไขเบอร์โทรศัพท์ (USER) + * @summary แก้ไขเบอร์โทรศัพท์ (USER) * */ @Put("updatePhoneNumber/user") - async updatePhoneNumber(@Request() request: RequestWithUser, - @Body() + async updatePhoneNumber( + @Request() request: RequestWithUser, + @Body() body: { phone: string; }, @@ -6408,15 +6411,16 @@ export class ProfileController extends Controller { return new HttpSuccess(); } - /** + /** * API แก้ไขอีเมล * - * @summary แก้ไขอีเมล (USER) + * @summary แก้ไขอีเมล (USER) * */ @Put("updateEmail/user") - async updateEmail(@Request() request: RequestWithUser, - @Body() + async updateEmail( + @Request() request: RequestWithUser, + @Body() body: { email: string; }, @@ -6453,7 +6457,4 @@ export class ProfileController extends Controller { ]); return new HttpSuccess(); } - - - } diff --git a/src/controllers/ProfileDevelopmentController.ts b/src/controllers/ProfileDevelopmentController.ts index 08948b7c..d102f423 100644 --- a/src/controllers/ProfileDevelopmentController.ts +++ b/src/controllers/ProfileDevelopmentController.ts @@ -10,7 +10,7 @@ import { Route, Security, Tags, - Query + Query, } from "tsoa"; import { AppDataSource } from "../database/data-source"; import HttpSuccess from "../interfaces/http-success"; @@ -51,13 +51,15 @@ export class ProfileDevelopmentController extends Controller { @Get("{profileId}") public async getDevelopment( - @Path() profileId: string, + @Path() profileId: string, @Request() req: RequestWithUser, @Query("page") page: number = 1, @Query("pageSize") pageSize: number = 10, @Query() searchKeyword: string = "", ) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const [profileDevelopment, total] = await AppDataSource.getRepository(ProfileDevelopment) .createQueryBuilder("profileDevelopment") .where({ profileId: profileId }) @@ -67,10 +69,10 @@ export class ProfileDevelopmentController extends Controller { searchKeyword != undefined && searchKeyword != null && searchKeyword != "" ? "profileDevelopment.name LIKE :keyword" : "1=1", - { - keyword: `%${searchKeyword}%`, - }, - ) + { + keyword: `%${searchKeyword}%`, + }, + ) .orWhere( searchKeyword != undefined && searchKeyword != null && searchKeyword != "" ? "profileDevelopment.developmentTarget LIKE :keyword" @@ -108,7 +110,9 @@ export class ProfileDevelopmentController extends Controller { public async developmentHistory(@Path() developmentId: string, @Request() req: RequestWithUser) { const _record = await this.developmentRepository.findOneBy({ id: developmentId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + let _workflow = await new permission().Workflow(req, developmentId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } const record = await this.developmentHistoryRepository.find({ where: { profileDevelopmentId: developmentId }, diff --git a/src/controllers/ProfileDevelopmentEmployeeController.ts b/src/controllers/ProfileDevelopmentEmployeeController.ts index 6a0bf2eb..025740e4 100644 --- a/src/controllers/ProfileDevelopmentEmployeeController.ts +++ b/src/controllers/ProfileDevelopmentEmployeeController.ts @@ -49,7 +49,9 @@ export class ProfileDevelopmentEmployeeController extends Controller { @Get("{profileId}") public async getDevelopment(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); const lists = await this.developmentRepository.find({ where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, @@ -61,11 +63,13 @@ export class ProfileDevelopmentEmployeeController extends Controller { public async developmentHistory(@Path() developmentId: string, @Request() req: RequestWithUser) { const _record = await this.developmentRepository.findOneBy({ id: developmentId }); if (_record) { - await new permission().PermissionOrgUserGet( - req, - "SYS_REGISTRY_EMP", - _record.profileEmployeeId, - ); + let _workflow = await new permission().Workflow(req, developmentId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.developmentHistoryRepository.find({ where: { profileDevelopmentId: developmentId }, diff --git a/src/controllers/ProfileDevelopmentEmployeeTempController.ts b/src/controllers/ProfileDevelopmentEmployeeTempController.ts index 4e502e83..768fd87e 100644 --- a/src/controllers/ProfileDevelopmentEmployeeTempController.ts +++ b/src/controllers/ProfileDevelopmentEmployeeTempController.ts @@ -49,7 +49,8 @@ export class ProfileDevelopmentEmployeeTempController extends Controller { @Get("{profileId}") public async getDevelopment(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.developmentRepository.find({ where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, @@ -59,7 +60,8 @@ export class ProfileDevelopmentEmployeeTempController extends Controller { @Get("history/{developmentId}") public async developmentHistory(@Path() developmentId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, developmentId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.developmentHistoryRepository.find({ where: { profileDevelopmentId: developmentId }, order: { createdAt: "DESC" }, diff --git a/src/controllers/ProfileDisciplineController.ts b/src/controllers/ProfileDisciplineController.ts index 5dd76287..e29af310 100644 --- a/src/controllers/ProfileDisciplineController.ts +++ b/src/controllers/ProfileDisciplineController.ts @@ -48,7 +48,9 @@ export class ProfileDisciplineController extends Controller { @Get("{profileId}") public async getDiscipline(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.disciplineRepository.find({ where: { profileId: profileId }, order: { createdAt: "ASC" }, @@ -58,7 +60,8 @@ export class ProfileDisciplineController extends Controller { @Get("admin/{profileId}") public async getDisciplineAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_SALARY_OFFICER"); + let _workflow = await new permission().Workflow(req, profileId, "SYS_SALARY_OFFICER"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_SALARY_OFFICER"); const lists = await this.disciplineRepository.find({ where: { profileId: profileId }, order: { createdAt: "ASC" }, @@ -73,7 +76,9 @@ export class ProfileDisciplineController extends Controller { ) { const _record = await this.disciplineRepository.findOneBy({ id: disciplineId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + let _workflow = await new permission().Workflow(req, disciplineId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } const record = await this.disciplineHistoryRepository.find({ where: { profileDisciplineId: disciplineId }, diff --git a/src/controllers/ProfileDisciplineEmployeeController.ts b/src/controllers/ProfileDisciplineEmployeeController.ts index 29d05050..e934e668 100644 --- a/src/controllers/ProfileDisciplineEmployeeController.ts +++ b/src/controllers/ProfileDisciplineEmployeeController.ts @@ -48,7 +48,9 @@ export class ProfileDisciplineEmployeeController extends Controller { @Get("{profileId}") public async getDiscipline(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); const lists = await this.disciplineRepository.find({ where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, @@ -58,7 +60,8 @@ export class ProfileDisciplineEmployeeController extends Controller { @Get("admin/{profileId}") public async getDisciplineAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_WAGE"); + let _workflow = await new permission().Workflow(req, profileId, "SYS_WAGE"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_WAGE"); const lists = await this.disciplineRepository.find({ where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, @@ -73,11 +76,13 @@ export class ProfileDisciplineEmployeeController extends Controller { ) { const _record = await this.disciplineRepository.findOneBy({ id: disciplineId }); if (_record) { - await new permission().PermissionOrgUserGet( - req, - "SYS_REGISTRY_EMP", - _record.profileEmployeeId, - ); + let _workflow = await new permission().Workflow(req, disciplineId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.disciplineHistoryRepository.find({ where: { profileDisciplineId: disciplineId }, diff --git a/src/controllers/ProfileDisciplineEmployeeTempController.ts b/src/controllers/ProfileDisciplineEmployeeTempController.ts index af900ad9..b981d567 100644 --- a/src/controllers/ProfileDisciplineEmployeeTempController.ts +++ b/src/controllers/ProfileDisciplineEmployeeTempController.ts @@ -48,7 +48,8 @@ export class ProfileDisciplineEmployeeTempController extends Controller { @Get("{profileId}") public async getDiscipline(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.disciplineRepository.find({ where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, @@ -58,7 +59,8 @@ export class ProfileDisciplineEmployeeTempController extends Controller { @Get("admin/{profileId}") public async getDisciplineAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_WAGE"); + let _workflow = await new permission().Workflow(req, profileId, "SYS_WAGE"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_WAGE"); const lists = await this.disciplineRepository.find({ where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, @@ -71,7 +73,8 @@ export class ProfileDisciplineEmployeeTempController extends Controller { @Path() disciplineId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, disciplineId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.disciplineHistoryRepository.find({ where: { profileDisciplineId: disciplineId }, order: { createdAt: "DESC" }, diff --git a/src/controllers/ProfileDutyController.ts b/src/controllers/ProfileDutyController.ts index 5981e1db..a9b4865c 100644 --- a/src/controllers/ProfileDutyController.ts +++ b/src/controllers/ProfileDutyController.ts @@ -44,7 +44,9 @@ export class ProfileDutyController extends Controller { @Get("{profileId}") public async getDuty(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.dutyRepository.find({ where: { profileId: profileId }, order: { createdAt: "ASC" }, @@ -56,7 +58,9 @@ export class ProfileDutyController extends Controller { public async dutyAdminHistory(@Path() dutyId: string, @Request() req: RequestWithUser) { const _record = await this.dutyRepository.findOneBy({ id: dutyId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + let _workflow = await new permission().Workflow(req, dutyId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } const record = await this.dutyHistoryRepository.find({ where: { profileDutyId: dutyId }, diff --git a/src/controllers/ProfileDutyEmployeeController.ts b/src/controllers/ProfileDutyEmployeeController.ts index 13b692a0..2093b375 100644 --- a/src/controllers/ProfileDutyEmployeeController.ts +++ b/src/controllers/ProfileDutyEmployeeController.ts @@ -44,7 +44,9 @@ export class ProfileDutyEmployeeController extends Controller { @Get("{profileId}") public async getDuty(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); const lists = await this.dutyRepository.find({ where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, @@ -56,11 +58,13 @@ export class ProfileDutyEmployeeController extends Controller { public async dutyAdminHistory(@Path() dutyId: string, @Request() req: RequestWithUser) { const _record = await this.dutyRepository.findOneBy({ id: dutyId }); if (_record) { - await new permission().PermissionOrgUserGet( - req, - "SYS_REGISTRY_EMP", - _record.profileEmployeeId, - ); + let _workflow = await new permission().Workflow(req, dutyId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.dutyHistoryRepository.find({ where: { profileDutyId: dutyId }, diff --git a/src/controllers/ProfileDutyEmployeeTempController.ts b/src/controllers/ProfileDutyEmployeeTempController.ts index dc34f8b9..7b199560 100644 --- a/src/controllers/ProfileDutyEmployeeTempController.ts +++ b/src/controllers/ProfileDutyEmployeeTempController.ts @@ -44,7 +44,8 @@ export class ProfileDutyEmployeeTempController extends Controller { @Get("{profileId}") public async getDuty(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.dutyRepository.find({ where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, @@ -54,7 +55,8 @@ export class ProfileDutyEmployeeTempController extends Controller { @Get("admin/history/{dutyId}") public async dutyAdminHistory(@Path() dutyId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, dutyId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.dutyHistoryRepository.find({ where: { profileDutyId: dutyId }, order: { createdAt: "DESC" }, diff --git a/src/controllers/ProfileEditController.ts b/src/controllers/ProfileEditController.ts index c30a23e9..77077cd5 100644 --- a/src/controllers/ProfileEditController.ts +++ b/src/controllers/ProfileEditController.ts @@ -210,7 +210,7 @@ export class ProfileEditController extends Controller { await new CallAPI() .PostData(req, "/org/workflow/add-workflow", { refId: data.id, - sysName: "REGISTRY_PROFILE", + sysName: "SYS_REGISTRY_OFFICER", posLevelName: profile.posLevel.posLevelName, posTypeName: profile.posType.posTypeName, }) diff --git a/src/controllers/ProfileEducationsController.ts b/src/controllers/ProfileEducationsController.ts index 4c9d702b..a1618bb9 100644 --- a/src/controllers/ProfileEducationsController.ts +++ b/src/controllers/ProfileEducationsController.ts @@ -53,7 +53,9 @@ export class ProfileEducationsController extends Controller { @Get("{profileId}") public async detailProfileEducation(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const getProfileEducation = await this.profileEducationRepo.find({ where: { profileId: profileId }, order: { createdAt: "ASC" }, @@ -71,7 +73,9 @@ export class ProfileEducationsController extends Controller { ) { const _record = await this.profileEducationRepo.findOneBy({ id: educationId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + let _workflow = await new permission().Workflow(req, educationId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } const record = await this.profileEducationHistoryRepo.find({ where: { diff --git a/src/controllers/ProfileEducationsEmployeeController.ts b/src/controllers/ProfileEducationsEmployeeController.ts index 189e8889..5f3c8795 100644 --- a/src/controllers/ProfileEducationsEmployeeController.ts +++ b/src/controllers/ProfileEducationsEmployeeController.ts @@ -54,7 +54,9 @@ export class ProfileEducationsEmployeeController extends Controller { @Path() profileEmployeeId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const getProfileEducation = await this.profileEducationRepo.find({ where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, @@ -72,11 +74,13 @@ export class ProfileEducationsEmployeeController extends Controller { ) { const _record = await this.profileEducationRepo.findOneBy({ id: educationId }); if (_record) { - await new permission().PermissionOrgUserGet( - req, - "SYS_REGISTRY_EMP", - _record.profileEmployeeId, - ); + let _workflow = await new permission().Workflow(req, educationId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.profileEducationHistoryRepo.find({ diff --git a/src/controllers/ProfileEducationsEmployeeTempController.ts b/src/controllers/ProfileEducationsEmployeeTempController.ts index 61c2325d..53519a39 100644 --- a/src/controllers/ProfileEducationsEmployeeTempController.ts +++ b/src/controllers/ProfileEducationsEmployeeTempController.ts @@ -54,7 +54,8 @@ export class ProfileEducationsEmployeeTempController extends Controller { @Path() profileEmployeeId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const getProfileEducation = await this.profileEducationRepo.find({ where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, @@ -70,7 +71,8 @@ export class ProfileEducationsEmployeeTempController extends Controller { @Path() educationId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, educationId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.profileEducationHistoryRepo.find({ where: { profileEducationId: educationId, diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index e3c8ed77..d7918565 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -139,7 +139,9 @@ export class ProfileEmployeeController extends Controller { }, }); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profile.id); + let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profile.id); let ImgUrl: any; if (profile?.avatar != null && profile?.avatarName != null) { // await new CallAPI() @@ -305,7 +307,9 @@ export class ProfileEmployeeController extends Controller { where: { id: id }, }); if (profiles) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profiles.id); + let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profiles.id); } if (!profiles) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); let ImgUrl: any; @@ -1230,7 +1234,9 @@ export class ProfileEmployeeController extends Controller { */ @Get("{id}") async detailProfile(@Path() id: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id); + let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id); const profile: any = await this.profileRepo.findOne({ relations: { posLevel: true, @@ -1585,7 +1591,7 @@ export class ProfileEmployeeController extends Controller { @Get("history/{id}") async getProfileHistory(@Path() id: string, @Request() req: RequestWithUser) { - // await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id);ไม่แน่ใจEMPปิดไว้ก่อน + //await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id); ไม่แน่ใจEMPปิดไว้ก่อน; const profile = await this.profileHistoryRepo.find({ relations: { posLevel: true, @@ -3210,7 +3216,9 @@ 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); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const profileInformation = await this.profileRepo.findOne({ where: { id: profileEmployeeId }, }); @@ -3241,7 +3249,9 @@ export class ProfileEmployeeController extends Controller { */ @Get("information/history/{profileEmployeeId}") async getInformationHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const profileInformation = await this.informationHistoryRepository.find({ where: { profileEmployeeId: profileEmployeeId }, order: { @@ -3263,7 +3273,9 @@ export class ProfileEmployeeController extends Controller { @Path() profileEmployeeId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const employment = await this.employmentRepository.find({ where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, @@ -3289,11 +3301,13 @@ export class ProfileEmployeeController extends Controller { where: { id: id }, }); if (employment) { - await new permission().PermissionOrgUserGet( - req, - "SYS_REGISTRY_EMP", - employment.profileEmployeeId, - ); + let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + employment.profileEmployeeId, + ); } return new HttpSuccess(employment); } @@ -3311,11 +3325,13 @@ export class ProfileEmployeeController extends Controller { where: { id: id }, }); if (employment) { - await new permission().PermissionOrgUserGet( - req, - "SYS_REGISTRY_EMP", - employment.profileEmployeeId, - ); + let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + employment.profileEmployeeId, + ); } const employmentHistory = await this.employmentHistoryRepository.find({ where: { profileEmployeeEmploymentId: id }, @@ -3705,17 +3721,23 @@ export class ProfileEmployeeController extends Controller { async getProfileByProfileid(@Request() request: RequestWithUser, @Path() id: string) { const profile = await this.profileRepo.findOne({ where: { id: id }, - relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot", "profileSalarys"], + relations: [ + "posLevel", + "posType", + "current_holders", + "current_holders.orgRoot", + "profileSalarys", + ], order: { profileSalarys: { - order: "DESC" - } - } + order: "DESC", + }, + }, }); if (!profile) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); } - // await new permission().PermissionOrgUserGet(request, "SYS_REGISTRY_EMP", profile.id);//ไม่แน่ใจEMPปิดไว้ก่อน + //await new permission().PermissionOrgUserGet(request, "SYS_REGISTRY_EMP", profile.id); //ไม่แน่ใจEMPปิดไว้ก่อน const orgRevisionPublish = await this.orgRevisionRepo .createQueryBuilder("orgRevision") @@ -3831,7 +3853,8 @@ export class ProfileEmployeeController extends Controller { node: null, nodeId: null, posNo: shortName, - salary: profile && profile.profileSalarys.length > 0 ? profile.profileSalarys[0].amount : null + salary: + profile && profile.profileSalarys.length > 0 ? profile.profileSalarys[0].amount : null, }; if (_profile.child4Id != null) { diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index cc096c45..a49f174c 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -115,7 +115,8 @@ export class ProfileEmployeeTempController extends Controller { */ @Get("kp7-short/{id}") async kp7ShortById(@Path() id: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const orgRevision = await this.orgRevisionRepo.findOne({ where: { orgRevisionIsCurrent: true }, }); @@ -239,7 +240,8 @@ export class ProfileEmployeeTempController extends Controller { */ @Get("kk1/{id}") public async getKk1Employee(@Path() id: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const profiles = await this.profileRepo.findOne({ // select: [ // "citizenId", @@ -1055,7 +1057,8 @@ export class ProfileEmployeeTempController extends Controller { */ @Get("{id}") async detailProfile(@Path() id: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const profile = await this.profileRepo.findOne({ relations: { posLevel: true, @@ -2941,7 +2944,8 @@ export class ProfileEmployeeTempController extends Controller { */ @Get("information/{profileEmployeeId}") async getInformationById(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const profileInformation = await this.profileRepo.findOne({ where: { id: profileEmployeeId }, }); @@ -2972,7 +2976,8 @@ export class ProfileEmployeeTempController extends Controller { */ @Get("information/history/{profileEmployeeId}") async getInformationHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const profileInformation = await this.informationHistoryRepository.find({ where: { profileEmployeeId: profileEmployeeId }, order: { @@ -2994,7 +2999,8 @@ export class ProfileEmployeeTempController extends Controller { @Path() profileEmployeeId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const employment = await this.employmentRepository.find({ where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, @@ -3016,7 +3022,8 @@ 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"); + let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const employment = await this.employmentRepository.findOne({ where: { id: id }, }); @@ -3032,7 +3039,8 @@ 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"); + let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const employmentHistory = await this.employmentHistoryRepository.find({ where: { profileEmployeeEmploymentId: id }, order: { lastUpdatedAt: "ASC" }, diff --git a/src/controllers/ProfileFamilyCoupleController.ts b/src/controllers/ProfileFamilyCoupleController.ts index e26c6ca7..eb4c27fe 100644 --- a/src/controllers/ProfileFamilyCoupleController.ts +++ b/src/controllers/ProfileFamilyCoupleController.ts @@ -50,7 +50,9 @@ export class ProfileFamilyCoupleController extends Controller { @Get("{profileId}") public async getFamilyCouple(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const profile = await this.profileRepo.findOne({ where: { id: profileId }, }); @@ -113,7 +115,9 @@ export class ProfileFamilyCoupleController extends Controller { @Get("history/{profileId}") public async familyCoupleHistory(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const profile = await this.profileRepo.findOne({ where: { id: profileId }, }); diff --git a/src/controllers/ProfileFamilyCoupleEmployeeController.ts b/src/controllers/ProfileFamilyCoupleEmployeeController.ts index 236bfc27..723ef57f 100644 --- a/src/controllers/ProfileFamilyCoupleEmployeeController.ts +++ b/src/controllers/ProfileFamilyCoupleEmployeeController.ts @@ -44,7 +44,9 @@ export class ProfileFamilyCoupleEmployeeController extends Controller { if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profile.id); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profile.id); const familyCouple = await this.ProfileFamilyCouple.findOne({ where: { profileEmployeeId }, @@ -110,7 +112,9 @@ export class ProfileFamilyCoupleEmployeeController extends Controller { if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profile.id); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profile.id); const familyCouple = await this.ProfileFamilyCouple.find({ relations: ["histories"], diff --git a/src/controllers/ProfileFamilyCoupleEmployeeTempController.ts b/src/controllers/ProfileFamilyCoupleEmployeeTempController.ts index 331cd829..7eb5ee44 100644 --- a/src/controllers/ProfileFamilyCoupleEmployeeTempController.ts +++ b/src/controllers/ProfileFamilyCoupleEmployeeTempController.ts @@ -38,7 +38,8 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller { @Get("{profileEmployeeId}") public async getFamilyCouple(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const profile = await this.profileRepo.findOne({ where: { id: profileEmployeeId }, }); @@ -105,7 +106,8 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller { @Path() profileEmployeeId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const profile = await this.profileRepo.findOne({ where: { id: profileEmployeeId }, }); diff --git a/src/controllers/ProfileFamilyFatherController.ts b/src/controllers/ProfileFamilyFatherController.ts index 2ab32ec5..504eb6cb 100644 --- a/src/controllers/ProfileFamilyFatherController.ts +++ b/src/controllers/ProfileFamilyFatherController.ts @@ -38,7 +38,9 @@ export class ProfileFamilyFatherController extends Controller { @Get("{profileId}") public async getFamilyFather(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const profile = await this.profileRepo.findOne({ where: { id: profileId }, }); @@ -97,7 +99,9 @@ export class ProfileFamilyFatherController extends Controller { @Get("history/{profileId}") public async familyFatherHistory(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const profile = await this.profileRepo.findOne({ where: { id: profileId }, }); diff --git a/src/controllers/ProfileFamilyFatherEmployeeController.ts b/src/controllers/ProfileFamilyFatherEmployeeController.ts index 2fcf5ed0..fec82bd0 100644 --- a/src/controllers/ProfileFamilyFatherEmployeeController.ts +++ b/src/controllers/ProfileFamilyFatherEmployeeController.ts @@ -38,7 +38,9 @@ export class ProfileFamilyFatherEmployeeController extends Controller { @Get("{profileEmployeeId}") public async getFamilyFather(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const profile = await this.profileRepo.findOne({ where: { id: profileEmployeeId }, }); @@ -99,7 +101,9 @@ export class ProfileFamilyFatherEmployeeController extends Controller { @Path() profileEmployeeId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const profile = await this.profileRepo.findOne({ where: { id: profileEmployeeId }, }); diff --git a/src/controllers/ProfileFamilyFatherEmployeeTempController.ts b/src/controllers/ProfileFamilyFatherEmployeeTempController.ts index 6fe38d9b..fa5e7060 100644 --- a/src/controllers/ProfileFamilyFatherEmployeeTempController.ts +++ b/src/controllers/ProfileFamilyFatherEmployeeTempController.ts @@ -38,7 +38,8 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller { @Get("{profileEmployeeId}") public async getFamilyFather(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const profile = await this.profileRepo.findOne({ where: { id: profileEmployeeId }, }); @@ -100,7 +101,8 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller { @Path() profileEmployeeId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const profile = await this.profileRepo.findOne({ where: { id: profileEmployeeId }, }); diff --git a/src/controllers/ProfileFamilyMotherController.ts b/src/controllers/ProfileFamilyMotherController.ts index cf9ce87a..ca042a60 100644 --- a/src/controllers/ProfileFamilyMotherController.ts +++ b/src/controllers/ProfileFamilyMotherController.ts @@ -38,7 +38,9 @@ export class ProfileFamilyMotherController extends Controller { @Get("{profileId}") public async getFamilyMother(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const profile = await this.profileRepo.findOne({ where: { id: profileId }, }); @@ -97,7 +99,9 @@ export class ProfileFamilyMotherController extends Controller { @Get("history/{profileId}") public async familyMotherHistory(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const profile = await this.profileRepo.findOne({ where: { id: profileId }, }); diff --git a/src/controllers/ProfileFamilyMotherEmployeeController.ts b/src/controllers/ProfileFamilyMotherEmployeeController.ts index f0b34986..b9bd15a0 100644 --- a/src/controllers/ProfileFamilyMotherEmployeeController.ts +++ b/src/controllers/ProfileFamilyMotherEmployeeController.ts @@ -38,7 +38,9 @@ export class ProfileFamilyMotherEmployeeController extends Controller { @Get("{profileEmployeeId}") public async getFamilyMother(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const profile = await this.profileRepo.findOne({ where: { id: profileEmployeeId }, }); @@ -100,7 +102,9 @@ export class ProfileFamilyMotherEmployeeController extends Controller { @Path() profileEmployeeId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const profile = await this.profileRepo.findOne({ where: { id: profileEmployeeId }, }); diff --git a/src/controllers/ProfileFamilyMotherEmployeeTempController.ts b/src/controllers/ProfileFamilyMotherEmployeeTempController.ts index 102170b9..576146b1 100644 --- a/src/controllers/ProfileFamilyMotherEmployeeTempController.ts +++ b/src/controllers/ProfileFamilyMotherEmployeeTempController.ts @@ -38,7 +38,8 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller { @Get("{profileEmployeeId}") public async getFamilyMother(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const profile = await this.profileRepo.findOne({ where: { id: profileEmployeeId }, }); @@ -100,7 +101,8 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller { @Path() profileEmployeeId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const profile = await this.profileRepo.findOne({ where: { id: profileEmployeeId }, }); diff --git a/src/controllers/ProfileGovernmentController.ts b/src/controllers/ProfileGovernmentController.ts index 614df3f6..0812511c 100644 --- a/src/controllers/ProfileGovernmentController.ts +++ b/src/controllers/ProfileGovernmentController.ts @@ -138,7 +138,9 @@ export class ProfileGovernmentHistoryController extends Controller { @Get("{profileId}") @Example({}) public async getGovHistory(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const orgRevision = await this.orgRevisionRepository.findOne({ select: ["id"], where: { @@ -357,7 +359,9 @@ export class ProfileGovernmentHistoryController extends Controller { @Get("history/{profileId}") @Example({}) public async govHistory(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const record = await this.govRepo.find({ order: { lastUpdatedAt: "DESC" }, where: { profileId: profileId }, diff --git a/src/controllers/ProfileGovernmentEmployeeController.ts b/src/controllers/ProfileGovernmentEmployeeController.ts index 0ca52f83..f916c4db 100644 --- a/src/controllers/ProfileGovernmentEmployeeController.ts +++ b/src/controllers/ProfileGovernmentEmployeeController.ts @@ -127,7 +127,9 @@ export class ProfileGovernmentEmployeeController extends Controller { @Get("{profileEmployeeId}") @Example({}) public async getGovHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const orgRevision = await this.orgRevisionRepository.findOne({ select: ["id"], where: { @@ -326,7 +328,9 @@ export class ProfileGovernmentEmployeeController extends Controller { @Get("history/{profileEmployeeId}") @Example({}) public async govHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const record = await this.govRepo.find({ order: { lastUpdatedAt: "DESC" }, where: { profileEmployeeId: profileEmployeeId }, diff --git a/src/controllers/ProfileGovernmentEmployeeTempController.ts b/src/controllers/ProfileGovernmentEmployeeTempController.ts index b5b49944..da8f3014 100644 --- a/src/controllers/ProfileGovernmentEmployeeTempController.ts +++ b/src/controllers/ProfileGovernmentEmployeeTempController.ts @@ -127,7 +127,8 @@ export class ProfileGovernmentEmployeeTempController extends Controller { @Get("{profileEmployeeId}") @Example({}) public async getGovHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const orgRevision = await this.orgRevisionRepository.findOne({ select: ["id"], where: { @@ -327,7 +328,8 @@ export class ProfileGovernmentEmployeeTempController extends Controller { @Get("history/{profileEmployeeId}") @Example({}) public async govHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.govRepo.find({ order: { lastUpdatedAt: "DESC" }, where: { profileEmployeeId: profileEmployeeId }, diff --git a/src/controllers/ProfileHonorController.ts b/src/controllers/ProfileHonorController.ts index 904ea180..536161f9 100644 --- a/src/controllers/ProfileHonorController.ts +++ b/src/controllers/ProfileHonorController.ts @@ -44,7 +44,9 @@ export class ProfileHonorController extends Controller { @Get("{profileId}") public async getHonor(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const record = await this.honorRepo.find({ where: { profileId: profileId }, order: { createdAt: "ASC" }, @@ -78,7 +80,9 @@ export class ProfileHonorController extends Controller { public async honorAdminHistory(@Path() honorId: string, @Request() req: RequestWithUser) { const _record = await this.honorRepo.findOneBy({ id: honorId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + let _workflow = await new permission().Workflow(req, honorId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } const record = await this.honorHistoryRepo.find({ where: { diff --git a/src/controllers/ProfileHonorEmployeeController.ts b/src/controllers/ProfileHonorEmployeeController.ts index c2b90631..1d6928ab 100644 --- a/src/controllers/ProfileHonorEmployeeController.ts +++ b/src/controllers/ProfileHonorEmployeeController.ts @@ -48,7 +48,9 @@ export class ProfileHonorEmployeeController extends Controller { @Get("{profileEmployeeId}") public async getHonor(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const record = await this.honorRepo.find({ where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, @@ -82,11 +84,13 @@ export class ProfileHonorEmployeeController extends Controller { public async honorAdminHistory(@Path() honorId: string, @Request() req: RequestWithUser) { const _record = await this.honorRepo.findOneBy({ id: honorId }); if (_record) { - await new permission().PermissionOrgUserGet( - req, - "SYS_REGISTRY_EMP", - _record.profileEmployeeId, - ); + let _workflow = await new permission().Workflow(req, honorId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.honorHistoryRepo.find({ diff --git a/src/controllers/ProfileHonorEmployeeTempController.ts b/src/controllers/ProfileHonorEmployeeTempController.ts index 0d619ae5..fb14c035 100644 --- a/src/controllers/ProfileHonorEmployeeTempController.ts +++ b/src/controllers/ProfileHonorEmployeeTempController.ts @@ -48,7 +48,8 @@ export class ProfileHonorEmployeeTempController extends Controller { @Get("{profileEmployeeId}") public async getHonor(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.honorRepo.find({ where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, @@ -80,7 +81,8 @@ export class ProfileHonorEmployeeTempController extends Controller { @Get("admin/history/{honorId}") public async honorAdminHistory(@Path() honorId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, honorId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.honorHistoryRepo.find({ where: { profileHonorId: honorId, diff --git a/src/controllers/ProfileInsigniaController.ts b/src/controllers/ProfileInsigniaController.ts index 29aae9fe..852de8ec 100644 --- a/src/controllers/ProfileInsigniaController.ts +++ b/src/controllers/ProfileInsigniaController.ts @@ -55,7 +55,9 @@ export class ProfileInsigniaController extends Controller { @Get("{profileId}") public async getInsignia(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const record = await this.insigniaRepo.find({ relations: { insignia: { @@ -75,7 +77,9 @@ export class ProfileInsigniaController extends Controller { ) { const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + let _workflow = await new permission().Workflow(req, InsigniaId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } const record = await this.insigniaHistoryRepo.find({ relations: { diff --git a/src/controllers/ProfileInsigniaEmployeeController.ts b/src/controllers/ProfileInsigniaEmployeeController.ts index d8fa2524..6db83733 100644 --- a/src/controllers/ProfileInsigniaEmployeeController.ts +++ b/src/controllers/ProfileInsigniaEmployeeController.ts @@ -55,7 +55,9 @@ export class ProfileInsigniaEmployeeController extends Controller { @Get("{profileEmployeeId}") public async getInsignia(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const record = await this.insigniaRepo.find({ relations: { insignia: { @@ -75,11 +77,13 @@ export class ProfileInsigniaEmployeeController extends Controller { ) { const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId }); if (_record) { - await new permission().PermissionOrgUserGet( - req, - "SYS_REGISTRY_EMP", - _record.profileEmployeeId, - ); + let _workflow = await new permission().Workflow(req, InsigniaId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.insigniaHistoryRepo.find({ relations: { diff --git a/src/controllers/ProfileInsigniaEmployeeTempController.ts b/src/controllers/ProfileInsigniaEmployeeTempController.ts index 72a4b186..7c353273 100644 --- a/src/controllers/ProfileInsigniaEmployeeTempController.ts +++ b/src/controllers/ProfileInsigniaEmployeeTempController.ts @@ -55,7 +55,8 @@ export class ProfileInsigniaEmployeeTempController extends Controller { @Get("{profileEmployeeId}") public async getInsignia(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.insigniaRepo.find({ relations: { insignia: { @@ -73,7 +74,8 @@ export class ProfileInsigniaEmployeeTempController extends Controller { @Path() InsigniaId: string, @Request() req: RequestWithUser, ) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, InsigniaId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.insigniaHistoryRepo.find({ relations: { insignia: { diff --git a/src/controllers/ProfileLeaveController.ts b/src/controllers/ProfileLeaveController.ts index a6fc4a34..80fcef9f 100644 --- a/src/controllers/ProfileLeaveController.ts +++ b/src/controllers/ProfileLeaveController.ts @@ -127,7 +127,9 @@ export class ProfileLeaveController extends Controller { @Get("{profileId}") public async getLeave(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const record = await this.leaveRepo.find({ relations: { leaveType: true }, where: { profileId }, @@ -138,7 +140,8 @@ export class ProfileLeaveController extends Controller { @Get("admin/{profileId}") public async getLeaveAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_SALARY_OFFICER"); + let _workflow = await new permission().Workflow(req, profileId, "SYS_SALARY_OFFICER"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_SALARY_OFFICER"); const record = await this.leaveRepo.find({ relations: { leaveType: true }, where: { profileId }, @@ -151,7 +154,9 @@ export class ProfileLeaveController extends Controller { public async leaveAdminHistory(@Path() leaveId: string, @Request() req: RequestWithUser) { const _record = await this.leaveRepo.findOneBy({ id: leaveId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + let _workflow = await new permission().Workflow(req, leaveId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } const record = await this.leaveHistoryRepo.find({ relations: { leaveType: true }, diff --git a/src/controllers/ProfileLeaveEmployeeController.ts b/src/controllers/ProfileLeaveEmployeeController.ts index 7cb80d86..f3c010de 100644 --- a/src/controllers/ProfileLeaveEmployeeController.ts +++ b/src/controllers/ProfileLeaveEmployeeController.ts @@ -51,7 +51,9 @@ export class ProfileLeaveEmployeeController extends Controller { @Get("{profileId}") public async getLeave(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); const record = await this.leaveRepo.find({ relations: { leaveType: true }, where: { profileEmployeeId: profileId }, @@ -62,7 +64,8 @@ export class ProfileLeaveEmployeeController extends Controller { @Get("admin/{profileId}") public async getLeaveAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_WAGE"); + let _workflow = await new permission().Workflow(req, profileId, "SYS_WAGE"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_WAGE"); const record = await this.leaveRepo.find({ relations: { leaveType: true }, where: { profileEmployeeId: profileId }, @@ -75,11 +78,13 @@ export class ProfileLeaveEmployeeController extends Controller { public async leaveAdminHistory(@Path() leaveId: string, @Request() req: RequestWithUser) { const _record = await this.leaveRepo.findOneBy({ id: leaveId }); if (_record) { - await new permission().PermissionOrgUserGet( - req, - "SYS_REGISTRY_EMP", - _record.profileEmployeeId, - ); + let _workflow = await new permission().Workflow(req, leaveId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.leaveHistoryRepo.find({ relations: { leaveType: true }, diff --git a/src/controllers/ProfileLeaveEmployeeTempController.ts b/src/controllers/ProfileLeaveEmployeeTempController.ts index 88e75c3a..28d6a621 100644 --- a/src/controllers/ProfileLeaveEmployeeTempController.ts +++ b/src/controllers/ProfileLeaveEmployeeTempController.ts @@ -51,7 +51,8 @@ export class ProfileLeaveEmployeeTempController extends Controller { @Get("{profileId}") public async getLeave(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.leaveRepo.find({ relations: { leaveType: true }, where: { profileEmployeeId: profileId }, @@ -62,7 +63,8 @@ export class ProfileLeaveEmployeeTempController extends Controller { @Get("admin/{profileId}") public async getLeaveAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_WAGE"); + let _workflow = await new permission().Workflow(req, profileId, "SYS_WAGE"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_WAGE"); const record = await this.leaveRepo.find({ relations: { leaveType: true }, where: { profileEmployeeId: profileId }, @@ -73,7 +75,8 @@ export class ProfileLeaveEmployeeTempController extends Controller { @Get("admin/history/{leaveId}") public async leaveAdminHistory(@Path() leaveId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, leaveId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) 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/ProfileNopaidController.ts b/src/controllers/ProfileNopaidController.ts index eaf132b6..ecd4fc9d 100644 --- a/src/controllers/ProfileNopaidController.ts +++ b/src/controllers/ProfileNopaidController.ts @@ -44,7 +44,9 @@ export class ProfileNopaidController extends Controller { @Get("{profileId}") public async getNopaid(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.nopaidRepository.find({ where: { profileId }, order: { createdAt: "ASC" }, @@ -56,7 +58,9 @@ export class ProfileNopaidController extends Controller { public async nopaidHistory(@Path() nopaidId: string, @Request() req: RequestWithUser) { const _record = await this.nopaidRepository.findOneBy({ id: nopaidId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + let _workflow = await new permission().Workflow(req, nopaidId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } const record = await this.nopaidHistoryRepository.find({ where: { profileNopaidId: nopaidId }, diff --git a/src/controllers/ProfileNopaidEmployeeController.ts b/src/controllers/ProfileNopaidEmployeeController.ts index cdd1352c..7f5eb3af 100644 --- a/src/controllers/ProfileNopaidEmployeeController.ts +++ b/src/controllers/ProfileNopaidEmployeeController.ts @@ -48,7 +48,8 @@ export class ProfileNopaidEmployeeController extends Controller { @Get("{profileId}") public async getNopaid(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_EMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_EMP"); const lists = await this.nopaidRepository.find({ where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, @@ -58,7 +59,8 @@ export class ProfileNopaidEmployeeController extends Controller { @Get("history/{nopaidId}") public async nopaidHistory(@Path() nopaidId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, nopaidId, "SYS_REGISTRY_EMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_EMP"); const record = await this.nopaidHistoryRepository.find({ where: { profileNopaidId: nopaidId }, order: { createdAt: "DESC" }, diff --git a/src/controllers/ProfileNopaidEmployeeTempController.ts b/src/controllers/ProfileNopaidEmployeeTempController.ts index 21153965..fca6b1c7 100644 --- a/src/controllers/ProfileNopaidEmployeeTempController.ts +++ b/src/controllers/ProfileNopaidEmployeeTempController.ts @@ -48,7 +48,8 @@ export class ProfileNopaidEmployeeTempController extends Controller { @Get("{profileId}") public async getNopaid(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.nopaidRepository.find({ where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, @@ -58,7 +59,8 @@ export class ProfileNopaidEmployeeTempController extends Controller { @Get("history/{nopaidId}") public async nopaidHistory(@Path() nopaidId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, nopaidId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.nopaidHistoryRepository.find({ where: { profileNopaidId: nopaidId }, order: { createdAt: "DESC" }, diff --git a/src/controllers/ProfileOtherController.ts b/src/controllers/ProfileOtherController.ts index dbf3b038..cf988fd6 100644 --- a/src/controllers/ProfileOtherController.ts +++ b/src/controllers/ProfileOtherController.ts @@ -45,7 +45,9 @@ export class ProfileOtherController extends Controller { @Get("{profileId}") public async getOther(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.otherRepository.find({ where: { profileId: profileId }, order: { createdAt: "ASC" }, @@ -57,7 +59,9 @@ export class ProfileOtherController extends Controller { public async otherAdminHistory(@Path() otherId: string, @Request() req: RequestWithUser) { const _record = await this.otherRepository.findOneBy({ id: otherId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + let _workflow = await new permission().Workflow(req, otherId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } const record = await this.otherHistoryRepository.find({ where: { profileOtherId: otherId }, diff --git a/src/controllers/ProfileOtherEmployeeController.ts b/src/controllers/ProfileOtherEmployeeController.ts index abbfd254..a17ec51a 100644 --- a/src/controllers/ProfileOtherEmployeeController.ts +++ b/src/controllers/ProfileOtherEmployeeController.ts @@ -48,7 +48,9 @@ export class ProfileOtherEmployeeController extends Controller { @Get("{profileId}") public async getOther(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); const lists = await this.otherRepository.find({ where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, @@ -60,11 +62,13 @@ export class ProfileOtherEmployeeController extends Controller { public async otherAdminHistory(@Path() otherId: string, @Request() req: RequestWithUser) { const _record = await this.otherRepository.findOneBy({ id: otherId }); if (_record) { - await new permission().PermissionOrgUserGet( - req, - "SYS_REGISTRY_EMP", - _record.profileEmployeeId, - ); + let _workflow = await new permission().Workflow(req, otherId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.otherHistoryRepository.find({ where: { profileOtherId: otherId }, diff --git a/src/controllers/ProfileOtherEmployeeTempController.ts b/src/controllers/ProfileOtherEmployeeTempController.ts index dfc7b00c..f56287e6 100644 --- a/src/controllers/ProfileOtherEmployeeTempController.ts +++ b/src/controllers/ProfileOtherEmployeeTempController.ts @@ -48,7 +48,8 @@ export class ProfileOtherEmployeeTempController extends Controller { @Get("{profileId}") public async getOther(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.otherRepository.find({ where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, @@ -58,7 +59,8 @@ export class ProfileOtherEmployeeTempController extends Controller { @Get("admin/history/{otherId}") public async otherAdminHistory(@Path() otherId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, otherId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.otherHistoryRepository.find({ where: { profileOtherId: otherId }, order: { createdAt: "DESC" }, diff --git a/src/controllers/ProfileSalaryController.ts b/src/controllers/ProfileSalaryController.ts index 26f2c188..1134b6fb 100644 --- a/src/controllers/ProfileSalaryController.ts +++ b/src/controllers/ProfileSalaryController.ts @@ -45,7 +45,9 @@ export class ProfileSalaryController extends Controller { @Get("{profileId}") public async getSalary(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const record = await this.salaryRepo.find({ where: { profileId: profileId }, order: { order: "ASC" }, @@ -55,7 +57,8 @@ export class ProfileSalaryController extends Controller { @Get("admin/{profileId}") public async getSalaryAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_SALARY_OFFICER"); + let _workflow = await new permission().Workflow(req, profileId, "SYS_SALARY_OFFICER"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_SALARY_OFFICER"); const record = await this.salaryRepo.find({ where: { profileId: profileId }, order: { order: "ASC" }, @@ -67,7 +70,9 @@ export class ProfileSalaryController extends Controller { public async salaryAdminHistory(@Path() salaryId: string, @Request() req: RequestWithUser) { const _record = await this.salaryRepo.findOneBy({ id: salaryId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + let _workflow = await new permission().Workflow(req, salaryId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } const record = await this.salaryHistoryRepo.find({ where: { @@ -208,7 +213,7 @@ export class ProfileSalaryController extends Controller { ) { const source_item = await this.salaryRepo.findOne({ where: { id: salaryId } }); // if (source_item) { - // await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", source_item.profileId);//ไม่แน่ใจOFFปิดไว้ก่อน + //await new permission().PermissionOrgUserGet(req,"SYS_REGISTRY_OFFICER",source_item.profileId,); //ไม่แน่ใจOFFปิดไว้ก่อน // } if (source_item == null) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); const sourceOrder = source_item.order; diff --git a/src/controllers/ProfileSalaryEmployeeController.ts b/src/controllers/ProfileSalaryEmployeeController.ts index bdedc6e4..71763656 100644 --- a/src/controllers/ProfileSalaryEmployeeController.ts +++ b/src/controllers/ProfileSalaryEmployeeController.ts @@ -49,7 +49,9 @@ export class ProfileSalaryEmployeeController extends Controller { @Get("{profileId}") public async getSalaryEmployee(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); const record = await this.salaryRepo.find({ where: { profileEmployeeId: profileId }, order: { order: "ASC" }, @@ -59,7 +61,8 @@ export class ProfileSalaryEmployeeController extends Controller { @Get("admin/{profileId}") public async getSalaryEmployeeAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_WAGE"); + let _workflow = await new permission().Workflow(req, profileId, "SYS_WAGE"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_WAGE"); const record = await this.salaryRepo.find({ where: { profileEmployeeId: profileId }, order: { order: "ASC" }, @@ -71,11 +74,13 @@ export class ProfileSalaryEmployeeController extends Controller { public async salaryAdminHistory(@Path() salaryId: string, @Request() req: RequestWithUser) { const _record = await this.salaryRepo.findOneBy({ id: salaryId }); if (_record) { - await new permission().PermissionOrgUserGet( - req, - "SYS_REGISTRY_EMP", - _record.profileEmployeeId, - ); + let _workflow = await new permission().Workflow(req, salaryId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.salaryHistoryRepo.find({ where: { diff --git a/src/controllers/ProfileSalaryEmployeeTempController.ts b/src/controllers/ProfileSalaryEmployeeTempController.ts index ba9d3935..f4be602a 100644 --- a/src/controllers/ProfileSalaryEmployeeTempController.ts +++ b/src/controllers/ProfileSalaryEmployeeTempController.ts @@ -49,7 +49,8 @@ export class ProfileSalaryEmployeeTempController extends Controller { @Get("{profileId}") public async getSalaryEmployee(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.salaryRepo.find({ where: { profileEmployeeId: profileId }, order: { order: "ASC" }, @@ -59,7 +60,8 @@ export class ProfileSalaryEmployeeTempController extends Controller { @Get("admin/{profileId}") public async getSalaryEmployeeAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_WAGE"); + let _workflow = await new permission().Workflow(req, profileId, "SYS_WAGE"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_WAGE"); const record = await this.salaryRepo.find({ where: { profileEmployeeId: profileId }, order: { order: "ASC" }, @@ -69,7 +71,8 @@ export class ProfileSalaryEmployeeTempController extends Controller { @Get("admin/history/{salaryId}") public async salaryAdminHistory(@Path() salaryId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, salaryId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.salaryHistoryRepo.find({ where: { profileSalaryId: salaryId, diff --git a/src/controllers/ProfileTrainingController.ts b/src/controllers/ProfileTrainingController.ts index adc72cee..0e67a061 100644 --- a/src/controllers/ProfileTrainingController.ts +++ b/src/controllers/ProfileTrainingController.ts @@ -48,7 +48,9 @@ export class ProfileTrainingController extends Controller { @Get("{profileId}") public async getTraining(@Path() profileId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const record = await this.trainingRepo.find({ where: { profileId }, order: { createdAt: "ASC" }, @@ -60,7 +62,9 @@ export class ProfileTrainingController extends Controller { public async trainingAdminHistory(@Path() trainingId: string, @Request() req: RequestWithUser) { const _record = await this.trainingRepo.findOneBy({ id: trainingId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + let _workflow = await new permission().Workflow(req, trainingId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } const record = await this.trainingHistoryRepo.find({ where: { diff --git a/src/controllers/ProfileTrainingEmployeeController.ts b/src/controllers/ProfileTrainingEmployeeController.ts index cd1d0f41..66f5ebb8 100644 --- a/src/controllers/ProfileTrainingEmployeeController.ts +++ b/src/controllers/ProfileTrainingEmployeeController.ts @@ -48,7 +48,9 @@ export class ProfileTrainingEmployeeController extends Controller { @Get("{profileEmployeeId}") public async getTraining(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const record = await this.trainingRepo.find({ where: { profileEmployeeId }, order: { createdAt: "ASC" }, @@ -60,11 +62,13 @@ export class ProfileTrainingEmployeeController extends Controller { public async trainingAdminHistory(@Path() trainingId: string, @Request() req: RequestWithUser) { const _record = await this.trainingRepo.findOneBy({ id: trainingId }); if (_record) { - await new permission().PermissionOrgUserGet( - req, - "SYS_REGISTRY_EMP", - _record.profileEmployeeId, - ); + let _workflow = await new permission().Workflow(req, trainingId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.trainingHistoryRepo.find({ diff --git a/src/controllers/ProfileTrainingEmployeeTempController.ts b/src/controllers/ProfileTrainingEmployeeTempController.ts index 324f60c0..10894d4a 100644 --- a/src/controllers/ProfileTrainingEmployeeTempController.ts +++ b/src/controllers/ProfileTrainingEmployeeTempController.ts @@ -48,7 +48,8 @@ export class ProfileTrainingEmployeeTempController extends Controller { @Get("{profileEmployeeId}") public async getTraining(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.trainingRepo.find({ where: { profileEmployeeId }, order: { createdAt: "ASC" }, @@ -58,7 +59,8 @@ export class ProfileTrainingEmployeeTempController extends Controller { @Get("admin/history/{trainingId}") public async trainingAdminHistory(@Path() trainingId: string, @Request() req: RequestWithUser) { - await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); + let _workflow = await new permission().Workflow(req, trainingId, "SYS_REGISTRY_TEMP"); + if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.trainingHistoryRepo.find({ where: { profileTrainingId: trainingId, diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index 06c70ae6..43ee9bec 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -700,4 +700,37 @@ export class WorkflowController extends Controller { let isOfficer = profileOfficer.orgChild1 == null ? false : profileOfficer.orgChild1.isOfficer; return new HttpSuccess({ isOfficer: isOfficer, isStaff: !isOfficer }); } + + /** + * API เช็ค สกจ + * + * @summary เช็ค สกจ + * + */ + @Post("keycloak/isofficer") + async checkPermissionWorkflow( + @Request() req: RequestWithUser, + @Body() + body: { + refId: string; + sysName: string; + }, + ) { + const profile = await this.profileRepo.findOne({ + where: { + keycloak: req.user.sub, + }, + }); + if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน"); + + const profileOfficer = await this.workflowRepo.findOne({ + where: { + states: { stateUserComments: { profile: { keycloak: req.user.sub } } }, + refId: body.refId, + sysName: body.sysName, + }, + }); + if (!profileOfficer) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลสิทธิ์"); + return new HttpSuccess(); + } } diff --git a/src/entities/OrgRoot.ts b/src/entities/OrgRoot.ts index 47e51706..286a3c4b 100644 --- a/src/entities/OrgRoot.ts +++ b/src/entities/OrgRoot.ts @@ -105,6 +105,12 @@ export class OrgRoot extends EntityBase { }) responsibility: string; + @Column({ + comment: "เป็นปลัด", + default: false, + }) + isDeputy: boolean; + @Column({ length: 40, comment: "คีย์นอก(FK)ของตาราง orgRevision", @@ -164,6 +170,9 @@ export class CreateOrgRoot { @Column("uuid") orgRevisionId: string; + + @Column() + isDeputy: boolean; } export type UpdateOrgRoot = Partial & { orgRootRank?: OrgRootRank }; diff --git a/src/interfaces/permission.ts b/src/interfaces/permission.ts index e063de6b..870d2fed 100644 --- a/src/interfaces/permission.ts +++ b/src/interfaces/permission.ts @@ -54,16 +54,6 @@ class CheckAuth { .GetData(req, `/org/permission/org/${system}/${action}`) .then(async (x) => { let privilege = x.privilege; - // if (action.trim().toLocaleUpperCase() == "CREATE") - // privilege = await this.PermissionCreate(req, system); - // if (action.trim().toLocaleUpperCase() == "DELETE") - // privilege = await this.PermissionDelete(req, system); - // if (action.trim().toLocaleUpperCase() == "GET") - // privilege = await this.PermissionGet(req, system); - // if (action.trim().toLocaleUpperCase() == "LIST") - // privilege = await this.PermissionList(req, system); - // if (action.trim().toLocaleUpperCase() == "UPDATE") - // privilege = await this.PermissionUpdate(req, system); let data: any = { root: [null], @@ -149,16 +139,6 @@ class CheckAuth { .GetData(req, `/org/permission/user/${system}/${action}/${profileId}`) .then(async (x) => { let org = x.org; - // if (action.trim().toLocaleUpperCase() == "CREATE") - // org = await this.PermissionOrgCreate(req, system); - // if (action.trim().toLocaleUpperCase() == "DELETE") - // org = await this.PermissionOrgDelete(req, system); - // if (action.trim().toLocaleUpperCase() == "GET") - // org = await this.PermissionOrgGet(req, system); - // if (action.trim().toLocaleUpperCase() == "LIST") - // org = await this.PermissionOrgList(req, system); - // if (action.trim().toLocaleUpperCase() == "UPDATE") - // org = await this.PermissionOrgUpdate(req, system); if (org.root != null) if (x.orgRootId != org.root[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล"; if (org.child1 != null) @@ -180,6 +160,26 @@ class CheckAuth { } }); } + public async Workflow(req: RequestWithUser, id: string, sysName: string) { + if ( + req.headers.hasOwnProperty("api_key") && + req.headers["api_key"] && + req.headers["api_key"] == process.env.API_KEY + ) { + return null; + } + return await new CallAPI() + .PostData(req, "/org/workflow/keycloak/isofficer", { + refId: id, + sysName: sysName, + }) + .then((x) => { + return true; + }) + .catch((x) => { + return false; + }); + } public async PermissionCreate(req: RequestWithUser, system: string) { return await this.Permission(req, system, "CREATE"); } diff --git a/src/migration/1729505298515-update_root_add_isdeputy.ts b/src/migration/1729505298515-update_root_add_isdeputy.ts new file mode 100644 index 00000000..ba66f09b --- /dev/null +++ b/src/migration/1729505298515-update_root_add_isdeputy.ts @@ -0,0 +1,14 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateRootAddIsdeputy1729505298515 implements MigrationInterface { + name = 'UpdateRootAddIsdeputy1729505298515' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`orgRoot\` ADD \`isDeputy\` tinyint NOT NULL COMMENT 'เป็นปลัด' DEFAULT 0`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`orgRoot\` DROP COLUMN \`isDeputy\``); + } + +}