list ผู้มีอำนาจ
This commit is contained in:
parent
7af2a9b0ed
commit
c84a626911
1 changed files with 179 additions and 0 deletions
|
|
@ -1654,6 +1654,185 @@ export class ProfileController extends Controller {
|
||||||
return new HttpSuccess({ data: lists, total });
|
return new HttpSuccess({ data: lists, total });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Post("commander-director-position")
|
||||||
|
async getProfileCommanderDirectorPosition(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
@Body()
|
||||||
|
body: {
|
||||||
|
isAct: boolean;
|
||||||
|
isDirector: boolean;
|
||||||
|
keyword: string;
|
||||||
|
page: number;
|
||||||
|
pageSize: number;
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
let posMaster = await this.posMasterRepo.findOne({
|
||||||
|
where: {
|
||||||
|
current_holder: { keycloak: request.user.sub },
|
||||||
|
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
|
},
|
||||||
|
relations: ["current_holder", "current_holder.posLevel"],
|
||||||
|
});
|
||||||
|
if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง");
|
||||||
|
if (posMaster?.current_holder?.posLevel?.posLevelAuthority ?? null == "DEPUTY") {
|
||||||
|
posMaster = await this.posMasterRepo.findOne({
|
||||||
|
where: {
|
||||||
|
orgRoot: { isDeputy: true },
|
||||||
|
orgChild1Id: IsNull(),
|
||||||
|
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโครงสร้างปลัด");
|
||||||
|
} else if (posMaster?.current_holder?.posLevel?.posLevelAuthority ?? null == "GOVERNOR") {
|
||||||
|
return new HttpSuccess({ data: [], total: 0 });
|
||||||
|
}
|
||||||
|
let condition: any = {
|
||||||
|
orgRootId: posMaster.orgRootId,
|
||||||
|
id: Not(posMaster.current_holderId || ""),
|
||||||
|
};
|
||||||
|
let conditionNow: any = {
|
||||||
|
orgRootId: posMaster.orgRootId ?? IsNull(),
|
||||||
|
orgChild1Id: posMaster.orgChild1Id ?? IsNull(),
|
||||||
|
orgChild2Id: posMaster.orgChild2Id ?? IsNull(),
|
||||||
|
orgChild3Id: posMaster.orgChild3Id ?? IsNull(),
|
||||||
|
orgChild4Id: posMaster.orgChild4Id ?? IsNull(),
|
||||||
|
id: Not(posMaster.current_holderId),
|
||||||
|
};
|
||||||
|
if (
|
||||||
|
posMaster.orgRootId == null ||
|
||||||
|
posMaster.orgChild1Id == null ||
|
||||||
|
posMaster.orgChild2Id == null
|
||||||
|
) {
|
||||||
|
condition.orgChild1Id = IsNull();
|
||||||
|
} else if (posMaster.orgChild3Id == null) {
|
||||||
|
condition.orgChild2Id = IsNull();
|
||||||
|
} else if (posMaster.orgChild4Id == null) {
|
||||||
|
condition.orgChild3Id = IsNull();
|
||||||
|
} else if (posMaster.orgChild4Id != null) {
|
||||||
|
condition.orgChild4Id = IsNull();
|
||||||
|
}
|
||||||
|
if (body.isDirector == true) {
|
||||||
|
condition.isDirector = true;
|
||||||
|
conditionNow.isDirector = true;
|
||||||
|
}
|
||||||
|
if (body.isAct == true) {
|
||||||
|
const [lists, total] = await AppDataSource.getRepository(viewDirectorActing)
|
||||||
|
.createQueryBuilder("viewDirectorActing")
|
||||||
|
.andWhere(
|
||||||
|
new Brackets((qb) => {
|
||||||
|
qb.orWhere(condition).orWhere(conditionNow);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
new Brackets((qb) => {
|
||||||
|
qb.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "CONCAT(viewDirectorActing.prefix,viewDirectorActing.firstName,' ',viewDirectorActing.lastName) LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "viewDirectorActing.position LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "viewDirectorActing.actFullName LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "CONCAT(viewDirectorActing.posType, ' (', viewDirectorActing.posLevel, ')') LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "viewDirectorActing.posNo LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.skip((body.page - 1) * body.pageSize)
|
||||||
|
.take(body.pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
return new HttpSuccess({ data: lists, total });
|
||||||
|
} else {
|
||||||
|
const [lists, total] = await AppDataSource.getRepository(viewDirector)
|
||||||
|
.createQueryBuilder("viewDirector")
|
||||||
|
.andWhere(
|
||||||
|
new Brackets((qb) => {
|
||||||
|
qb.orWhere(condition).orWhere(conditionNow);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
new Brackets((qb) => {
|
||||||
|
qb.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "CONCAT(viewDirector.prefix,viewDirector.firstName,' ',viewDirector.lastName) LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "viewDirector.position LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "viewDirector.actFullName LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "CONCAT(viewDirector.posType, ' (', viewDirector.posLevel, ')') LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "viewDirector.posNo LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.skip((body.page - 1) * body.pageSize)
|
||||||
|
.take(body.pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
return new HttpSuccess({ data: lists, total });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API เลือกผู้ประเมินสำหรับ User (ADMIN)
|
* API เลือกผู้ประเมินสำหรับ User (ADMIN)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue