no message
This commit is contained in:
parent
dfd9ebb3c1
commit
483ad486dc
9 changed files with 943 additions and 41 deletions
|
|
@ -277,6 +277,92 @@ export class kpiCapacityController extends Controller {
|
|||
return new HttpSuccess(kpiCapacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายละเอียดรายการสมรรถนะ
|
||||
*
|
||||
* @summary รายละเอียดดรายการสมรรถนะ
|
||||
*
|
||||
* @param {string} id Guid, *Id รายการสมรรถนะ
|
||||
*/
|
||||
@Get("edit/{id}")
|
||||
@Example({
|
||||
type: "HEAD",
|
||||
name: "ชื่อสมรรถนะ",
|
||||
description: "คำจำกัดความ",
|
||||
kpiCapacityDetails: [
|
||||
{
|
||||
level: 1,
|
||||
description: "คำอธิบายระดับ",
|
||||
},
|
||||
],
|
||||
})
|
||||
async GetKpiCapacityByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
let _data = await new permission().PermissionGet(request, "SYS_EVA_COMPETENCY");
|
||||
const kpiCapacity = await this.kpiCapacityRepository.findOne({
|
||||
where: { id: id },
|
||||
select: ["type", "name", "description"],
|
||||
});
|
||||
if (!kpiCapacity) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรายการสมรรถนะนี้");
|
||||
}
|
||||
const kpiCapacityDetails = await this.kpiCapacityDetailRepository.find({
|
||||
where: { kpiCapacityId: id },
|
||||
select: ["level", "description"],
|
||||
order: { level: "ASC" },
|
||||
});
|
||||
const mapData = {
|
||||
type: kpiCapacity.type,
|
||||
name: kpiCapacity.name,
|
||||
description: kpiCapacity.description,
|
||||
capacityDetails: kpiCapacityDetails,
|
||||
};
|
||||
return new HttpSuccess(mapData);
|
||||
}
|
||||
/**
|
||||
* API รายการสมรรถนะ
|
||||
*
|
||||
* @summary รายการสมรรถนะ
|
||||
*
|
||||
*/
|
||||
@Get("edit")
|
||||
async listKpiCapacityEdit(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("type") type?: string,
|
||||
@Query("keyword") keyword?: string,
|
||||
) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||
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(type == undefined ? "1=1" : { type: type })
|
||||
.orderBy("kpiCapacity.createdAt", "ASC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const mapFormula = kpiCapacity.map((item) => ({
|
||||
id: item.id,
|
||||
type: item.type,
|
||||
name: item.name,
|
||||
description: item.description,
|
||||
capacityDetails: item.kpiCapacityDetails.map((detail) => {
|
||||
return {
|
||||
id: detail.id,
|
||||
description: detail.description,
|
||||
level: detail.level,
|
||||
capacityId: detail.kpiCapacityId,
|
||||
};
|
||||
}),
|
||||
}));
|
||||
return new HttpSuccess({ data: mapFormula, total });
|
||||
}
|
||||
/**
|
||||
* API รายละเอียดรายการสมรรถนะ
|
||||
*
|
||||
|
|
@ -297,7 +383,6 @@ export class kpiCapacityController extends Controller {
|
|||
],
|
||||
})
|
||||
async GetKpiCapacityById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||
const kpiCapacity = await this.kpiCapacityRepository.findOne({
|
||||
where: { id: id },
|
||||
select: ["type", "name", "description"],
|
||||
|
|
@ -333,7 +418,6 @@ export class kpiCapacityController extends Controller {
|
|||
@Query("type") type?: string,
|
||||
@Query("keyword") keyword?: string,
|
||||
) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||
const [kpiCapacity, total] = await AppDataSource.getRepository(KpiCapacity)
|
||||
.createQueryBuilder("kpiCapacity")
|
||||
.leftJoinAndSelect("kpiCapacity.kpiCapacityDetails", "kpiCapacityDetail")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue