From 48805224976faf02f3d0827a9b8802f048194343 Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 15 Nov 2024 09:29:24 +0700 Subject: [PATCH] download kk1 --- src/controllers/ProfileController.ts | 22 ++++--------------- src/controllers/ProfileEmployeeController.ts | 12 +++------- .../ProfileEmployeeTempController.ts | 10 +++------ 3 files changed, 10 insertions(+), 34 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index a4572d10..8cea8b36 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -106,7 +106,6 @@ export class ProfileController extends Controller { private districtRepo = AppDataSource.getRepository(District); private subDistrictRepo = AppDataSource.getRepository(SubDistrict); private profileInsigniaRepo = AppDataSource.getRepository(ProfileInsignia); - private profileDisciplineRepo = AppDataSource.getRepository(ProfileDiscipline); private profileLeaveRepository = AppDataSource.getRepository(ProfileLeave); private posMasterActRepository = AppDataSource.getRepository(PosMasterAct); @@ -119,7 +118,6 @@ 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); const orgRevision = await this.orgRevisionRepo.findOne({ where: { orgRevisionIsCurrent: true }, }); @@ -299,20 +297,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); const profiles = await this.profileRepo.findOne({ - // select: [ - // "citizenId", - // "prefix", - // "firstName", - // "lastName", - // "birthDate", - // "currentAddress", - // "currentDistrictId", - // "currentProvinceId", - // "telephoneNumber", - // "avatar", - // ], relations: ["currentSubDistrict", "currentDistrict", "currentProvince", "profileAvatars"], order: { profileAvatars: { createdAt: "ASC" }, @@ -5785,9 +5770,10 @@ export class ProfileController extends Controller { child4ShortName: child4 == null ? null : child4.orgChild4ShortName, node: null, nodeId: null, - education: profile && profile.profileEducations.length > 0 - ? `${profile.profileEducations[0].degree ?? ""}/${profile.profileEducations[0].field ?? ""}` - : "-", + education: + profile && profile.profileEducations.length > 0 + ? `${profile.profileEducations[0].degree ?? ""}/${profile.profileEducations[0].field ?? ""}` + : "-", }; if (_profile.child4Id != null) { diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 1c5cce09..035dc241 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -143,7 +143,7 @@ export class ProfileEmployeeController extends Controller { }); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_EMP"); - if (_workflow == false) + if (_workflow == false && req.user.sub != profile.keycloak) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profile.id); let ImgUrl: any; if (profile?.avatar != null && profile?.avatarName != null) { @@ -292,8 +292,6 @@ export class ProfileEmployeeController extends Controller { reportName: "docx-report", data: mapData, }); - - return new HttpSuccess(mapData); } /** @@ -312,13 +310,8 @@ export class ProfileEmployeeController extends Controller { }, where: { id: id }, }); - if (profiles) { - 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; + let ImgUrl: any = null; let _ImgUrl: any = []; if (profiles?.avatar != null && profiles?.avatarName != null) { // await new CallAPI() @@ -327,6 +320,7 @@ export class ProfileEmployeeController extends Controller { // ImgUrl = x.downloadUrl; // }) // .catch(); + let req_: any = req; const token_ = "Bearer " + req_.headers.authorization.replace("Bearer ", ""); diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 21ea1568..029110e8 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -140,7 +140,7 @@ export class ProfileEmployeeTempController extends Controller { }); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_TEMP"); - if (_workflow == false) + if (_workflow == false && req.user.sub != profile.keycloak) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_TEMP", profile.id); let ImgUrl: any; if (profile?.avatar != null && profile?.avatarName != null) { @@ -307,13 +307,8 @@ export class ProfileEmployeeTempController extends Controller { }, where: { id: id }, }); - if (profiles) { - let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_TEMP"); - if (_workflow == false) - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_TEMP", profiles.id); - } if (!profiles) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - let ImgUrl: any; + let ImgUrl: any = null; let _ImgUrl: any = []; if (profiles?.avatar != null && profiles?.avatarName != null) { // await new CallAPI() @@ -322,6 +317,7 @@ export class ProfileEmployeeTempController extends Controller { // ImgUrl = x.downloadUrl; // }) // .catch(); + let req_: any = req; const token_ = "Bearer " + req_.headers.authorization.replace("Bearer ", "");