fix api
This commit is contained in:
parent
88e352cea3
commit
dd7c8ea670
1 changed files with 30 additions and 3 deletions
|
|
@ -22,6 +22,7 @@ import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
|||
import { off } from "process";
|
||||
import Extension from "../interfaces/extension";
|
||||
import { KpiRole } from "../entities/kpiRole";
|
||||
import { KpiPlan } from "../entities/kpiPlan";
|
||||
|
||||
@Route("api/v1/kpi/report")
|
||||
@Tags("Report")
|
||||
|
|
@ -30,6 +31,7 @@ export class ReportController extends Controller {
|
|||
private kpiPeriodRepository = AppDataSource.getRepository(KpiPeriod);
|
||||
private kpiUserEvaluationRepository = AppDataSource.getRepository(KpiUserEvaluation);
|
||||
private kpiRoleRepository = AppDataSource.getRepository(KpiRole);
|
||||
private kpiPlanRepository = AppDataSource.getRepository(KpiPlan);
|
||||
|
||||
@Post("announcement")
|
||||
async GetReportAnnouncement(
|
||||
|
|
@ -135,15 +137,40 @@ export class ReportController extends Controller {
|
|||
|
||||
@Post("kpi9/{periodId}")
|
||||
async GetReportKpi9(
|
||||
@Path() periodId?: string | null,
|
||||
@Path() profileId?: string | null,
|
||||
) {
|
||||
|
||||
let formattedData: any;
|
||||
if (profileId) {
|
||||
const kpiUserEvaluation = await this.kpiUserEvaluationRepository.findOne({
|
||||
relations: ["kpiUserRoles", "kpiUserPlanneds", "kpiUserSpecials", "kpiUserCapacitys"],
|
||||
where: { profileId: profileId },
|
||||
});
|
||||
if (!kpiUserEvaluation)
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ประเมิน");
|
||||
|
||||
//period
|
||||
const period = await this.kpiPeriodRepository.findOneBy({
|
||||
id: kpiUserEvaluation?.kpiPeriodId,
|
||||
});
|
||||
if (!period) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลงวดการประเมิน");
|
||||
|
||||
const kpiRole = await this.kpiRoleRepository.find({
|
||||
where: { kpiPeriodId: period?.id },
|
||||
});
|
||||
|
||||
const kpiPlan = await this.kpiPlanRepository.find({
|
||||
where: { kpiPeriodId: period?.id },
|
||||
});
|
||||
|
||||
formattedData = {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
return new HttpSuccess({
|
||||
template: "KPI9",
|
||||
reportName: "KPI9",
|
||||
data: {},
|
||||
data: formattedData,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue