Merge branch 'develop' of github.com:Frappet/bma-ehr-kpi into develop

This commit is contained in:
Kittapath 2024-05-08 13:32:02 +07:00
commit 30636c482d
3 changed files with 297 additions and 160 deletions

View file

@ -48,10 +48,12 @@ export class kpiPlanController extends Controller {
@Request() request: { user: Record<string, any> }, @Request() request: { user: Record<string, any> },
) { ) {
const kpiPlan = Object.assign(new KpiPlan(), requestBody); const kpiPlan = Object.assign(new KpiPlan(), requestBody);
if (requestBody.kpiPeriodId != null) { if (requestBody.year != null) {
const kpiPeriod = await this.kpiPeriodRepository.findOne({ const kpiPeriod = await this.kpiPeriodRepository
where: { id: requestBody.kpiPeriodId }, .createQueryBuilder("kpiPeriod")
}); .where("kpiPeriod.year = :year", { year: requestBody.year })
.andWhere("kpiPeriod.durationKPI = :durationKPI", { durationKPI: requestBody.period })
.getOne();
if (!kpiPeriod) { if (!kpiPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้");
} }
@ -106,8 +108,11 @@ export class kpiPlanController extends Controller {
.where("kpiPlan.rootId = :rootId AND kpiPlan.child1Id IS NULL", { .where("kpiPlan.rootId = :rootId AND kpiPlan.child1Id IS NULL", {
rootId: requestBody.nodeId, rootId: requestBody.nodeId,
}) })
.andWhere("kpiPlan.kpiPeriodId = :kpiPeriodId", { .andWhere("kpiPlan.year = :year", {
kpiPeriodId: requestBody.kpiPeriodId, year: requestBody.year,
})
.andWhere("kpiPlan.period = :period", {
period: requestBody.period,
}) })
.getRawOne(); .getRawOne();
} else if (requestBody.node == 1) { } else if (requestBody.node == 1) {
@ -117,8 +122,11 @@ export class kpiPlanController extends Controller {
.where("kpiPlan.child1Id = :child1Id AND kpiPlan.child2Id IS NULL", { .where("kpiPlan.child1Id = :child1Id AND kpiPlan.child2Id IS NULL", {
child1Id: requestBody.nodeId, child1Id: requestBody.nodeId,
}) })
.andWhere("kpiPlan.kpiPeriodId = :kpiPeriodId", { .andWhere("kpiPlan.year = :year", {
kpiPeriodId: requestBody.kpiPeriodId, year: requestBody.year,
})
.andWhere("kpiPlan.period = :period", {
period: requestBody.period,
}) })
.getRawOne(); .getRawOne();
} else if (requestBody.node == 2) { } else if (requestBody.node == 2) {
@ -128,8 +136,11 @@ export class kpiPlanController extends Controller {
.where("kpiPlan.child2Id = :child2Id AND kpiPlan.child3Id IS NULL", { .where("kpiPlan.child2Id = :child2Id AND kpiPlan.child3Id IS NULL", {
child2Id: requestBody.nodeId, child2Id: requestBody.nodeId,
}) })
.andWhere("kpiPlan.kpiPeriodId = :kpiPeriodId", { .andWhere("kpiPlan.year = :year", {
kpiPeriodId: requestBody.kpiPeriodId, year: requestBody.year,
})
.andWhere("kpiPlan.period = :period", {
period: requestBody.period,
}) })
.getRawOne(); .getRawOne();
} else if (requestBody.node == 3) { } else if (requestBody.node == 3) {
@ -139,8 +150,11 @@ export class kpiPlanController extends Controller {
.where("kpiPlan.child3Id = :child3Id AND kpiPlan.child4Id IS NULL", { .where("kpiPlan.child3Id = :child3Id AND kpiPlan.child4Id IS NULL", {
child3Id: requestBody.nodeId, child3Id: requestBody.nodeId,
}) })
.andWhere("kpiPlan.kpiPeriodId = :kpiPeriodId", { .andWhere("kpiPlan.year = :year", {
kpiPeriodId: requestBody.kpiPeriodId, year: requestBody.year,
})
.andWhere("kpiPlan.period = :period", {
period: requestBody.period,
}) })
.getRawOne(); .getRawOne();
} else if (requestBody.node == 4) { } else if (requestBody.node == 4) {
@ -150,8 +164,11 @@ export class kpiPlanController extends Controller {
.where("kpiPlan.child4Id = :child4Id", { .where("kpiPlan.child4Id = :child4Id", {
child4Id: requestBody.nodeId, child4Id: requestBody.nodeId,
}) })
.andWhere("kpiPlan.kpiPeriodId = :kpiPeriodId", { .andWhere("kpiPlan.year = :year", {
kpiPeriodId: requestBody.kpiPeriodId, year: requestBody.year,
})
.andWhere("kpiPlan.period = :period", {
period: requestBody.period,
}) })
.getRawOne(); .getRawOne();
} }
@ -192,10 +209,12 @@ export class kpiPlanController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามแผนฯนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามแผนฯนี้");
} }
if (requestBody.kpiPeriodId != null) { if (requestBody.year != null) {
const kpiPeriod = await this.kpiPeriodRepository.findOne({ const kpiPeriod = await this.kpiPeriodRepository
where: { id: requestBody.kpiPeriodId }, .createQueryBuilder("kpiPeriod")
}); .where("kpiPeriod.year = :year", { year: requestBody.year })
.andWhere("kpiPeriod.durationKPI = :durationKPI", { durationKPI: requestBody.period })
.getOne();
if (!kpiPeriod) { if (!kpiPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้");
} }
@ -363,48 +382,91 @@ export class kpiPlanController extends Controller {
* @param pageSize * @param pageSize
* @param keyword * @param keyword
*/ */
@Get() @Post("search")
async listKpiPlan( async listKpiPlan(
@Query("page") page: number = 1, @Body()
@Query("pageSize") pageSize: number = 10, requestBody: {
@Query("kpiPeriodId") kpiPeriodId?: string, page: number;
@Query("nodeId") nodeId?: string | null, pageSize: number;
@Query("node") node?: number | null, year?: string | null;
@Query("keyword") keyword?: string, period?: string | null;
nodeId?: string | null;
node?: number | null;
keyword?: string;
isAll?: boolean;
isNull?: boolean;
},
) { ) {
let condition = "";
let parameters: any = {};
if (requestBody.isAll === false) {
switch (requestBody.node) {
case 0:
condition = "kpiPlan.rootId LIKE :nodeId AND kpiPlan.child1 IS NULL";
break;
case 1:
condition = "kpiPlan.child1 LIKE :nodeId AND kpiPlan.child2 IS NULL";
break;
case 2:
condition = "kpiPlan.child2 LIKE :nodeId AND kpiPlan.child3 IS NULL";
break;
case 3:
condition = "kpiPlan.child3 LIKE :nodeId AND kpiPlan.child4 IS NULL";
break;
case 4:
condition = "kpiPlan.child4 LIKE :nodeId";
break;
default:
break;
}
parameters.nodeId = `%${requestBody.nodeId}%`;
} else {
switch (requestBody.node) {
case 0:
condition = "kpiPlan.rootId LIKE :nodeId";
break;
case 1:
condition = "kpiPlan.child1 LIKE :nodeId";
break;
case 2:
condition = "kpiPlan.child2 LIKE :nodeId";
break;
case 3:
condition = "kpiPlan.child3 LIKE :nodeId";
break;
case 4:
condition = "kpiPlan.child4 LIKE :nodeId";
break;
default:
break;
}
parameters.nodeId = `%${requestBody.nodeId}%`;
}
if (requestBody.year && requestBody.period && requestBody.isNull === true) {
condition += ` AND (kpiPlan.year LIKE :year OR kpiPlan.year IS NULL) AND (kpiPlan.period LIKE :period OR kpiPlan.period IS NULL)`;
parameters.year = `%${requestBody.year}%`;
parameters.period = `%${requestBody.period}%`;
}
const [kpiPlan, total] = await AppDataSource.getRepository(KpiPlan) const [kpiPlan, total] = await AppDataSource.getRepository(KpiPlan)
.createQueryBuilder("kpiPlan") .createQueryBuilder("kpiPlan")
.leftJoinAndSelect("kpiPlan.kpiPeriod", "kpiPeriod") .leftJoinAndSelect("kpiPlan.kpiPeriod", "kpiPeriod")
.andWhere(condition, parameters)
.andWhere( .andWhere(
node != undefined && node != null requestBody.isNull === false && requestBody.year && requestBody.period
? node == 4 ? "kpiPlan.year LIKE :year AND kpiPlan.period LIKE :period"
? "kpiPlan.child4Id LIKE :nodeId"
: node == 3
? "kpiPlan.child3Id LIKE :nodeId"
: node == 2
? "kpiPlan.child2Id LIKE :nodeId"
: node == 1
? "kpiPlan.child1Id LIKE :nodeId"
: "kpiPlan.rootId LIKE :nodeId"
: "1=1", : "1=1",
{ {
nodeId: nodeId, year: `%${requestBody.year}%`,
}, period: `%${requestBody.period}%`,
)
.andWhere(
kpiPeriodId != undefined && kpiPeriodId != null && kpiPeriodId != ""
? "kpiPlan.kpiPeriodId LIKE :kpiPeriodId"
: "1=1",
{
kpiPeriodId: kpiPeriodId,
}, },
) )
.andWhere( .andWhere(
new Brackets((qb) => { new Brackets((qb) => {
qb.orWhere("kpiPlan.including LIKE :keyword", { keyword: `%${keyword}%` }).orWhere( qb.orWhere("kpiPlan.including LIKE :keyword", {
"kpiPlan.includingName LIKE :keyword", keyword: `%${requestBody.keyword}%`,
{ keyword: `%${keyword}%` }, }).orWhere("kpiPlan.includingName LIKE :keyword", {
); keyword: `%${requestBody.keyword}%`,
});
}), }),
) )
.select([ .select([
@ -416,8 +478,8 @@ export class kpiPlanController extends Controller {
"kpiPlan.createdAt", "kpiPlan.createdAt",
]) ])
.orderBy("kpiPlan.createdAt", "DESC") .orderBy("kpiPlan.createdAt", "DESC")
.skip((page - 1) * pageSize) .skip((requestBody.page - 1) * requestBody.pageSize)
.take(pageSize) .take(requestBody.pageSize)
.getManyAndCount(); .getManyAndCount();
return new HttpSuccess({ data: kpiPlan, total }); return new HttpSuccess({ data: kpiPlan, total });

View file

@ -48,10 +48,12 @@ export class kpiRoleController extends Controller {
@Request() request: { user: Record<string, any> }, @Request() request: { user: Record<string, any> },
) { ) {
const kpiRole = Object.assign(new KpiRole(), requestBody); const kpiRole = Object.assign(new KpiRole(), requestBody);
if (requestBody.kpiPeriodId != null) { if (requestBody.year != null) {
const kpiPeriod = await this.kpiPeriodRepository.findOne({ const kpiPeriod = await this.kpiPeriodRepository
where: { id: requestBody.kpiPeriodId }, .createQueryBuilder("kpiPeriod")
}); .where("kpiPeriod.year = :year", { year: requestBody.year })
.andWhere("kpiPeriod.durationKPI = :durationKPI", { durationKPI: requestBody.period })
.getOne();
if (!kpiPeriod) { if (!kpiPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้");
} }
@ -80,78 +82,93 @@ export class kpiRoleController extends Controller {
}) })
.catch((x) => {}); .catch((x) => {});
let maxIncludingRole: any; let maxIncludingRole: any;
if (requestBody.node == 0) { if (requestBody.node == 0) {
maxIncludingRole = await this.kpiRoleRepository maxIncludingRole = await this.kpiRoleRepository
.createQueryBuilder("kpiRole") .createQueryBuilder("kpiRole")
.select("MAX(kpiRole.including)", "maxIncluding") .select("MAX(kpiRole.including)", "maxIncluding")
.where("kpiRole.rootId = :rootId AND kpiRole.child1Id IS NULL", { .where("kpiRole.rootId = :rootId AND kpiRole.child1Id IS NULL", {
rootId: requestBody.nodeId, rootId: requestBody.nodeId,
}) })
.andWhere("kpiRole.position LIKE :position", { .andWhere("kpiRole.position LIKE :position", {
position: `%${requestBody.position}%`, position: `%${requestBody.position}%`,
}) })
.andWhere("kpiRole.kpiPeriodId = :kpiPeriodId", { .andWhere("kpiRole.year = :year", {
kpiPeriodId: requestBody.kpiPeriodId, year: requestBody.year,
}) })
.getRawOne(); .andWhere("kpiRole.period = :period", {
} else if (requestBody.node == 1) { period: requestBody.period,
maxIncludingRole = await this.kpiRoleRepository })
.createQueryBuilder("kpiRole") .getRawOne();
.select("MAX(kpiRole.including)", "maxIncluding") } else if (requestBody.node == 1) {
.where("kpiRole.child1Id = :child1Id AND kpiRole.child2Id IS NULL", { maxIncludingRole = await this.kpiRoleRepository
child1Id: requestBody.nodeId, .createQueryBuilder("kpiRole")
}) .select("MAX(kpiRole.including)", "maxIncluding")
.andWhere("kpiRole.position LIKE :position", { .where("kpiRole.child1Id = :child1Id AND kpiRole.child2Id IS NULL", {
position: `%${requestBody.position}%`, child1Id: requestBody.nodeId,
}) })
.andWhere("kpiRole.kpiPeriodId = :kpiPeriodId", { .andWhere("kpiRole.position LIKE :position", {
kpiPeriodId: requestBody.kpiPeriodId, position: `%${requestBody.position}%`,
}) })
.getRawOne(); .andWhere("kpiRole.year = :year", {
} else if (requestBody.node == 2) { year: requestBody.year,
maxIncludingRole = await this.kpiRoleRepository })
.createQueryBuilder("kpiRole") .andWhere("kpiRole.period = :period", {
.select("MAX(kpiRole.including)", "maxIncluding") period: requestBody.period,
.where("kpiRole.child2Id = :child2Id AND kpiRole.child3Id IS NULL", { })
child2Id: requestBody.nodeId, .getRawOne();
}) } else if (requestBody.node == 2) {
.andWhere("kpiRole.position LIKE :position", { maxIncludingRole = await this.kpiRoleRepository
position: `%${requestBody.position}%`, .createQueryBuilder("kpiRole")
}) .select("MAX(kpiRole.including)", "maxIncluding")
.andWhere("kpiRole.kpiPeriodId = :kpiPeriodId", { .where("kpiRole.child2Id = :child2Id AND kpiRole.child3Id IS NULL", {
kpiPeriodId: requestBody.kpiPeriodId, child2Id: requestBody.nodeId,
}) })
.getRawOne(); .andWhere("kpiRole.position LIKE :position", {
} else if (requestBody.node == 3) { position: `%${requestBody.position}%`,
maxIncludingRole = await this.kpiRoleRepository })
.createQueryBuilder("kpiRole") .andWhere("kpiRole.year = :year", {
.select("MAX(kpiRole.including)", "maxIncluding") year: requestBody.year,
.where("kpiRole.child3Id = :child3Id AND kpiRole.child4Id IS NULL", { })
child3Id: requestBody.nodeId, .andWhere("kpiRole.period = :period", {
}) period: requestBody.period,
.andWhere("kpiRole.position LIKE :position", { })
position: `%${requestBody.position}%`, .getRawOne();
}) } else if (requestBody.node == 3) {
.andWhere("kpiRole.kpiPeriodId = :kpiPeriodId", { maxIncludingRole = await this.kpiRoleRepository
kpiPeriodId: requestBody.kpiPeriodId, .createQueryBuilder("kpiRole")
}) .select("MAX(kpiRole.including)", "maxIncluding")
.getRawOne(); .where("kpiRole.child3Id = :child3Id AND kpiRole.child4Id IS NULL", {
} else if (requestBody.node == 4) { child3Id: requestBody.nodeId,
maxIncludingRole = await this.kpiRoleRepository })
.createQueryBuilder("kpiRole") .andWhere("kpiRole.position LIKE :position", {
.select("MAX(kpiRole.including)", "maxIncluding") position: `%${requestBody.position}%`,
.where("kpiRole.child4Id = :child4Id", { })
child4Id: requestBody.nodeId, .andWhere("kpiRole.year = :year", {
}) year: requestBody.year,
.andWhere("kpiRole.position LIKE :position", { })
position: `%${requestBody.position}%`, .andWhere("kpiRole.period = :period", {
}) period: requestBody.period,
.andWhere("kpiRole.kpiPeriodId = :kpiPeriodId", { })
kpiPeriodId: requestBody.kpiPeriodId, .getRawOne();
}) } else if (requestBody.node == 4) {
.getRawOne(); maxIncludingRole = await this.kpiRoleRepository
} .createQueryBuilder("kpiRole")
.select("MAX(kpiRole.including)", "maxIncluding")
.where("kpiRole.child4Id = :child4Id", {
child4Id: requestBody.nodeId,
})
.andWhere("kpiRole.position LIKE :position", {
position: `%${requestBody.position}%`,
})
.andWhere("kpiRole.year = :year", {
year: requestBody.year,
})
.andWhere("kpiRole.period = :period", {
period: requestBody.period,
})
.getRawOne();
}
kpiRole.including = maxIncludingRole.maxIncluding + 1; kpiRole.including = maxIncludingRole.maxIncluding + 1;
kpiRole.createdUserId = request.user.sub; kpiRole.createdUserId = request.user.sub;
kpiRole.createdFullName = request.user.name; kpiRole.createdFullName = request.user.name;
@ -189,10 +206,12 @@ export class kpiRoleController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้");
} }
if (requestBody.kpiPeriodId != null) { if (requestBody.year != null) {
const kpiPeriod = await this.kpiPeriodRepository.findOne({ const kpiPeriod = await this.kpiPeriodRepository
where: { id: requestBody.kpiPeriodId }, .createQueryBuilder("kpiPeriod")
}); .where("kpiPeriod.year = :year", { year: requestBody.year })
.andWhere("kpiPeriod.durationKPI = :durationKPI", { durationKPI: requestBody.period })
.getOne();
if (!kpiPeriod) { if (!kpiPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้");
} }
@ -312,51 +331,108 @@ export class kpiRoleController extends Controller {
* @param pageSize * @param pageSize
* @param keyword * @param keyword
*/ */
@Get() @Post("search")
async listKpiRole( async listKpiRole(
@Query("page") page: number = 1, @Body()
@Query("pageSize") pageSize: number = 10, requestBody: {
@Query("kpiPeriodId") kpiPeriodId?: string, page: number;
@Query("nodeId") nodeId?: string | null, pageSize: number;
@Query("node") node?: number | null, year?: string | null;
@Query("keyword") keyword?: string, period?: string | null;
@Query("position") position?: string, nodeId?: string | null;
node?: number | null;
position?: string | null;
keyword?: string;
isAll?: boolean;
isNull?: boolean;
},
) { ) {
let condition = "";
let parameters: any = {};
if (requestBody.isAll === false) {
switch (requestBody.node) {
case 0:
condition = "kpiRole.rootId LIKE :nodeId AND kpiRole.child1 IS NULL";
break;
case 1:
condition = "kpiRole.child1 LIKE :nodeId AND kpiRole.child2 IS NULL";
break;
case 2:
condition = "kpiRole.child2 LIKE :nodeId AND kpiRole.child3 IS NULL";
break;
case 3:
condition = "kpiRole.child3 LIKE :nodeId AND kpiRole.child4 IS NULL";
break;
case 4:
condition = "kpiRole.child4 LIKE :nodeId";
break;
default:
break;
}
parameters.nodeId = `%${requestBody.nodeId}%`;
} else {
switch (requestBody.node) {
case 0:
condition = "kpiRole.rootId LIKE :nodeId";
break;
case 1:
condition = "kpiRole.child1 LIKE :nodeId";
break;
case 2:
condition = "kpiRole.child2 LIKE :nodeId";
break;
case 3:
condition = "kpiRole.child3 LIKE :nodeId";
break;
case 4:
condition = "kpiRole.child4 LIKE :nodeId";
break;
default:
break;
}
parameters.nodeId = `%${requestBody.nodeId}%`;
}
if (requestBody.year && requestBody.period && requestBody.isNull === true) {
condition += ` AND (kpiRole.year LIKE :year OR kpiRole.year IS NULL) AND (kpiRole.period LIKE :period OR kpiRole.period IS NULL)`;
parameters.year = `%${requestBody.year}%`;
parameters.period = `%${requestBody.period}%`;
}
const [kpiRole, total] = await AppDataSource.getRepository(KpiRole) const [kpiRole, total] = await AppDataSource.getRepository(KpiRole)
.createQueryBuilder("kpiRole") .createQueryBuilder("kpiRole")
.leftJoinAndSelect("kpiRole.kpiPeriod", "kpiPeriod") .leftJoinAndSelect("kpiRole.kpiPeriod", "kpiPeriod")
.andWhere( .andWhere(
node != undefined && node != null requestBody.node != undefined && requestBody.node != null
? node == 4 ? requestBody.node == 4
? "kpiRole.child4Id LIKE :nodeId" ? "kpiRole.child4Id LIKE :nodeId"
: node == 3 : requestBody.node == 3
? "kpiRole.child3Id LIKE :nodeId" ? "kpiRole.child3Id LIKE :nodeId"
: node == 2 : requestBody.node == 2
? "kpiRole.child2Id LIKE :nodeId" ? "kpiRole.child2Id LIKE :nodeId"
: node == 1 : requestBody.node == 1
? "kpiRole.child1Id LIKE :nodeId" ? "kpiRole.child1Id LIKE :nodeId"
: "kpiRole.rootId LIKE :nodeId" : "kpiRole.rootId LIKE :nodeId"
: "1=1", : "1=1",
{ {
nodeId: nodeId, nodeId: requestBody.nodeId,
}, },
) )
.andWhere( .andWhere(
kpiPeriodId != undefined && kpiPeriodId != null && kpiPeriodId != "" requestBody.isNull === false && requestBody.year && requestBody.period
? "kpiRole.kpiPeriod LIKE :kpiPeriodId" ? "kpiRole.year LIKE :year AND kpiRole.period LIKE :period"
: "1=1", : "1=1",
{ {
kpiPeriodId: kpiPeriodId, year: `%${requestBody.year}%`,
period: `%${requestBody.period}%`,
}, },
) )
.andWhere(position != undefined ? "kpiRole.position LIKE :position" : "1=1", { .andWhere(requestBody.position != undefined ? "kpiRole.position LIKE :position" : "1=1", {
position: `%${position}%`, position: `%${requestBody.position}%`,
}) })
.andWhere( .andWhere(
new Brackets((qb) => { new Brackets((qb) => {
qb.orWhere("kpiRole.including LIKE :keyword", { keyword: `%${keyword}%` }).orWhere( qb.orWhere("kpiRole.including LIKE :keyword", { keyword: `%${requestBody.keyword}%` }).orWhere(
"kpiRole.includingName LIKE :keyword", "kpiRole.includingName LIKE :keyword",
{ keyword: `%${keyword}%` }, { keyword: `%${requestBody.keyword}%` },
); );
}), }),
) )
@ -369,8 +445,8 @@ export class kpiRoleController extends Controller {
"kpiRole.createdAt", "kpiRole.createdAt",
]) ])
.orderBy("kpiRole.createdAt", "DESC") .orderBy("kpiRole.createdAt", "DESC")
.skip((page - 1) * pageSize) .skip((requestBody.page - 1) * requestBody.pageSize)
.take(pageSize) .take(requestBody.pageSize)
.getManyAndCount(); .getManyAndCount();
return new HttpSuccess({ data: kpiRole, total }); return new HttpSuccess({ data: kpiRole, total });
@ -463,7 +539,6 @@ export class kpiRoleController extends Controller {
}); });
await this.kpiRoleRepository.save(remainingKpiRoles); await this.kpiRoleRepository.save(remainingKpiRoles);
} }
return new HttpSuccess(); return new HttpSuccess();
} }
} }

View file

@ -356,8 +356,8 @@ export class createKpiPlan {
strategy: number; strategy: number;
@Column() @Column()
strategyId: string | null; strategyId: string | null;
@Column() // @Column()
kpiPeriodId: string | null; // kpiPeriodId: string | null;
@Column() @Column()
documentInfoEvidence: string | null; documentInfoEvidence: string | null;
} }
@ -401,8 +401,8 @@ export class updateKpiPlan {
strategy: number; strategy: number;
@Column() @Column()
strategyId: string | null; strategyId: string | null;
@Column() // @Column()
kpiPeriodId: string | null; // kpiPeriodId: string | null;
@Column() @Column()
documentInfoEvidence: string | null; documentInfoEvidence: string | null;
} }