add isBlank

This commit is contained in:
kittapath 2024-10-03 15:37:28 +07:00
parent e805759af5
commit 85657d1c32
3 changed files with 39 additions and 18 deletions

View file

@ -621,7 +621,8 @@ export class OrganizationController extends Controller {
// let attrOwnership = null; // let attrOwnership = null;
if ( if (
orgRevision.orgRevisionIsDraft == true && orgRevision.orgRevisionIsDraft == true &&
orgRevision.orgRevisionIsCurrent == false orgRevision.orgRevisionIsCurrent == false &&
request.user.role.includes("SUPER_ADMIN")
// attrOwnership == false // attrOwnership == false
) { ) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({

View file

@ -48,9 +48,9 @@ export class PermissionOrgController extends Controller {
*/ */
@Get() @Get()
async GetActiveRootIdAdmin(@Request() request: RequestWithUser) { async GetActiveRootIdAdmin(@Request() request: RequestWithUser) {
if (!request.user.role.includes("SUPER_ADMIN")) { // if (!request.user.role.includes("SUPER_ADMIN")) {
throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); // throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้");
} // }
const orgRevisionActive = await this.orgRevisionRepository.findOne({ const orgRevisionActive = await this.orgRevisionRepository.findOne({
where: { orgRevisionIsCurrent: false, orgRevisionIsDraft: true }, where: { orgRevisionIsCurrent: false, orgRevisionIsDraft: true },
}); });
@ -76,9 +76,9 @@ export class PermissionOrgController extends Controller {
searchField?: "fullName" | "position" | "posNo" | "postype" | "poslevel", searchField?: "fullName" | "position" | "posNo" | "postype" | "poslevel",
@Query() searchKeyword: string = "", @Query() searchKeyword: string = "",
) { ) {
if (!request.user.role.includes("SUPER_ADMIN")) { // if (!request.user.role.includes("SUPER_ADMIN")) {
throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); // throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้");
} // }
let queryLike = let queryLike =
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword"; "CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
if (searchField == "postype") { if (searchField == "postype") {
@ -233,9 +233,9 @@ export class PermissionOrgController extends Controller {
searchKeyword: string; searchKeyword: string;
}, },
) { ) {
if (!request.user.role.includes("SUPER_ADMIN")) { // if (!request.user.role.includes("SUPER_ADMIN")) {
throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); // throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้");
} // }
let profiles: any = []; let profiles: any = [];
if (requestBody.id != null) { if (requestBody.id != null) {
const _permissionOrg = await this.orgRootRepository.findOne({ const _permissionOrg = await this.orgRootRepository.findOne({
@ -423,9 +423,9 @@ export class PermissionOrgController extends Controller {
@Request() request: RequestWithUser, @Request() request: RequestWithUser,
@Body() requestBody: { nodeId: string; personId: string }, @Body() requestBody: { nodeId: string; personId: string },
) { ) {
if (!request.user.role.includes("SUPER_ADMIN")) { // if (!request.user.role.includes("SUPER_ADMIN")) {
throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); // throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้");
} // }
const orgRoot = await this.orgRootRepository.findOne({ const orgRoot = await this.orgRootRepository.findOne({
where: { id: requestBody.nodeId }, where: { id: requestBody.nodeId },
}); });
@ -472,9 +472,9 @@ export class PermissionOrgController extends Controller {
*/ */
@Delete("{id}") @Delete("{id}")
async Delete(@Request() request: RequestWithUser, @Path() id: string) { async Delete(@Request() request: RequestWithUser, @Path() id: string) {
if (!request.user.role.includes("SUPER_ADMIN")) { // if (!request.user.role.includes("SUPER_ADMIN")) {
throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); // throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้");
} // }
// const orgRoot = await this.orgRootRepository.findOne({ // const orgRoot = await this.orgRootRepository.findOne({
// where: { id: nodeId }, // where: { id: nodeId },
// relations: ["permissionOrgRoots"], // relations: ["permissionOrgRoots"],

View file

@ -840,9 +840,13 @@ export class PositionController extends Controller {
} }
let _null: any = null; let _null: any = null;
posMaster.isDirector = requestBody.isDirector; 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.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.posMasterNo = requestBody.posMasterNo;
posMaster.posMasterNoPrefix = requestBody.posMasterNoPrefix; posMaster.posMasterNoPrefix = requestBody.posMasterNoPrefix;
posMaster.posMasterNoSuffix = requestBody.posMasterNoSuffix; posMaster.posMasterNoSuffix = requestBody.posMasterNoSuffix;
@ -1101,6 +1105,7 @@ export class PositionController extends Controller {
revisionId: string; revisionId: string;
type: number; type: number;
isAll: boolean; isAll: boolean;
isBlank: boolean;
page: number; page: number;
pageSize: number; pageSize: number;
keyword?: string; keyword?: string;
@ -1127,6 +1132,9 @@ export class PositionController extends Controller {
searchShortName = `CONCAT(orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; searchShortName = `CONCAT(orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
} else { } else {
} }
if (body.isBlank == true) {
typeCondition.current_holderId = IsNull();
}
} else if (body.type === 1) { } else if (body.type === 1) {
typeCondition = { typeCondition = {
orgChild1Id: body.id, 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}%'`; searchShortName = `CONCAT(orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
} else { } else {
} }
if (body.isBlank == true) {
typeCondition.current_holderId = IsNull();
}
} else if (body.type === 2) { } else if (body.type === 2) {
typeCondition = { typeCondition = {
orgChild2Id: body.id, 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}%'`; searchShortName = `CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
} else { } else {
} }
if (body.isBlank == true) {
typeCondition.current_holderId = IsNull();
}
} else if (body.type === 3) { } else if (body.type === 3) {
typeCondition = { typeCondition = {
orgChild3Id: body.id, 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}%'`; searchShortName = `CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
} else { } else {
} }
if (body.isBlank == true) {
typeCondition.current_holderId = IsNull();
}
} else if (body.type === 4) { } else if (body.type === 4) {
typeCondition = { typeCondition = {
orgChild4Id: body.id, orgChild4Id: body.id,
}; };
searchShortName = `CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; 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 findPosition: any;
let masterId = new Array(); let masterId = new Array();