แก้บัค kpi
This commit is contained in:
parent
cb26678af0
commit
8d38768494
3 changed files with 13 additions and 10 deletions
|
|
@ -350,11 +350,7 @@ export class kpiCapacityController extends Controller {
|
|||
const [kpiCapacity, total] = await AppDataSource.getRepository(KpiCapacity)
|
||||
.createQueryBuilder("kpiCapacity")
|
||||
.leftJoinAndSelect("kpiCapacity.kpiCapacityDetails", "kpiCapacityDetail")
|
||||
.andWhere(
|
||||
keyword == undefined
|
||||
? "1=1"
|
||||
: [{ name: Like(`%${keyword}%`) }, { description: Like(`%${keyword}%`) }],
|
||||
)
|
||||
.andWhere(keyword == undefined ? "1=1" : [{ name: Like(`%${keyword}%`) }])
|
||||
.andWhere(type == undefined ? "1=1" : { type: type })
|
||||
.orderBy("kpiCapacity.createdAt", "ASC")
|
||||
.skip((page - 1) * pageSize)
|
||||
|
|
|
|||
|
|
@ -18,12 +18,14 @@ import {
|
|||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { Like, Not } from "typeorm";
|
||||
import { In, Like, Not } from "typeorm";
|
||||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import { KpiGroup, createKpiGroup, updateKpiGroup } from "../entities/kpiGroup";
|
||||
import permission from "../interfaces/permission";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
import { KpiLink } from "../entities/kpiLink";
|
||||
import { Position } from "../entities/position";
|
||||
|
||||
@Route("api/v1/kpi/group")
|
||||
@Tags("kpiGroup")
|
||||
|
|
@ -35,6 +37,8 @@ import { setLogDataDiff } from "../interfaces/utils";
|
|||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class kpiGroupController extends Controller {
|
||||
private kpiGroupRepository = AppDataSource.getRepository(KpiGroup);
|
||||
private kpiLinkRepository = AppDataSource.getRepository(KpiLink);
|
||||
private positionRepository = AppDataSource.getRepository(Position);
|
||||
|
||||
/**
|
||||
* API สร้างกลุ่มงาน
|
||||
|
|
@ -192,7 +196,11 @@ export class kpiGroupController extends Controller {
|
|||
if (!kpiGroup) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานนี้");
|
||||
}
|
||||
|
||||
const kpiLink = await this.kpiLinkRepository.find({
|
||||
where: { kpiGroupId: id },
|
||||
});
|
||||
await this.positionRepository.delete({ kpiLinkId: In(kpiLink.map((x) => x.id)) });
|
||||
await this.kpiLinkRepository.remove(kpiLink, { data: request });
|
||||
await this.kpiGroupRepository.remove(kpiGroup, { data: request });
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,17 +47,16 @@ export class kpiRoleController extends Controller {
|
|||
async createKpiRole(@Body() requestBody: createKpiRole, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionCreate(request, "SYS_EVA_INDICATOR");
|
||||
const kpiRole = Object.assign(new KpiRole(), requestBody);
|
||||
if (requestBody.year != null && requestBody.period != null) {
|
||||
if (requestBody.year != null && requestBody.period != null && requestBody.period != "") {
|
||||
const kpiPeriod = await this.kpiPeriodRepository
|
||||
.createQueryBuilder("kpiPeriod")
|
||||
.where("kpiPeriod.year = :year", { year: requestBody.year })
|
||||
.andWhere("kpiPeriod.durationKPI = :durationKPI", { durationKPI: requestBody.period })
|
||||
.getOne();
|
||||
if (!kpiPeriod) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้");
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลรอบการประเมินนี้ในปีงบประมาณ " + requestBody.year,
|
||||
"ไม่พบข้อมูลรอบการประเมินนี้ในปีงบประมาณ " + (requestBody.year + 543),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue