From 4641362b950b50fde6ab7c7c9acbd09f3054b532 Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 13 Sep 2024 10:29:08 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=94=E0=B8=B9=E0=B9=81=E0=B8=9A=E0=B8=9A?= =?UTF-8?q?=E0=B8=A3=E0=B9=88=E0=B8=B2=E0=B8=87=20owner?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/EmployeePositionController.ts | 6 +- src/controllers/OrganizationController.ts | 30 ++++----- src/controllers/PositionController.ts | 61 ++++++++++++------- src/entities/EmployeePosMaster.ts | 14 ++--- src/entities/PosMaster.ts | 14 ++--- 5 files changed, 72 insertions(+), 53 deletions(-) diff --git a/src/controllers/EmployeePositionController.ts b/src/controllers/EmployeePositionController.ts index 7c9a1857..1dc17ee8 100644 --- a/src/controllers/EmployeePositionController.ts +++ b/src/controllers/EmployeePositionController.ts @@ -253,7 +253,7 @@ export class EmployeePositionController extends Controller { posMasterNo: posMaster.posMasterNo, posMasterNoSuffix: posMaster.posMasterNoSuffix, reason: posMaster.reason, - isOfficer: posMaster.isOfficer, + // isOfficer: posMaster.isOfficer, isStaff: posMaster.isStaff, isDirector: posMaster.isDirector, positionSign: posMaster.positionSign, @@ -630,12 +630,12 @@ export class EmployeePositionController extends Controller { if (!posMaster) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลอัตรากำลัง"); } - let _null:any = null; + let _null: any = null; posMaster.posMasterNo = requestBody.posMasterNo; posMaster.isDirector = requestBody.isDirector; posMaster.isStaff = requestBody.isStaff; posMaster.positionSign = requestBody.positionSign == null ? _null : requestBody.positionSign; - posMaster.isOfficer = requestBody.isOfficer; + // posMaster.isOfficer = requestBody.isOfficer; posMaster.posMasterNoPrefix = requestBody.posMasterNoPrefix; posMaster.posMasterNoSuffix = requestBody.posMasterNoSuffix; posMaster.reason = requestBody.reason == null ? "" : requestBody.reason; diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 93d73333..75727d68 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -626,21 +626,23 @@ export class OrganizationController extends Controller { _data = await new permission().PermissionOrgList(request, "SYS_ORG"); } - if (orgRevision.orgRevisionIsDraft == true && orgRevision.orgRevisionIsCurrent == false) { - const profile = await this.profileRepo.findOne({ - where: { keycloak: request.user.sub }, - relations: ["permissionProfiles"], - }); - if (!profile) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งานในทะเบียนประวัติ"); + if (_data.root != null) { + if (orgRevision.orgRevisionIsDraft == true && orgRevision.orgRevisionIsCurrent == false) { + const profile = await this.profileRepo.findOne({ + where: { keycloak: request.user.sub }, + relations: ["permissionProfiles"], + }); + if (!profile) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งานในทะเบียนประวัติ"); + } + _data = { + root: [profile.permissionProfiles.map((x) => x.orgRootId)], + child1: null, + child2: null, + child3: null, + child4: null, + }; } - _data = { - root: profile.permissionProfiles.map((x) => x.orgRootId), - child1: null, - child2: null, - child3: null, - child4: null, - }; } const orgRootData = await AppDataSource.getRepository(OrgRoot) diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index dd981f15..443c42bb 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -451,23 +451,40 @@ export class PositionController extends Controller { order: { posDictName: "ASC" }, }); break; - - case "ALL": - findPosDict = await this.posDictRepository.find({ - where: [ - { posDictName: Like(`%${keyword}%`) }, - { posDictField: Like(`%${keyword}%`) }, - { posTypeId: In(await this.posTypeRepository.find({ where: { posTypeName: Like(`%${keyword}%`) }, select: ["id"] }).then(types => types.map(type => type.id))) }, - { posLevelId: In(await this.posLevelRepository.find({ where: { posLevelName: Like(`%${keyword}%`) }, select: ["id"] }).then(levels => levels.map(level => level.id))) }, - { posExecutiveId: In(await this.posExecutiveRepository.find({ where: { posExecutiveName: Like(`%${keyword}%`) }, select: ["id"] }).then(executives => executives.map(exec => exec.id))) }, - { posDictExecutiveField: Like(`%${keyword}%`) }, - { posDictArea: Like(`%${keyword}%`) } - ], - relations: ["posType", "posLevel", "posExecutive"], - order: { posDictName: "ASC" }, - }); - break; + case "ALL": + findPosDict = await this.posDictRepository.find({ + where: [ + { posDictName: Like(`%${keyword}%`) }, + { posDictField: Like(`%${keyword}%`) }, + { + posTypeId: In( + await this.posTypeRepository + .find({ where: { posTypeName: Like(`%${keyword}%`) }, select: ["id"] }) + .then((types) => types.map((type) => type.id)), + ), + }, + { + posLevelId: In( + await this.posLevelRepository + .find({ where: { posLevelName: Like(`%${keyword}%`) }, select: ["id"] }) + .then((levels) => levels.map((level) => level.id)), + ), + }, + { + posExecutiveId: In( + await this.posExecutiveRepository + .find({ where: { posExecutiveName: Like(`%${keyword}%`) }, select: ["id"] }) + .then((executives) => executives.map((exec) => exec.id)), + ), + }, + { posDictExecutiveField: Like(`%${keyword}%`) }, + { posDictArea: Like(`%${keyword}%`) }, + ], + relations: ["posType", "posLevel", "posExecutive"], + order: { posDictName: "ASC" }, + }); + break; default: findPosDict = await this.posDictRepository.find({ @@ -821,10 +838,10 @@ export class PositionController extends Controller { if (!posMaster) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลอัตรากำลัง"); } - let _null:any = null; + let _null: any = null; posMaster.isDirector = requestBody.isDirector; posMaster.isStaff = requestBody.isStaff; - posMaster.isOfficer = requestBody.isOfficer; + // posMaster.isOfficer = requestBody.isOfficer; posMaster.positionSign = requestBody.positionSign == null ? _null : requestBody.positionSign; posMaster.posMasterNo = requestBody.posMasterNo; posMaster.posMasterNoPrefix = requestBody.posMasterNoPrefix; @@ -1023,7 +1040,7 @@ export class PositionController extends Controller { posMasterNo: posMaster.posMasterNo, posMasterNoSuffix: posMaster.posMasterNoSuffix, reason: posMaster.reason, - isOfficer: posMaster.isOfficer, + // isOfficer: posMaster.isOfficer, isStaff: posMaster.isStaff, isDirector: posMaster.isDirector, positionSign: posMaster.positionSign, @@ -1591,8 +1608,8 @@ export class PositionController extends Controller { * @param {string} id Id อัตรากำลัง */ @Get("history/{id}") - async getHistoryPosMater(@Path() id: string , @Request() request: RequestWithUser) { - await new permission().PermissionGet(request , "SYS_ORG"); + async getHistoryPosMater(@Path() id: string, @Request() request: RequestWithUser) { + await new permission().PermissionGet(request, "SYS_ORG"); const posMaster = await this.posMasterRepository.findOne({ where: { id }, }); @@ -3328,7 +3345,7 @@ export class PositionController extends Controller { isAll: boolean; }, ) { - await new permission().PermissionGet(request,"SYS_ACTING"); + await new permission().PermissionGet(request, "SYS_ACTING"); const posMasterMain = await this.posMasterRepository.findOne({ where: { id: body.posmasterId }, relations: ["posMasterActs"], diff --git a/src/entities/EmployeePosMaster.ts b/src/entities/EmployeePosMaster.ts index 2c1ebbbb..bb2c8881 100644 --- a/src/entities/EmployeePosMaster.ts +++ b/src/entities/EmployeePosMaster.ts @@ -99,11 +99,11 @@ export class EmployeePosMaster extends EntityBase { }) isStaff: boolean; - @Column({ - comment: "เป็นสกจ", - default: false, - }) - isOfficer: boolean; + // @Column({ + // comment: "เป็นสกจ", + // default: false, + // }) + // isOfficer: boolean; @Column({ nullable: true, @@ -270,8 +270,8 @@ export class CreateEmployeePosMaster { @Column() isStaff: boolean; - @Column() - isOfficer: boolean; + // @Column() + // isOfficer: boolean; @Column() positionSign: string | null; diff --git a/src/entities/PosMaster.ts b/src/entities/PosMaster.ts index 2d27a911..4935b2f6 100644 --- a/src/entities/PosMaster.ts +++ b/src/entities/PosMaster.ts @@ -100,11 +100,11 @@ export class PosMaster extends EntityBase { }) isStaff: boolean; - @Column({ - comment: "เป็นสกจ", - default: false, - }) - isOfficer: boolean; + // @Column({ + // comment: "เป็นสกจ", + // default: false, + // }) + // isOfficer: boolean; @Column({ nullable: true, @@ -277,8 +277,8 @@ export class CreatePosMaster { @Column() isStaff: boolean; - @Column() - isOfficer: boolean; + // @Column() + // isOfficer: boolean; @Column() positionSign: string | null;