no message

This commit is contained in:
Kittapath 2024-07-10 10:45:09 +07:00
parent 19703a4f0b
commit f0af5a5c83
4 changed files with 81 additions and 89 deletions

View file

@ -187,9 +187,9 @@ export class kpiCapacityController extends Controller {
@Get("head")
async GetKpiCapacityTypeHEAD() {
const kpiCapacity = await this.kpiCapacityRepository.find({
where: {
type: In(["HEAD"]),
kpiCapacityDetails: { level: "1" }
where: {
type: In(["HEAD"]),
kpiCapacityDetails: { level: "1" },
},
select: ["id", "name"],
relations: ["kpiCapacityDetails"],
@ -199,7 +199,7 @@ export class kpiCapacityController extends Controller {
id: x.id,
name: x.name,
level: x.kpiCapacityDetails.length > 0 ? x.kpiCapacityDetails[0].level : null,
description: x.kpiCapacityDetails.length > 0 ? x.kpiCapacityDetails[0].description : null,
description: x.kpiCapacityDetails.length > 0 ? x.kpiCapacityDetails[0].description : null,
}));
return new HttpSuccess(mapData);
@ -212,34 +212,34 @@ export class kpiCapacityController extends Controller {
*
*/
@Get("group")
async GetKpiCapacityTypeGROUP(
@Query("positionName") positionName: string
) {
async GetKpiCapacityTypeGROUP(@Query("positionName") positionName: string) {
let position = await this.positionRepository.findOne({
where: { name: Like(`%${positionName}%`) },
relations: ["kpiLink.kpiCapacitys"]
})
where: { name: Like(`${positionName}`) },
relations: ["kpiLink", "kpiLink.kpiCapacitys"],
});
if (position == null) {
position = await this.positionRepository.findOne({
position = await this.positionRepository.findOne({
where: { name: "นักจัดการงานทั่วไป" },
relations: ["kpiLink.kpiCapacitys"]
})
relations: ["kpiLink", "kpiLink.kpiCapacitys"],
});
}
let positionLinkId: any
positionLinkId = position != null ? position : null
const kpiCapacityIds = positionLinkId.kpiLink.kpiCapacitys.map((kpiCapacity:any) => kpiCapacity.id)
let positionLinkId: any;
positionLinkId = position != null ? position : null;
if (positionLinkId == null || positionLinkId.kpiLink == null) return new HttpSuccess([]);
const kpiCapacityIds = positionLinkId.kpiLink.kpiCapacitys.map(
(kpiCapacity: any) => kpiCapacity.id,
);
const kpiCapacity = await this.kpiCapacityRepository.find({
where: {
where: {
id: In(kpiCapacityIds),
type: In(["GROUP"]),
kpiCapacityDetails: { level: "2" }
type: In(["GROUP"]),
kpiCapacityDetails: { level: "2" },
},
select: ["id", "name"],
relations: ["kpiCapacityDetails",],
relations: ["kpiCapacityDetails"],
});
const mapData = kpiCapacity.map((x) => ({