no message

This commit is contained in:
Kittapath 2024-06-13 11:48:15 +07:00
parent 0b632803fe
commit 4a07ca669c
3 changed files with 116 additions and 64 deletions

View file

@ -445,51 +445,30 @@ export class kpiPlanController extends Controller {
}
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)
.createQueryBuilder("kpiPlan")
.leftJoinAndSelect("kpiPlan.kpiPeriod", "kpiPeriod")
.andWhere(condition, parameters)
// .andWhere(
// requestBody.year && requestBody.period
// ? "kpiPlan.year LIKE :year AND kpiPlan.period LIKE :period"
// : "1=1",
// {
// year: `%${requestBody.year}%`,
// period: `%${requestBody.period}%`,
// },
// )
.andWhere(
requestBody.year
? "kpiPlan.year LIKE :year"
: "1=1",
{
year: `%${requestBody.year}%`,
},
)
.andWhere(
requestBody.period
? "kpiPlan.period LIKE :period"
: "1=1",
{
period: `%${requestBody.period}%`,
},
)
.andWhere(requestBody.year ? "kpiPlan.year LIKE :year" : "1=1", {
year: `%${requestBody.year}%`,
})
.andWhere(requestBody.period ? "kpiPlan.period LIKE :period" : "1=1", {
period: `%${requestBody.period}%`,
})
.andWhere(
new Brackets((qb) => {
qb.orWhere("kpiPlan.including LIKE :keyword", {
keyword: `%${requestBody.keyword}%`,
}).orWhere("kpiPlan.includingName LIKE :keyword", {
keyword: `%${requestBody.keyword}%`,
}).orWhere("kpiPlan.year LIKE :keyword",{
keyword: `%${requestBody.keyword}%`
}).orWhere("kpiPlan.period LIKE :keyword",{
keyword: `%${requestBody.keyword}%`
});
})
.orWhere("kpiPlan.includingName LIKE :keyword", {
keyword: `%${requestBody.keyword}%`,
})
.orWhere("kpiPlan.year LIKE :keyword", {
keyword: `%${requestBody.keyword}%`,
})
.orWhere("kpiPlan.period LIKE :keyword", {
keyword: `%${requestBody.keyword}%`,
});
}),
)
.select([
@ -594,21 +573,21 @@ export class kpiPlanController extends Controller {
return new HttpSuccess();
}
/**
/**
* API
* @param id Guid, *Id
*/
@Get("history/{id}")
async GetHistory(@Path() id: string) {
const kpiPlanHistory = await this.kpiPlanHistoryRepository.find({
where: { kpiPlanId: id },
order:{
createdAt: "ASC"
}
});
if (!kpiPlanHistory) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัดิตัวชี้วัดตามแผนนี้");
}
return new HttpSuccess(kpiPlanHistory);
@Get("history/{id}")
async GetHistory(@Path() id: string) {
const kpiPlanHistory = await this.kpiPlanHistoryRepository.find({
where: { kpiPlanId: id },
order: {
createdAt: "ASC",
},
});
if (!kpiPlanHistory) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัดิตัวชี้วัดตามแผนนี้");
}
return new HttpSuccess(kpiPlanHistory);
}
}