fixing
This commit is contained in:
parent
6585520af7
commit
f36594266c
2 changed files with 91 additions and 83 deletions
|
|
@ -88,89 +88,97 @@ export class EvaluationController {
|
|||
status?: string[];
|
||||
},
|
||||
) {
|
||||
// await new permission().PermissionList(request, "SYS_EVA_REQ");
|
||||
let _data = await new permission().PermissionOrgList(request, "SYS_EVA_REQ");
|
||||
const [evaluation, total] = await AppDataSource.getRepository(Evaluation)
|
||||
.createQueryBuilder("evaluation")
|
||||
.andWhere(
|
||||
_data.root != undefined && _data.root != null
|
||||
? _data.root[0] != null
|
||||
? `evaluation.rootId IN (:...root)`
|
||||
: `evaluation.rootId is null`
|
||||
: "1=1",
|
||||
{
|
||||
root: _data.root,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
_data.child1 != undefined && _data.child1 != null
|
||||
? _data.child1[0] != null
|
||||
? `evaluation.child1Id IN (:...child1)`
|
||||
: `evaluation.child1Id is null`
|
||||
: "1=1",
|
||||
{
|
||||
child1: _data.child1,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
_data.child2 != undefined && _data.child2 != null
|
||||
? _data.child2[0] != null
|
||||
? `evaluation.child2Id IN (:...child2)`
|
||||
: `evaluation.child2Id is null`
|
||||
: "1=1",
|
||||
{
|
||||
child2: _data.child2,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
_data.child3 != undefined && _data.child3 != null
|
||||
? _data.child3[0] != null
|
||||
? `evaluation.child3Id IN (:...child3)`
|
||||
: `evaluation.child3Id is null`
|
||||
: "1=1",
|
||||
{
|
||||
child3: _data.child3,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
_data.child4 != undefined && _data.child4 != null
|
||||
? _data.child4[0] != null
|
||||
? `evaluation.child4Id IN (:...child4)`
|
||||
: `evaluation.child4Id is null`
|
||||
: "1=1",
|
||||
{
|
||||
child4: _data.child4,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.status == undefined || body.status == null || body.status.every((s) => s === "ALL")
|
||||
? "1=1"
|
||||
: `evaluation.step In (:status)`,
|
||||
{
|
||||
status: body.status,
|
||||
},
|
||||
).andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere("evaluation.fullName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orWhere("evaluation.citizenId LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orWhere("evaluation.position LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orWhere("evaluation.posNo LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orWhere("evaluation.oc LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orWhere("evaluation.type IN (:...type)", {
|
||||
type: body.keyword == null ? [""] : ConvertThaiToType(body.keyword),
|
||||
});
|
||||
}),
|
||||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("evaluation.lastUpdatedAt", "DESC")
|
||||
.skip((body.page - 1) * body.pageSize)
|
||||
.take(body.pageSize)
|
||||
.getManyAndCount();
|
||||
try {
|
||||
// await new permission().PermissionList(request, "SYS_EVA_REQ");
|
||||
let _data = await new permission().PermissionOrgList(request, "SYS_EVA_REQ");
|
||||
const [evaluation, total] = await AppDataSource.getRepository(Evaluation)
|
||||
.createQueryBuilder("evaluation")
|
||||
.andWhere(
|
||||
_data.root != undefined && _data.root != null
|
||||
? _data.root[0] != null
|
||||
? `evaluation.rootId IN (:...root)`
|
||||
: `evaluation.rootId is null`
|
||||
: "1=1",
|
||||
{
|
||||
root: _data.root,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
_data.child1 != undefined && _data.child1 != null
|
||||
? _data.child1[0] != null
|
||||
? `evaluation.child1Id IN (:...child1)`
|
||||
: `evaluation.child1Id is null`
|
||||
: "1=1",
|
||||
{
|
||||
child1: _data.child1,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
_data.child2 != undefined && _data.child2 != null
|
||||
? _data.child2[0] != null
|
||||
? `evaluation.child2Id IN (:...child2)`
|
||||
: `evaluation.child2Id is null`
|
||||
: "1=1",
|
||||
{
|
||||
child2: _data.child2,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
_data.child3 != undefined && _data.child3 != null
|
||||
? _data.child3[0] != null
|
||||
? `evaluation.child3Id IN (:...child3)`
|
||||
: `evaluation.child3Id is null`
|
||||
: "1=1",
|
||||
{
|
||||
child3: _data.child3,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
_data.child4 != undefined && _data.child4 != null
|
||||
? _data.child4[0] != null
|
||||
? `evaluation.child4Id IN (:...child4)`
|
||||
: `evaluation.child4Id is null`
|
||||
: "1=1",
|
||||
{
|
||||
child4: _data.child4,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.status == undefined ||
|
||||
body.status == null ||
|
||||
body.status.every((s) => s === "ALL")
|
||||
? "1=1"
|
||||
: `evaluation.step In (:status)`,
|
||||
{
|
||||
status: body.status,
|
||||
},
|
||||
).andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere("evaluation.fullName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orWhere("evaluation.citizenId LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orWhere("evaluation.position LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orWhere("evaluation.posNo LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orWhere("evaluation.oc LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orWhere("evaluation.type IN (:...type)", {
|
||||
type: body.keyword == null ? [""] : ConvertThaiToType(body.keyword),
|
||||
});
|
||||
}),
|
||||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("evaluation.lastUpdatedAt", "DESC")
|
||||
.skip((body.page - 1) * body.pageSize)
|
||||
.take(body.pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
return new HttpSuccess({ data: evaluation, total });
|
||||
return new HttpSuccess({ data: evaluation, total });
|
||||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue