เพิ่ม parth api ใช่ซ้ำกันในหลายเมนู (ข้อมูลแบบปนะเมิน>>>ตัวชี้วัด)
This commit is contained in:
parent
b95cda9512
commit
62d3824b4a
3 changed files with 279 additions and 0 deletions
|
|
@ -618,6 +618,118 @@ export class kpiPlanController extends Controller {
|
|||
return new HttpSuccess({ data: kpiPlan, total });
|
||||
}
|
||||
|
||||
/**
|
||||
* API list ตัวชี้วัดตามแผนฯ
|
||||
* @param page
|
||||
* @param pageSize
|
||||
* @param keyword
|
||||
*/
|
||||
@Post("search-kpi-plan")
|
||||
async searchKpiPlan(
|
||||
@Request() request: RequestWithUser,
|
||||
@Body()
|
||||
requestBody: {
|
||||
page: number;
|
||||
pageSize: number;
|
||||
year?: string | null;
|
||||
period?: string | null;
|
||||
nodeId?: string | null;
|
||||
node?: number | null;
|
||||
keyword?: string | null;
|
||||
isAll?: boolean | false;
|
||||
// isNull?: boolean | false;
|
||||
},
|
||||
) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_KPI_LIST");
|
||||
let condition = "";
|
||||
let parameters: any = {};
|
||||
if (requestBody.isAll === false) {
|
||||
switch (requestBody.node) {
|
||||
case 0:
|
||||
condition = "kpiPlan.rootId LIKE :nodeId AND kpiPlan.child1Id IS NULL";
|
||||
break;
|
||||
case 1:
|
||||
condition = "kpiPlan.child1Id LIKE :nodeId AND kpiPlan.child2Id IS NULL";
|
||||
break;
|
||||
case 2:
|
||||
condition = "kpiPlan.child2Id LIKE :nodeId AND kpiPlan.child3Id IS NULL";
|
||||
break;
|
||||
case 3:
|
||||
condition = "kpiPlan.child3Id LIKE :nodeId AND kpiPlan.child4Id IS NULL";
|
||||
break;
|
||||
case 4:
|
||||
condition = "kpiPlan.child4Id LIKE :nodeId";
|
||||
break;
|
||||
default:
|
||||
condition = "1=1";
|
||||
break;
|
||||
}
|
||||
parameters.nodeId = `%${requestBody.nodeId}%`;
|
||||
} else {
|
||||
switch (requestBody.node) {
|
||||
case 0:
|
||||
condition = "kpiPlan.rootId LIKE :nodeId";
|
||||
break;
|
||||
case 1:
|
||||
condition = "kpiPlan.child1Id LIKE :nodeId";
|
||||
break;
|
||||
case 2:
|
||||
condition = "kpiPlan.child2Id LIKE :nodeId";
|
||||
break;
|
||||
case 3:
|
||||
condition = "kpiPlan.child3Id LIKE :nodeId";
|
||||
break;
|
||||
case 4:
|
||||
condition = "kpiPlan.child4Id LIKE :nodeId";
|
||||
break;
|
||||
default:
|
||||
condition = "1=1";
|
||||
break;
|
||||
}
|
||||
parameters.nodeId = `%${requestBody.nodeId}%`;
|
||||
}
|
||||
const [kpiPlan, total] = await AppDataSource.getRepository(KpiPlan)
|
||||
.createQueryBuilder("kpiPlan")
|
||||
.leftJoinAndSelect("kpiPlan.kpiPeriod", "kpiPeriod")
|
||||
.andWhere(condition, parameters)
|
||||
.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}%`,
|
||||
});
|
||||
}),
|
||||
)
|
||||
.select([
|
||||
"kpiPlan.id",
|
||||
"kpiPeriod.year",
|
||||
"kpiPeriod.durationKPI",
|
||||
"kpiPlan.including",
|
||||
"kpiPlan.includingName",
|
||||
"kpiPlan.createdAt",
|
||||
])
|
||||
.orderBy("kpiPlan.createdAt", "DESC")
|
||||
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||
.take(requestBody.pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
return new HttpSuccess({ data: kpiPlan, total });
|
||||
}
|
||||
|
||||
/**
|
||||
* API list ตัวชี้วัดตามแผนฯ
|
||||
* @param page
|
||||
|
|
|
|||
|
|
@ -552,6 +552,121 @@ export class kpiRoleController extends Controller {
|
|||
return new HttpSuccess({ data: kpiRole, total });
|
||||
}
|
||||
|
||||
/**
|
||||
* API list ตัวชี้วัดตามตำแหน่ง
|
||||
* @param page
|
||||
* @param pageSize
|
||||
* @param keyword
|
||||
*/
|
||||
@Post("search-kpi-role")
|
||||
async searchKpiRole(
|
||||
@Request() request: RequestWithUser,
|
||||
@Body()
|
||||
requestBody: {
|
||||
page: number;
|
||||
pageSize: number;
|
||||
year?: string | null;
|
||||
period?: string | null;
|
||||
nodeId?: string | null;
|
||||
node?: number | null;
|
||||
position?: string | null;
|
||||
keyword?: string | null;
|
||||
isAll?: boolean | false;
|
||||
},
|
||||
) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_KPI_LIST");
|
||||
let condition = "";
|
||||
let parameters: any = {};
|
||||
if (requestBody.isAll === false) {
|
||||
switch (requestBody.node) {
|
||||
case 0:
|
||||
condition = "kpiRole.rootId LIKE :nodeId AND kpiRole.child1Id IS NULL";
|
||||
break;
|
||||
case 1:
|
||||
condition = "kpiRole.child1Id LIKE :nodeId AND kpiRole.child2Id IS NULL";
|
||||
break;
|
||||
case 2:
|
||||
condition = "kpiRole.child2Id LIKE :nodeId AND kpiRole.child3Id IS NULL";
|
||||
break;
|
||||
case 3:
|
||||
condition = "kpiRole.child3Id LIKE :nodeId AND kpiRole.child4Id IS NULL";
|
||||
break;
|
||||
case 4:
|
||||
condition = "kpiRole.child4Id LIKE :nodeId";
|
||||
break;
|
||||
default:
|
||||
condition = "1=1";
|
||||
break;
|
||||
}
|
||||
parameters.nodeId = `%${requestBody.nodeId}%`;
|
||||
} else {
|
||||
switch (requestBody.node) {
|
||||
case 0:
|
||||
condition = "kpiRole.rootId LIKE :nodeId";
|
||||
break;
|
||||
case 1:
|
||||
condition = "kpiRole.child1Id LIKE :nodeId";
|
||||
break;
|
||||
case 2:
|
||||
condition = "kpiRole.child2Id LIKE :nodeId";
|
||||
break;
|
||||
case 3:
|
||||
condition = "kpiRole.child3Id LIKE :nodeId";
|
||||
break;
|
||||
case 4:
|
||||
condition = "kpiRole.child4Id LIKE :nodeId";
|
||||
break;
|
||||
default:
|
||||
condition = "1=1";
|
||||
break;
|
||||
}
|
||||
parameters.nodeId = `%${requestBody.nodeId}%`;
|
||||
}
|
||||
const [kpiRole, total] = await AppDataSource.getRepository(KpiRole)
|
||||
.createQueryBuilder("kpiRole")
|
||||
.leftJoinAndSelect("kpiRole.kpiPeriod", "kpiPeriod")
|
||||
.andWhere(condition, parameters)
|
||||
.andWhere(requestBody.year ? "kpiRole.year LIKE :year" : "1=1", {
|
||||
year: `%${requestBody.year}%`,
|
||||
})
|
||||
.andWhere(requestBody.period ? "kpiRole.period LIKE :period" : "1=1", {
|
||||
period: `%${requestBody.period}%`,
|
||||
})
|
||||
.andWhere(requestBody.position != undefined ? "kpiRole.position LIKE :position" : "1=1", {
|
||||
position: `%${requestBody.position}%`,
|
||||
})
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere("kpiRole.including LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiRole.includingName LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiRole.year LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiRole.period LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
});
|
||||
}),
|
||||
)
|
||||
.select([
|
||||
"kpiRole.id",
|
||||
"kpiPeriod.year",
|
||||
"kpiPeriod.durationKPI",
|
||||
"kpiRole.including",
|
||||
"kpiRole.includingName",
|
||||
"kpiRole.createdAt",
|
||||
])
|
||||
.orderBy("kpiRole.createdAt", "DESC")
|
||||
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||
.take(requestBody.pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
return new HttpSuccess({ data: kpiRole, total });
|
||||
}
|
||||
|
||||
/**
|
||||
* API list ตัวชี้วัดตามตำแหน่ง
|
||||
* @param page
|
||||
|
|
|
|||
|
|
@ -261,6 +261,58 @@ export class kpiSpecialController extends Controller {
|
|||
return new HttpSuccess({ data: kpiSpecial, total });
|
||||
}
|
||||
|
||||
/**
|
||||
* API list ตัวชี้วัด Special
|
||||
* @param page
|
||||
* @param pageSize
|
||||
* @param keyword
|
||||
*/
|
||||
@Post("search-kpi-special")
|
||||
async searchKpiSpecial(
|
||||
@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_KPI_LIST");
|
||||
const [kpiSpecial, total] = await AppDataSource.getRepository(KpiSpecial)
|
||||
.createQueryBuilder("kpiSpecial")
|
||||
.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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue