diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 1bfdd706..ec573e8e 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -6657,6 +6657,39 @@ export class ProfileController extends Controller { return new HttpSuccess(_profile); } + /** + * API ข้อมูลสิทธิ์การแก้ไขทะเบียนประวัติ + * + * @summary ORG_065 - ข้อมูลสิทธิ์การแก้ไขทะเบียนประวัติ + * + */ + @Get("keycloak/permissionProfile/{rootId}") + async getPermissionProfileByRoot( + @Request() request: { user: Record }, + @Path() rootId: string, + ) { + const profile = await this.profileRepo.findOne({ + where: { keycloak: request.user.sub }, + }); + if (!profile) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้"); + } + const permissionProflile = await this.permissionProflileRepository.findOne({ + where: { + profileId: profile.id, + orgRootId: rootId, + }, + }); + + const _profile: any = { + profileId: profile?.id ?? null, + isEdit: permissionProflile?.isEdit ?? false, + isCheck: permissionProflile?.isCheck ?? false, + }; + + return new HttpSuccess(_profile); + } + /** * API ข้อมูลทะเบียนประวัติตาม keycloak * @@ -8932,18 +8965,30 @@ export class ProfileController extends Controller { .orWhere(`orgRoot.orgRootName LIKE :keyword and profile.isProbation = ${isProbation}`, { keyword: `%${body.keyword}%`, }) - .orWhere(`orgChild1.orgChild1Name LIKE :keyword and profile.isProbation = ${isProbation}`, { - keyword: `%${body.keyword}%`, - }) - .orWhere(`orgChild2.orgChild2Name LIKE :keyword and profile.isProbation = ${isProbation}`, { - keyword: `%${body.keyword}%`, - }) - .orWhere(`orgChild3.orgChild3Name LIKE :keyword and profile.isProbation = ${isProbation}`, { - keyword: `%${body.keyword}%`, - }) - .orWhere(`orgChild4.orgChild4Name LIKE :keyword and profile.isProbation = ${isProbation}`, { - keyword: `%${body.keyword}%`, - }); + .orWhere( + `orgChild1.orgChild1Name LIKE :keyword and profile.isProbation = ${isProbation}`, + { + keyword: `%${body.keyword}%`, + }, + ) + .orWhere( + `orgChild2.orgChild2Name LIKE :keyword and profile.isProbation = ${isProbation}`, + { + keyword: `%${body.keyword}%`, + }, + ) + .orWhere( + `orgChild3.orgChild3Name LIKE :keyword and profile.isProbation = ${isProbation}`, + { + keyword: `%${body.keyword}%`, + }, + ) + .orWhere( + `orgChild4.orgChild4Name LIKE :keyword and profile.isProbation = ${isProbation}`, + { + keyword: `%${body.keyword}%`, + }, + ); }), ) .orderBy("profile.citizenId", "ASC")