get by id
This commit is contained in:
parent
386a7f72d0
commit
5c3daa716a
2 changed files with 11 additions and 8 deletions
|
|
@ -64,15 +64,12 @@ export class kpiEvaluationController extends Controller {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API list เกณฑ์การประเมิน
|
* API list เกณฑ์การประเมิน
|
||||||
* @param page
|
|
||||||
* @param pageSize
|
|
||||||
*/
|
*/
|
||||||
@Get()
|
@Get()
|
||||||
async listKpiEvaluation(
|
async listKpiEvaluation(
|
||||||
@Query("page") page: number = 1,
|
@Query("page") page: number = 1,
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Query("keyword") keyword?: string,
|
@Query("keyword") keyword?: string,
|
||||||
@Query("status") status?: string,
|
|
||||||
) {
|
) {
|
||||||
let whereClause: any = {};
|
let whereClause: any = {};
|
||||||
|
|
||||||
|
|
@ -85,9 +82,6 @@ export class kpiEvaluationController extends Controller {
|
||||||
|
|
||||||
const [kpiEvaluation, total] = await this.kpiEvaluationRepository.findAndCount({
|
const [kpiEvaluation, total] = await this.kpiEvaluationRepository.findAndCount({
|
||||||
...whereClause,
|
...whereClause,
|
||||||
...(status == null || status == undefined
|
|
||||||
? {}
|
|
||||||
: { evaluationStatus: status.trim().toUpperCase() }),
|
|
||||||
...(keyword ? {} : { skip: (page - 1) * pageSize, take: pageSize }),
|
...(keyword ? {} : { skip: (page - 1) * pageSize, take: pageSize }),
|
||||||
order: {
|
order: {
|
||||||
level: "DESC",
|
level: "DESC",
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
async listKpiUserCommanderEvaluation(@Path() id: string, @Path() type: string) {
|
async listKpiUserCommanderEvaluation(@Path() id: string, @Path() type: string) {
|
||||||
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonRepository.find({
|
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonRepository.find({
|
||||||
where: { kpiUserEvaluationId: id, type: type.trim().toUpperCase() },
|
where: { kpiUserEvaluationId: id, type: type.trim().toUpperCase() },
|
||||||
order: { createdAt: "ASC" }
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(kpiUserEvaluationReason);
|
return new HttpSuccess(kpiUserEvaluationReason);
|
||||||
}
|
}
|
||||||
|
|
@ -333,16 +333,25 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get()
|
@Get()
|
||||||
async listKpiUserEvaluation(
|
async listKpiUserEvaluation(
|
||||||
|
@Request() request: { user: Record<string, any> },
|
||||||
@Query("page") page: number = 1,
|
@Query("page") page: number = 1,
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Query("kpiPeriodId") kpiPeriodId?: string,
|
@Query("kpiPeriodId") kpiPeriodId?: string,
|
||||||
// @Query("keyword") keyword?: string,
|
@Query("keyword") keyword?: string,
|
||||||
|
@Query("status") status?: string,
|
||||||
) {
|
) {
|
||||||
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(kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", {
|
||||||
kpiPeriodId: kpiPeriodId,
|
kpiPeriodId: kpiPeriodId,
|
||||||
})
|
})
|
||||||
|
.andWhere({ createdUserId: request.user.sub })
|
||||||
|
.andWhere(
|
||||||
|
status == null || status == undefined ? "1=1" : "evaluationStatus LIKE :evaluationStatus",
|
||||||
|
{
|
||||||
|
evaluationStatus: status == undefined ? "" : status.trim().toUpperCase(),
|
||||||
|
},
|
||||||
|
)
|
||||||
.orderBy("kpiUserEvaluation.createdAt", "ASC")
|
.orderBy("kpiUserEvaluation.createdAt", "ASC")
|
||||||
.skip((page - 1) * pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.take(pageSize)
|
.take(pageSize)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue