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[];
|
status?: string[];
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
// await new permission().PermissionList(request, "SYS_EVA_REQ");
|
try {
|
||||||
let _data = await new permission().PermissionOrgList(request, "SYS_EVA_REQ");
|
// await new permission().PermissionList(request, "SYS_EVA_REQ");
|
||||||
const [evaluation, total] = await AppDataSource.getRepository(Evaluation)
|
let _data = await new permission().PermissionOrgList(request, "SYS_EVA_REQ");
|
||||||
.createQueryBuilder("evaluation")
|
const [evaluation, total] = await AppDataSource.getRepository(Evaluation)
|
||||||
.andWhere(
|
.createQueryBuilder("evaluation")
|
||||||
_data.root != undefined && _data.root != null
|
.andWhere(
|
||||||
? _data.root[0] != null
|
_data.root != undefined && _data.root != null
|
||||||
? `evaluation.rootId IN (:...root)`
|
? _data.root[0] != null
|
||||||
: `evaluation.rootId is null`
|
? `evaluation.rootId IN (:...root)`
|
||||||
: "1=1",
|
: `evaluation.rootId is null`
|
||||||
{
|
: "1=1",
|
||||||
root: _data.root,
|
{
|
||||||
},
|
root: _data.root,
|
||||||
)
|
},
|
||||||
.andWhere(
|
)
|
||||||
_data.child1 != undefined && _data.child1 != null
|
.andWhere(
|
||||||
? _data.child1[0] != null
|
_data.child1 != undefined && _data.child1 != null
|
||||||
? `evaluation.child1Id IN (:...child1)`
|
? _data.child1[0] != null
|
||||||
: `evaluation.child1Id is null`
|
? `evaluation.child1Id IN (:...child1)`
|
||||||
: "1=1",
|
: `evaluation.child1Id is null`
|
||||||
{
|
: "1=1",
|
||||||
child1: _data.child1,
|
{
|
||||||
},
|
child1: _data.child1,
|
||||||
)
|
},
|
||||||
.andWhere(
|
)
|
||||||
_data.child2 != undefined && _data.child2 != null
|
.andWhere(
|
||||||
? _data.child2[0] != null
|
_data.child2 != undefined && _data.child2 != null
|
||||||
? `evaluation.child2Id IN (:...child2)`
|
? _data.child2[0] != null
|
||||||
: `evaluation.child2Id is null`
|
? `evaluation.child2Id IN (:...child2)`
|
||||||
: "1=1",
|
: `evaluation.child2Id is null`
|
||||||
{
|
: "1=1",
|
||||||
child2: _data.child2,
|
{
|
||||||
},
|
child2: _data.child2,
|
||||||
)
|
},
|
||||||
.andWhere(
|
)
|
||||||
_data.child3 != undefined && _data.child3 != null
|
.andWhere(
|
||||||
? _data.child3[0] != null
|
_data.child3 != undefined && _data.child3 != null
|
||||||
? `evaluation.child3Id IN (:...child3)`
|
? _data.child3[0] != null
|
||||||
: `evaluation.child3Id is null`
|
? `evaluation.child3Id IN (:...child3)`
|
||||||
: "1=1",
|
: `evaluation.child3Id is null`
|
||||||
{
|
: "1=1",
|
||||||
child3: _data.child3,
|
{
|
||||||
},
|
child3: _data.child3,
|
||||||
)
|
},
|
||||||
.andWhere(
|
)
|
||||||
_data.child4 != undefined && _data.child4 != null
|
.andWhere(
|
||||||
? _data.child4[0] != null
|
_data.child4 != undefined && _data.child4 != null
|
||||||
? `evaluation.child4Id IN (:...child4)`
|
? _data.child4[0] != null
|
||||||
: `evaluation.child4Id is null`
|
? `evaluation.child4Id IN (:...child4)`
|
||||||
: "1=1",
|
: `evaluation.child4Id is null`
|
||||||
{
|
: "1=1",
|
||||||
child4: _data.child4,
|
{
|
||||||
},
|
child4: _data.child4,
|
||||||
)
|
},
|
||||||
.andWhere(
|
)
|
||||||
new Brackets((qb) => {
|
.andWhere(
|
||||||
qb.andWhere(
|
new Brackets((qb) => {
|
||||||
body.status == undefined || body.status == null || body.status.every((s) => s === "ALL")
|
qb.andWhere(
|
||||||
? "1=1"
|
body.status == undefined ||
|
||||||
: `evaluation.step In (:status)`,
|
body.status == null ||
|
||||||
{
|
body.status.every((s) => s === "ALL")
|
||||||
status: body.status,
|
? "1=1"
|
||||||
},
|
: `evaluation.step In (:status)`,
|
||||||
).andWhere(
|
{
|
||||||
new Brackets((qb) => {
|
status: body.status,
|
||||||
qb.orWhere("evaluation.fullName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
},
|
||||||
.orWhere("evaluation.citizenId LIKE :keyword", { keyword: `%${body.keyword}%` })
|
).andWhere(
|
||||||
.orWhere("evaluation.position LIKE :keyword", { keyword: `%${body.keyword}%` })
|
new Brackets((qb) => {
|
||||||
.orWhere("evaluation.posNo LIKE :keyword", { keyword: `%${body.keyword}%` })
|
qb.orWhere("evaluation.fullName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
.orWhere("evaluation.oc LIKE :keyword", { keyword: `%${body.keyword}%` })
|
.orWhere("evaluation.citizenId LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
.orWhere("evaluation.type IN (:...type)", {
|
.orWhere("evaluation.position LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
type: body.keyword == null ? [""] : ConvertThaiToType(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();
|
.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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ export const AppDataSource = new DataSource({
|
||||||
password: process.env.DB_PASSWORD,
|
password: process.env.DB_PASSWORD,
|
||||||
connectorPackage: "mysql2",
|
connectorPackage: "mysql2",
|
||||||
synchronize: false,
|
synchronize: false,
|
||||||
timezone: "Z", // "Z" = UTC
|
// timezone: "Z", // "Z" = UTC
|
||||||
logging: ["query", "error"],
|
logging: ["query", "error"],
|
||||||
entities:
|
entities:
|
||||||
process.env.NODE_ENV !== "production"
|
process.env.NODE_ENV !== "production"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue