no message
This commit is contained in:
parent
71a9da67e8
commit
d6b8443b5c
1 changed files with 140 additions and 14 deletions
|
|
@ -1228,10 +1228,10 @@ export class ProfileController extends Controller {
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("commander-director")//page searchxxxxxxxxxxxxxxxxxxxxxxxx
|
@Post("commander-director")
|
||||||
async getProfileCommanderDirector(
|
async getProfileCommanderDirector(
|
||||||
@Request() request: RequestWithUser,
|
@Request() request: RequestWithUser,
|
||||||
@Body() body: { isDirector: boolean },
|
@Body() body: { isDirector: boolean; page: number; pageSize: number; keyword: string },
|
||||||
) {
|
) {
|
||||||
const posMaster = await this.posMasterRepo.findOne({
|
const posMaster = await this.posMasterRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -1241,15 +1241,78 @@ export class ProfileController extends Controller {
|
||||||
});
|
});
|
||||||
if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง");
|
if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง");
|
||||||
if (body.isDirector == true) {
|
if (body.isDirector == true) {
|
||||||
const _posMaster = await this.posMasterRepo.find({
|
const [_posMaster, total] = await AppDataSource.getRepository(PosMaster)
|
||||||
where: {
|
.createQueryBuilder("posMaster")
|
||||||
|
.leftJoinAndSelect("posMaster.current_holder", "current_holder")
|
||||||
|
.leftJoinAndSelect("current_holder.posLevel", "posLevel")
|
||||||
|
.leftJoinAndSelect("current_holder.posType", "posType")
|
||||||
|
.where({
|
||||||
orgRootId: posMaster.orgRootId || "",
|
orgRootId: posMaster.orgRootId || "",
|
||||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
isDirector: true,
|
isDirector: true,
|
||||||
current_holderId: Not(IsNull()),
|
current_holderId: Not(IsNull()),
|
||||||
},
|
})
|
||||||
relations: ["current_holder", "current_holder.posLevel", "current_holder.posType"],
|
.andWhere(
|
||||||
});
|
new Brackets((qb) => {
|
||||||
|
qb.where(
|
||||||
|
body.keyword != undefined && body.keyword != null && body.keyword != ""
|
||||||
|
? "CONCAT(current_holder.prefix, current_holder.firstName, ' ', current_holder.lastName) LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.where(
|
||||||
|
body.keyword != undefined && body.keyword != null && body.keyword != ""
|
||||||
|
? "current_holder.citizenId LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.where(
|
||||||
|
body.keyword != undefined && body.keyword != null && body.keyword != ""
|
||||||
|
? "current_holder.position LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.where(
|
||||||
|
body.keyword != undefined && body.keyword != null && body.keyword != ""
|
||||||
|
? "posLevel.posLevelName LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.where(
|
||||||
|
body.keyword != undefined && body.keyword != null && body.keyword != ""
|
||||||
|
? "posType.posTypeName LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.select([
|
||||||
|
"posMaster.current_holderId",
|
||||||
|
"current_holder.prefix",
|
||||||
|
"current_holder.firstName",
|
||||||
|
"current_holder.lastName",
|
||||||
|
"current_holder.citizenId",
|
||||||
|
"current_holder.position",
|
||||||
|
"current_holder.posLevel",
|
||||||
|
"posLevel.posLevelName",
|
||||||
|
"current_holder.posType",
|
||||||
|
"posType.posTypeName",
|
||||||
|
"posMaster.isDirector",
|
||||||
|
])
|
||||||
|
.skip((body.page - 1) * body.pageSize)
|
||||||
|
.take(body.pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
|
||||||
const posMasterActs = await this.posMasterActRepository.find({
|
const posMasterActs = await this.posMasterActRepository.find({
|
||||||
where: {
|
where: {
|
||||||
posMasterId: In(_posMaster.map((x) => x.id)),
|
posMasterId: In(_posMaster.map((x) => x.id)),
|
||||||
|
|
@ -1299,16 +1362,79 @@ export class ProfileController extends Controller {
|
||||||
};
|
};
|
||||||
data.push(item);
|
data.push(item);
|
||||||
});
|
});
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess({ data, total });
|
||||||
} else {
|
} else {
|
||||||
const _posMaster = await this.posMasterRepo.find({
|
const [_posMaster, total] = await AppDataSource.getRepository(PosMaster)
|
||||||
where: {
|
.createQueryBuilder("posMaster")
|
||||||
|
.leftJoinAndSelect("posMaster.current_holder", "current_holder")
|
||||||
|
.leftJoinAndSelect("current_holder.posLevel", "posLevel")
|
||||||
|
.leftJoinAndSelect("current_holder.posType", "posType")
|
||||||
|
.where({
|
||||||
orgRootId: posMaster.orgRootId || "",
|
orgRootId: posMaster.orgRootId || "",
|
||||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
current_holderId: Not(IsNull()),
|
current_holderId: Not(IsNull()),
|
||||||
},
|
})
|
||||||
relations: ["current_holder", "current_holder.posLevel", "current_holder.posType"],
|
.andWhere(
|
||||||
});
|
new Brackets((qb) => {
|
||||||
|
qb.where(
|
||||||
|
body.keyword != undefined && body.keyword != null && body.keyword != ""
|
||||||
|
? "CONCAT(current_holder.prefix, current_holder.firstName, ' ', current_holder.lastName) LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.where(
|
||||||
|
body.keyword != undefined && body.keyword != null && body.keyword != ""
|
||||||
|
? "current_holder.citizenId LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.where(
|
||||||
|
body.keyword != undefined && body.keyword != null && body.keyword != ""
|
||||||
|
? "current_holder.position LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.where(
|
||||||
|
body.keyword != undefined && body.keyword != null && body.keyword != ""
|
||||||
|
? "posLevel.posLevelName LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.where(
|
||||||
|
body.keyword != undefined && body.keyword != null && body.keyword != ""
|
||||||
|
? "posType.posTypeName LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.select([
|
||||||
|
"posMaster.current_holderId",
|
||||||
|
"current_holder.prefix",
|
||||||
|
"current_holder.firstName",
|
||||||
|
"current_holder.lastName",
|
||||||
|
"current_holder.citizenId",
|
||||||
|
"current_holder.position",
|
||||||
|
"current_holder.posLevel",
|
||||||
|
"posLevel.posLevelName",
|
||||||
|
"current_holder.posType",
|
||||||
|
"posType.posTypeName",
|
||||||
|
"posMaster.isDirector",
|
||||||
|
])
|
||||||
|
.skip((body.page - 1) * body.pageSize)
|
||||||
|
.take(body.pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
|
||||||
let data = _posMaster.map((_data) => ({
|
let data = _posMaster.map((_data) => ({
|
||||||
id: _data.current_holderId || null,
|
id: _data.current_holderId || null,
|
||||||
prefix: _data.current_holder?.prefix || "",
|
prefix: _data.current_holder?.prefix || "",
|
||||||
|
|
@ -1327,7 +1453,7 @@ export class ProfileController extends Controller {
|
||||||
isDirector: _data.isDirector || false,
|
isDirector: _data.isDirector || false,
|
||||||
actFullName: null,
|
actFullName: null,
|
||||||
}));
|
}));
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess({ data, total });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue