From 85657d1c3224ae5db4f2c06de24c4d7d4ab50c5a Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 3 Oct 2024 15:37:28 +0700 Subject: [PATCH] add isBlank --- src/controllers/OrganizationController.ts | 3 ++- src/controllers/PermissionOrgController.ts | 30 +++++++++++----------- src/controllers/PositionController.ts | 24 +++++++++++++++-- 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 7f151dd7..a07b20f4 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -621,7 +621,8 @@ export class OrganizationController extends Controller { // let attrOwnership = null; if ( orgRevision.orgRevisionIsDraft == true && - orgRevision.orgRevisionIsCurrent == false + orgRevision.orgRevisionIsCurrent == false && + request.user.role.includes("SUPER_ADMIN") // attrOwnership == false ) { const profile = await this.profileRepo.findOne({ diff --git a/src/controllers/PermissionOrgController.ts b/src/controllers/PermissionOrgController.ts index 1150f6cd..9cd157f5 100644 --- a/src/controllers/PermissionOrgController.ts +++ b/src/controllers/PermissionOrgController.ts @@ -48,9 +48,9 @@ export class PermissionOrgController extends Controller { */ @Get() async GetActiveRootIdAdmin(@Request() request: RequestWithUser) { - if (!request.user.role.includes("SUPER_ADMIN")) { - throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); - } + // if (!request.user.role.includes("SUPER_ADMIN")) { + // throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); + // } const orgRevisionActive = await this.orgRevisionRepository.findOne({ where: { orgRevisionIsCurrent: false, orgRevisionIsDraft: true }, }); @@ -76,9 +76,9 @@ export class PermissionOrgController extends Controller { searchField?: "fullName" | "position" | "posNo" | "postype" | "poslevel", @Query() searchKeyword: string = "", ) { - if (!request.user.role.includes("SUPER_ADMIN")) { - throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); - } + // if (!request.user.role.includes("SUPER_ADMIN")) { + // throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); + // } let queryLike = "CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword"; if (searchField == "postype") { @@ -233,9 +233,9 @@ export class PermissionOrgController extends Controller { searchKeyword: string; }, ) { - if (!request.user.role.includes("SUPER_ADMIN")) { - throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); - } + // if (!request.user.role.includes("SUPER_ADMIN")) { + // throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); + // } let profiles: any = []; if (requestBody.id != null) { const _permissionOrg = await this.orgRootRepository.findOne({ @@ -423,9 +423,9 @@ export class PermissionOrgController extends Controller { @Request() request: RequestWithUser, @Body() requestBody: { nodeId: string; personId: string }, ) { - if (!request.user.role.includes("SUPER_ADMIN")) { - throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); - } + // if (!request.user.role.includes("SUPER_ADMIN")) { + // throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); + // } const orgRoot = await this.orgRootRepository.findOne({ where: { id: requestBody.nodeId }, }); @@ -472,9 +472,9 @@ export class PermissionOrgController extends Controller { */ @Delete("{id}") async Delete(@Request() request: RequestWithUser, @Path() id: string) { - if (!request.user.role.includes("SUPER_ADMIN")) { - throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); - } + // if (!request.user.role.includes("SUPER_ADMIN")) { + // throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); + // } // const orgRoot = await this.orgRootRepository.findOne({ // where: { id: nodeId }, // relations: ["permissionOrgRoots"], diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 646276cf..de22564a 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -840,9 +840,13 @@ export class PositionController extends Controller { } let _null: any = null; posMaster.isDirector = requestBody.isDirector; - posMaster.isStaff = requestBody.isStaff == null || requestBody.isStaff == undefined ? _null : requestBody.isStaff; + posMaster.isStaff = + requestBody.isStaff == null || requestBody.isStaff == undefined ? _null : requestBody.isStaff; // posMaster.isOfficer = requestBody.isOfficer; - posMaster.positionSign = requestBody.positionSign == null || requestBody.positionSign == undefined ? _null : requestBody.positionSign; + posMaster.positionSign = + requestBody.positionSign == null || requestBody.positionSign == undefined + ? _null + : requestBody.positionSign; posMaster.posMasterNo = requestBody.posMasterNo; posMaster.posMasterNoPrefix = requestBody.posMasterNoPrefix; posMaster.posMasterNoSuffix = requestBody.posMasterNoSuffix; @@ -1101,6 +1105,7 @@ export class PositionController extends Controller { revisionId: string; type: number; isAll: boolean; + isBlank: boolean; page: number; pageSize: number; keyword?: string; @@ -1127,6 +1132,9 @@ export class PositionController extends Controller { searchShortName = `CONCAT(orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } + if (body.isBlank == true) { + typeCondition.current_holderId = IsNull(); + } } else if (body.type === 1) { typeCondition = { orgChild1Id: body.id, @@ -1138,6 +1146,9 @@ export class PositionController extends Controller { searchShortName = `CONCAT(orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } + if (body.isBlank == true) { + typeCondition.current_holderId = IsNull(); + } } else if (body.type === 2) { typeCondition = { orgChild2Id: body.id, @@ -1149,6 +1160,9 @@ export class PositionController extends Controller { searchShortName = `CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } + if (body.isBlank == true) { + typeCondition.current_holderId = IsNull(); + } } else if (body.type === 3) { typeCondition = { orgChild3Id: body.id, @@ -1160,11 +1174,17 @@ export class PositionController extends Controller { searchShortName = `CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } + if (body.isBlank == true) { + typeCondition.current_holderId = IsNull(); + } } else if (body.type === 4) { typeCondition = { orgChild4Id: body.id, }; searchShortName = `CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + if (body.isBlank == true) { + typeCondition.current_holderId = IsNull(); + } } let findPosition: any; let masterId = new Array();