This commit is contained in:
parent
78778e0eb0
commit
6e6253887f
1 changed files with 35 additions and 11 deletions
|
|
@ -472,9 +472,9 @@ export class KeycloakController extends Controller {
|
||||||
|
|
||||||
@Post("user/admin")
|
@Post("user/admin")
|
||||||
async listUserKeycloak(
|
async listUserKeycloak(
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
@Body()
|
@Body()
|
||||||
body:{
|
body: {
|
||||||
page: number,
|
page: number,
|
||||||
pageSize: number,
|
pageSize: number,
|
||||||
keyword: string | null,
|
keyword: string | null,
|
||||||
|
|
@ -507,9 +507,9 @@ export class KeycloakController extends Controller {
|
||||||
|
|
||||||
let typeCondition = "";
|
let typeCondition = "";
|
||||||
let checkChildConditions = "";
|
let checkChildConditions = "";
|
||||||
let conditions:any = {};
|
let conditions: any = {};
|
||||||
|
|
||||||
if(body.nodeId !== null && body.nodeId !== "" && body.nodeId !== undefined){
|
if (body.nodeId !== null && body.nodeId !== "" && body.nodeId !== undefined) {
|
||||||
if (body.node === 0) {
|
if (body.node === 0) {
|
||||||
typeCondition = `current_holders.orgRootId = '${body.nodeId}'`;
|
typeCondition = `current_holders.orgRootId = '${body.nodeId}'`;
|
||||||
if (!body.isAll) {
|
if (!body.isAll) {
|
||||||
|
|
@ -533,9 +533,9 @@ export class KeycloakController extends Controller {
|
||||||
} else if (body.node === 4) {
|
} else if (body.node === 4) {
|
||||||
typeCondition = `current_holders.orgChild4Id = '${body.nodeId}'`;
|
typeCondition = `current_holders.orgChild4Id = '${body.nodeId}'`;
|
||||||
}
|
}
|
||||||
|
|
||||||
conditions = typeCondition;
|
conditions = typeCondition;
|
||||||
if(checkChildConditions){
|
if (checkChildConditions) {
|
||||||
conditions += checkChildConditions;
|
conditions += checkChildConditions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -547,6 +547,11 @@ export class KeycloakController extends Controller {
|
||||||
.createQueryBuilder("profile")
|
.createQueryBuilder("profile")
|
||||||
.leftJoinAndSelect("profile.roleKeycloaks", "roleKeycloaks")
|
.leftJoinAndSelect("profile.roleKeycloaks", "roleKeycloaks")
|
||||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
|
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||||
.where("profile.keycloak IS NOT NULL AND profile.keycloak != ''")
|
.where("profile.keycloak IS NOT NULL AND profile.keycloak != ''")
|
||||||
.andWhere(checkChildFromRole)
|
.andWhere(checkChildFromRole)
|
||||||
.andWhere(conditions)
|
.andWhere(conditions)
|
||||||
|
|
@ -566,6 +571,13 @@ export class KeycloakController extends Controller {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.orderBy("profile.citizenId", "ASC")
|
.orderBy("profile.citizenId", "ASC")
|
||||||
|
.orderBy("orgRoot.orgRootOrder", "ASC")
|
||||||
|
.addOrderBy("orgChild1.orgChild1Order", "ASC")
|
||||||
|
.addOrderBy("orgChild2.orgChild2Order", "ASC")
|
||||||
|
.addOrderBy("orgChild3.orgChild3Order", "ASC")
|
||||||
|
.addOrderBy("orgChild4.orgChild4Order", "ASC")
|
||||||
|
.addOrderBy("current_holders.posMasterOrder", "ASC")
|
||||||
|
.addOrderBy("current_holders.posMasterCreatedAt", "ASC")
|
||||||
.skip((body.page - 1) * body.pageSize)
|
.skip((body.page - 1) * body.pageSize)
|
||||||
.take(body.pageSize)
|
.take(body.pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
@ -574,6 +586,11 @@ export class KeycloakController extends Controller {
|
||||||
.createQueryBuilder("profileEmployee")
|
.createQueryBuilder("profileEmployee")
|
||||||
.leftJoinAndSelect("profileEmployee.roleKeycloaks", "roleKeycloaks")
|
.leftJoinAndSelect("profileEmployee.roleKeycloaks", "roleKeycloaks")
|
||||||
.leftJoinAndSelect("profileEmployee.current_holders", "current_holders")
|
.leftJoinAndSelect("profileEmployee.current_holders", "current_holders")
|
||||||
|
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||||
.where("profileEmployee.keycloak IS NOT NULL AND profileEmployee.keycloak != ''")
|
.where("profileEmployee.keycloak IS NOT NULL AND profileEmployee.keycloak != ''")
|
||||||
.andWhere(checkChildFromRole)
|
.andWhere(checkChildFromRole)
|
||||||
.andWhere(conditions)
|
.andWhere(conditions)
|
||||||
|
|
@ -598,6 +615,13 @@ export class KeycloakController extends Controller {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.orderBy("profileEmployee.citizenId", "ASC")
|
.orderBy("profileEmployee.citizenId", "ASC")
|
||||||
|
.orderBy("orgRoot.orgRootOrder", "ASC")
|
||||||
|
.addOrderBy("orgChild1.orgChild1Order", "ASC")
|
||||||
|
.addOrderBy("orgChild2.orgChild2Order", "ASC")
|
||||||
|
.addOrderBy("orgChild3.orgChild3Order", "ASC")
|
||||||
|
.addOrderBy("orgChild4.orgChild4Order", "ASC")
|
||||||
|
.addOrderBy("current_holders.posMasterOrder", "ASC")
|
||||||
|
.addOrderBy("current_holders.posMasterCreatedAt", "ASC")
|
||||||
.skip((body.page - 1) * body.pageSize)
|
.skip((body.page - 1) * body.pageSize)
|
||||||
.take(body.pageSize)
|
.take(body.pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
@ -758,17 +782,17 @@ export class KeycloakController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("user/role/{id}")
|
@Get("user/role/{id}")
|
||||||
async getRoleUser(@Request() req: RequestWithUser,@Path("id") id: string) {
|
async getRoleUser(@Request() req: RequestWithUser, @Path("id") id: string) {
|
||||||
|
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
where: { keycloak: id },
|
where: { keycloak: id },
|
||||||
relations: ["roleKeycloaks"],
|
relations: ["roleKeycloaks"],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (
|
if (
|
||||||
req.user.sub === id &&
|
req.user.sub === id &&
|
||||||
req.user.role.some(x => x === 'ADMIN') &&
|
req.user.role.some(x => x === 'ADMIN') &&
|
||||||
!req.user.role.some(x => x === 'SUPER_ADMIN')
|
!req.user.role.some(x => x === 'SUPER_ADMIN')
|
||||||
) {
|
) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่มีสิทธิ์เข้าถึงข้อมูลนี้");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่มีสิทธิ์เข้าถึงข้อมูลนี้");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue