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