Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
This commit is contained in:
commit
5e526b63e0
2 changed files with 39 additions and 18 deletions
|
|
@ -192,21 +192,21 @@ export class PermissionController extends Controller {
|
||||||
/**
|
/**
|
||||||
* API permission (dotnet api)
|
* API permission (dotnet api)
|
||||||
* @summary permission (dotnet api)
|
* @summary permission (dotnet api)
|
||||||
* @param {string} method Method
|
* @param {string} action action
|
||||||
* @param {string} system authSysId
|
* @param {string} system authSysId
|
||||||
*/
|
*/
|
||||||
@Get("dotnet/{method}/{system}")
|
@Get("dotnet/{action}/{system}")
|
||||||
public async dotnet(
|
public async dotnet(
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
@Path() method: string,
|
@Path() action: string,
|
||||||
@Path() system: string
|
@Path() system: string
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if(!["CREATE", "DELETE", "GET", "LIST", "UPDATE"].includes(method)) {
|
if(!["CREATE", "DELETE", "GET", "LIST", "UPDATE"].includes(action)) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "Method ไม่ถูกต้อง");
|
throw new HttpError(HttpStatus.NOT_FOUND, "Action ไม่ถูกต้อง");
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = await new permission().Permission(req, system.toLocaleUpperCase(), method);
|
let res = await new permission().Permission(req, system.toLocaleUpperCase(), action);
|
||||||
return new HttpSuccess(res);
|
return new HttpSuccess(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2559,13 +2559,15 @@ export class ProfileController extends Controller {
|
||||||
async listProfile(
|
async listProfile(
|
||||||
@Query("page") page: number = 1,
|
@Query("page") page: number = 1,
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Query() searchField?: "firstName" | "lastName" | "fullName" | "citizenId" | "position",
|
@Query() searchField?: "firstName" | "lastName" | "fullName" | "citizenId" | "position" | "posNo",
|
||||||
@Query() searchKeyword: string = "",
|
@Query() searchKeyword: string = "",
|
||||||
@Query() posType?: string,
|
@Query() posType?: string,
|
||||||
@Query() posLevel?: string,
|
@Query() posLevel?: string,
|
||||||
@Query() yearLeave?: number,
|
@Query() yearLeave?: number,
|
||||||
@Query() isProbation?: boolean,
|
@Query() isProbation?: boolean,
|
||||||
@Query() isRetire?: boolean,
|
@Query() isRetire?: boolean,
|
||||||
|
@Query() node?: number,
|
||||||
|
@Query() nodeId?: string,
|
||||||
) {
|
) {
|
||||||
let queryLike =
|
let queryLike =
|
||||||
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
||||||
|
|
@ -2573,6 +2575,27 @@ export class ProfileController extends Controller {
|
||||||
queryLike = "profile.citizenId LIKE :keyword";
|
queryLike = "profile.citizenId LIKE :keyword";
|
||||||
} else if (searchField == "position") {
|
} else if (searchField == "position") {
|
||||||
queryLike = "profile.position LIKE :keyword";
|
queryLike = "profile.position LIKE :keyword";
|
||||||
|
} else if (searchField == "posNo") {
|
||||||
|
queryLike = `CONCAT(
|
||||||
|
IFNULL(orgChild4.orgChild4ShortName, ''),
|
||||||
|
IFNULL(orgChild3.orgChild3ShortName, ''),
|
||||||
|
IFNULL(orgChild2.orgChild2ShortName, ''),
|
||||||
|
IFNULL(orgChild1.orgChild1ShortName, ''),
|
||||||
|
IFNULL(orgRoot.orgRootShortName, ''),
|
||||||
|
IFNULL(current_holders.posMasterNo , '')
|
||||||
|
) LIKE :keyword`;
|
||||||
|
}
|
||||||
|
let nodeCondition = "1=1";
|
||||||
|
if (node === 0 && nodeId) {
|
||||||
|
nodeCondition = "current_holders.orgRootId = :nodeId";
|
||||||
|
} else if (node === 1 && nodeId) {
|
||||||
|
nodeCondition = "current_holders.orgChild1Id = :nodeId";
|
||||||
|
} else if (node === 2 && nodeId) {
|
||||||
|
nodeCondition = "current_holders.orgChild2Id = :nodeId";
|
||||||
|
} else if (node === 3 && nodeId) {
|
||||||
|
nodeCondition = "current_holders.orgChild3Id = :nodeId";
|
||||||
|
} else if (node === 4 && nodeId) {
|
||||||
|
nodeCondition = "current_holders.orgChild4Id = :nodeId";
|
||||||
}
|
}
|
||||||
const [record, total] = await this.profileRepo
|
const [record, total] = await this.profileRepo
|
||||||
.createQueryBuilder("profile")
|
.createQueryBuilder("profile")
|
||||||
|
|
@ -2622,9 +2645,13 @@ export class ProfileController extends Controller {
|
||||||
keyword: `%${searchKeyword}%`,
|
keyword: `%${searchKeyword}%`,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
.andWhere(nodeCondition, {
|
||||||
|
nodeId: nodeId,
|
||||||
|
})
|
||||||
.skip((page - 1) * pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.take(pageSize)
|
.take(pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
||||||
const findRevision = await this.orgRevisionRepo.findOne({
|
const findRevision = await this.orgRevisionRepo.findOne({
|
||||||
where: { orgRevisionIsCurrent: true },
|
where: { orgRevisionIsCurrent: true },
|
||||||
});
|
});
|
||||||
|
|
@ -4221,7 +4248,8 @@ export class ProfileController extends Controller {
|
||||||
keyword?: string;
|
keyword?: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const [firstName, lastName] = body.keyword ? body.keyword.split(" ") : ["", ""];
|
let conditionFullName =
|
||||||
|
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
||||||
const [findProfile, total] = await AppDataSource.getRepository(Profile)
|
const [findProfile, total] = await AppDataSource.getRepository(Profile)
|
||||||
.createQueryBuilder("profile")
|
.createQueryBuilder("profile")
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
|
|
@ -4253,16 +4281,9 @@ export class ProfileController extends Controller {
|
||||||
.orWhere(`posType.posTypeName LIKE :keyword`, {
|
.orWhere(`posType.posTypeName LIKE :keyword`, {
|
||||||
keyword: `%${body.keyword}%`,
|
keyword: `%${body.keyword}%`,
|
||||||
})
|
})
|
||||||
.orWhere(
|
.orWhere(conditionFullName, {
|
||||||
new Brackets((qb) => {
|
keyword: `%${body.keyword}%`,
|
||||||
if (body.keyword) {
|
})
|
||||||
qb.where(`profile.firstName LIKE :firstName`, { firstName: `%${firstName}%` }).orWhere(
|
|
||||||
`profile.lastName LIKE :lastName`,
|
|
||||||
{ lastName: `%${lastName}%` },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.orderBy("profile.citizenId", "ASC")
|
.orderBy("profile.citizenId", "ASC")
|
||||||
.skip((body.page - 1) * body.pageSize)
|
.skip((body.page - 1) * body.pageSize)
|
||||||
.take(body.pageSize)
|
.take(body.pageSize)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue