search admin get to post
This commit is contained in:
parent
c94f9c4b06
commit
e43feb4964
1 changed files with 40 additions and 22 deletions
|
|
@ -51,16 +51,19 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
* @summary รายการประเมินผลการปฏิบัติราชการระดับบุคคลทั้งหมด
|
* @summary รายการประเมินผลการปฏิบัติราชการระดับบุคคลทั้งหมด
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("admin")
|
@Post("admin")
|
||||||
async listKpiAdminEvaluation(
|
async listKpiAdminEvaluation(
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: { user: Record<string, any> },
|
||||||
@Query("page") page: number = 1,
|
@Body()
|
||||||
@Query("pageSize") pageSize: number = 10,
|
requestBody: {
|
||||||
@Query("kpiPeriodId") kpiPeriodId?: string,
|
page: number;
|
||||||
@Query("keyword") keyword?: string,
|
pageSize: number;
|
||||||
@Query("status") status?: string,
|
kpiPeriodId?: string;
|
||||||
@Query("results") results?: string,
|
keyword?: string;
|
||||||
@Query("reqedit") reqedit?: string,
|
status?: string | null;
|
||||||
|
results?: string | null;
|
||||||
|
reqedit?: string | null;
|
||||||
|
},
|
||||||
) {
|
) {
|
||||||
let profileId: any = null;
|
let profileId: any = null;
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
|
|
@ -73,22 +76,31 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
});
|
});
|
||||||
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||||
.createQueryBuilder("kpiUserEvaluation")
|
.createQueryBuilder("kpiUserEvaluation")
|
||||||
.andWhere(kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", {
|
.andWhere(requestBody.kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", {
|
||||||
kpiPeriodId: kpiPeriodId,
|
kpiPeriodId: requestBody.kpiPeriodId,
|
||||||
})
|
|
||||||
.andWhere(status != null && status != undefined ? "evaluationStatus LIKE :status" : "1=1", {
|
|
||||||
status: status,
|
|
||||||
})
|
})
|
||||||
.andWhere(
|
.andWhere(
|
||||||
results != null && results != undefined ? "evaluationResults LIKE :results" : "1=1",
|
requestBody.status != null && requestBody.status != undefined
|
||||||
|
? "evaluationStatus LIKE :status"
|
||||||
|
: "1=1",
|
||||||
{
|
{
|
||||||
results: results,
|
status: requestBody.status,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.andWhere(
|
.andWhere(
|
||||||
reqedit != null && reqedit != undefined ? "evaluationReqEdit LIKE :reqedit" : "1=1",
|
requestBody.results != null && requestBody.results != undefined
|
||||||
|
? "evaluationResults LIKE :results"
|
||||||
|
: "1=1",
|
||||||
{
|
{
|
||||||
reqedit: reqedit,
|
results: requestBody.results,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
requestBody.reqedit != null && requestBody.reqedit != undefined
|
||||||
|
? "evaluationReqEdit LIKE :reqedit"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
reqedit: requestBody.reqedit,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.andWhere(
|
.andWhere(
|
||||||
|
|
@ -106,14 +118,20 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
)
|
)
|
||||||
.andWhere(
|
.andWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.orWhere("kpiUserEvaluation.prefix LIKE :keyword", { keyword: `%${keyword}%` })
|
qb.orWhere("kpiUserEvaluation.prefix LIKE :keyword", {
|
||||||
.orWhere("kpiUserEvaluation.firstName LIKE :keyword", { keyword: `%${keyword}%` })
|
keyword: `%${requestBody.keyword}%`,
|
||||||
.orWhere("kpiUserEvaluation.lastName LIKE :keyword", { keyword: `%${keyword}%` });
|
})
|
||||||
|
.orWhere("kpiUserEvaluation.firstName LIKE :keyword", {
|
||||||
|
keyword: `%${requestBody.keyword}%`,
|
||||||
|
})
|
||||||
|
.orWhere("kpiUserEvaluation.lastName LIKE :keyword", {
|
||||||
|
keyword: `%${requestBody.keyword}%`,
|
||||||
|
});
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.orderBy("kpiUserEvaluation.createdAt", "ASC")
|
.orderBy("kpiUserEvaluation.createdAt", "ASC")
|
||||||
.skip((page - 1) * pageSize)
|
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||||
.take(pageSize)
|
.take(requestBody.pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
||||||
const mapData = kpiUserEvaluation.map((item) => ({
|
const mapData = kpiUserEvaluation.map((item) => ({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue