no message
This commit is contained in:
parent
dfd9ebb3c1
commit
483ad486dc
9 changed files with 943 additions and 41 deletions
|
|
@ -117,13 +117,51 @@ export class kpiSpecialController extends Controller {
|
|||
return new HttpSuccess(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* API ตัวชี้วัด Special
|
||||
* @param id Guid, *Id ตัวชี้วัด Special
|
||||
*/
|
||||
@Get("edit/{id}")
|
||||
async GetKpiSpecialByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
let _data = await new permission().PermissionGet(request, "SYS_EVA_INDICATOR");
|
||||
const KpiSpecial = await this.kpiSpecialRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!KpiSpecial) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัด Specialนี้");
|
||||
}
|
||||
|
||||
const mapData = {
|
||||
id: KpiSpecial.id,
|
||||
period: KpiSpecial.period,
|
||||
year: KpiSpecial.year,
|
||||
including: KpiSpecial.including,
|
||||
includingName: KpiSpecial.includingName,
|
||||
target: KpiSpecial.target,
|
||||
unit: KpiSpecial.unit,
|
||||
weight: KpiSpecial.weight,
|
||||
point: KpiSpecial.point,
|
||||
summary: KpiSpecial.summary,
|
||||
documentInfoEvidence: KpiSpecial.documentInfoEvidence,
|
||||
startDate: KpiSpecial.startDate,
|
||||
endDate: KpiSpecial.endDate,
|
||||
achievement1: KpiSpecial.achievement1,
|
||||
achievement2: KpiSpecial.achievement2,
|
||||
achievement3: KpiSpecial.achievement3,
|
||||
achievement4: KpiSpecial.achievement4,
|
||||
achievement5: KpiSpecial.achievement5,
|
||||
meaning: KpiSpecial.meaning,
|
||||
formula: KpiSpecial.formula,
|
||||
};
|
||||
return new HttpSuccess(mapData);
|
||||
}
|
||||
|
||||
/**
|
||||
* API ตัวชี้วัด Special
|
||||
* @param id Guid, *Id ตัวชี้วัด Special
|
||||
*/
|
||||
@Get("{id}")
|
||||
async GetKpiSpecialById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||
const KpiSpecial = await this.kpiSpecialRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
@ -173,6 +211,70 @@ export class kpiSpecialController extends Controller {
|
|||
period?: string | null;
|
||||
keyword?: string | null;
|
||||
},
|
||||
) {
|
||||
// let condition: any = {};
|
||||
// if (requestBody.keyword !== undefined && requestBody.keyword !== "") {
|
||||
// condition = {
|
||||
// where: [
|
||||
// {
|
||||
// including: Like(`%${requestBody.keyword}%`),
|
||||
// includingName: Like(`%${requestBody.keyword}%`),
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
// }
|
||||
|
||||
const [kpiSpecial, total] = await AppDataSource.getRepository(KpiSpecial)
|
||||
.createQueryBuilder("kpiSpecial")
|
||||
// .andWhere(condition)
|
||||
.andWhere(requestBody.year ? "kpiSpecial.year LIKE :year" : "1=1", {
|
||||
year: `%${requestBody.year}%`,
|
||||
})
|
||||
.andWhere(requestBody.period ? "kpiSpecial.period LIKE :period" : "1=1", {
|
||||
period: `%${requestBody.period}%`,
|
||||
})
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere("kpiSpecial.including LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
}).orWhere("kpiSpecial.includingName LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
});
|
||||
}),
|
||||
)
|
||||
.select([
|
||||
"kpiSpecial.id",
|
||||
"kpiSpecial.year",
|
||||
"kpiSpecial.period",
|
||||
"kpiSpecial.including",
|
||||
"kpiSpecial.includingName",
|
||||
"kpiSpecial.createdAt",
|
||||
])
|
||||
.orderBy("kpiSpecial.createdAt", "DESC")
|
||||
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||
.take(requestBody.pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
return new HttpSuccess({ data: kpiSpecial, total });
|
||||
}
|
||||
|
||||
/**
|
||||
* API list ตัวชี้วัด Special
|
||||
* @param page
|
||||
* @param pageSize
|
||||
* @param keyword
|
||||
*/
|
||||
@Post("search-edit")
|
||||
async listKpiSpecialEdit(
|
||||
@Request() request: RequestWithUser,
|
||||
@Body()
|
||||
requestBody: {
|
||||
page: number;
|
||||
pageSize: number;
|
||||
year?: string | null;
|
||||
period?: string | null;
|
||||
keyword?: string | null;
|
||||
},
|
||||
) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||
// let condition: any = {};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue