เพิ่ม node id
This commit is contained in:
parent
71eac974de
commit
b433a44000
3 changed files with 95 additions and 38 deletions
|
|
@ -257,6 +257,11 @@ export class kpiPlanController extends Controller {
|
|||
achievement5: kpiPlan.achievement5,
|
||||
meaning: kpiPlan.meaning,
|
||||
formula: kpiPlan.formula,
|
||||
root: kpiPlan.rootId,
|
||||
child1: kpiPlan.child1Id,
|
||||
child2: kpiPlan.child2Id,
|
||||
child3: kpiPlan.child3Id,
|
||||
child4: kpiPlan.child4Id,
|
||||
node: node,
|
||||
nodeId: nodeId,
|
||||
nodeName: nodeName,
|
||||
|
|
@ -264,6 +269,11 @@ export class kpiPlanController extends Controller {
|
|||
strategy: strategy,
|
||||
strategyId: strategyId,
|
||||
strategyName: strategyName,
|
||||
strategyChild1: kpiPlan.strategyChild1Id,
|
||||
strategyChild2: kpiPlan.strategyChild2Id,
|
||||
strategyChild3: kpiPlan.strategyChild3Id,
|
||||
strategyChild4: kpiPlan.strategyChild4Id,
|
||||
strategyChild5: kpiPlan.strategyChild5Id,
|
||||
};
|
||||
return new HttpSuccess(formattedData);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -197,6 +197,11 @@ export class kpiRoleController extends Controller {
|
|||
achievement5: kpiRole.achievement5,
|
||||
meaning: kpiRole.meaning,
|
||||
formula: kpiRole.formula,
|
||||
root: kpiRole.rootId,
|
||||
child1: kpiRole.child1Id,
|
||||
child2: kpiRole.child2Id,
|
||||
child3: kpiRole.child3Id,
|
||||
child4: kpiRole.child4Id,
|
||||
node: node,
|
||||
nodeId: nodeId,
|
||||
nodeName: nodeName,
|
||||
|
|
|
|||
|
|
@ -14,14 +14,18 @@ import {
|
|||
SuccessResponse,
|
||||
Response,
|
||||
Query,
|
||||
ArrayValidator
|
||||
ArrayValidator,
|
||||
} from "tsoa";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import { KpiPeriod } from "../entities/kpiPeriod";
|
||||
import { KpiUserEvaluation, createKpiUserEvaluation, updateKpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
||||
import {
|
||||
KpiUserEvaluation,
|
||||
createKpiUserEvaluation,
|
||||
updateKpiUserEvaluation,
|
||||
} from "../entities/kpiUserEvaluation";
|
||||
import { Like, In } from "typeorm";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
|
||||
|
|
@ -37,18 +41,55 @@ export class KpiUserEvaluationController extends Controller {
|
|||
private kpiPeriodRepository = AppDataSource.getRepository(KpiPeriod);
|
||||
private kpiUserEvalutionRepository = AppDataSource.getRepository(KpiUserEvaluation);
|
||||
|
||||
/**
|
||||
* API
|
||||
*
|
||||
* @summary รายการประเมินผลการปฏิบัติราชการระดับบุคคลทั้งหมด
|
||||
*
|
||||
*/
|
||||
@Get("admin")
|
||||
async listKpiAdminEvaluation(
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("kpiPeriodId") kpiPeriodId?: string,
|
||||
// @Query("keyword") keyword?: string,
|
||||
) {
|
||||
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||
.createQueryBuilder("kpiUserEvaluation")
|
||||
.andWhere(kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", {
|
||||
kpiPeriodId: `%${kpiPeriodId}%`,
|
||||
})
|
||||
.orderBy("kpiUserEvaluation.createdAt", "ASC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const mapData = kpiUserEvaluation.map((item) => ({
|
||||
id: item.id,
|
||||
profileId: item.profileId,
|
||||
prefix: item.prefix,
|
||||
firstname: item.firstName,
|
||||
lastname: item.lastName,
|
||||
kpiPeriodId: item.kpiPeriodId,
|
||||
evaluationStatus: item.evaluationStatus,
|
||||
evaluationResults: item.evaluationResults,
|
||||
createdAt: item.createdAt,
|
||||
}));
|
||||
return new HttpSuccess({ data: mapData, total });
|
||||
}
|
||||
|
||||
/**
|
||||
* API สร้างรายการประเมินผลการปฏิบัติราชการระดับบุคคล (USER)
|
||||
*
|
||||
*
|
||||
* @summary สร้างรายการประเมินผลการปฏิบัติราชการระดับบุคคล (USER)
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Post()
|
||||
async CreateKpiUserEvaluation(
|
||||
@Body() requestBody: createKpiUserEvaluation,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
){
|
||||
) {
|
||||
const kpiPeriod = await this.kpiPeriodRepository.findOne({
|
||||
where: { id: requestBody.kpiPeriodId },
|
||||
});
|
||||
|
|
@ -58,32 +99,32 @@ export class KpiUserEvaluationController extends Controller {
|
|||
"ไม่พบข้อมูลรอบการประเมินผลการปฏิบัติหน้าที่ราชการนี้",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
const kpiUserEvaluation = Object.assign(new KpiUserEvaluation(), requestBody);
|
||||
await new CallAPI()
|
||||
.GetData(request, "org/profile/keycloak/position")
|
||||
.then((x) => {
|
||||
kpiUserEvaluation.profileId = x.profileId
|
||||
kpiUserEvaluation.prefix = x.prefix
|
||||
kpiUserEvaluation.firstName = x.firstName
|
||||
kpiUserEvaluation.lastName = x.lastName
|
||||
kpiUserEvaluation.profileId = x.profileId;
|
||||
kpiUserEvaluation.prefix = x.prefix;
|
||||
kpiUserEvaluation.firstName = x.firstName;
|
||||
kpiUserEvaluation.lastName = x.lastName;
|
||||
})
|
||||
.catch((x) => {});
|
||||
kpiUserEvaluation.evaluationStatus = "PENDING";
|
||||
kpiUserEvaluation.evaluationResults = "PENDING";
|
||||
kpiUserEvaluation.createdUserId = request.user.sub;
|
||||
kpiUserEvaluation.createdFullName = request.user.name;
|
||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
||||
return new HttpSuccess(kpiUserEvaluation.id);
|
||||
kpiUserEvaluation.evaluationStatus = "PENDING";
|
||||
kpiUserEvaluation.evaluationResults = "PENDING";
|
||||
kpiUserEvaluation.createdUserId = request.user.sub;
|
||||
kpiUserEvaluation.createdFullName = request.user.name;
|
||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
||||
return new HttpSuccess(kpiUserEvaluation.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขรายการประเมินผลการปฏิบัติราชการระดับบุคคล (USER)
|
||||
*
|
||||
*
|
||||
* @summary แก้ไขรายการประเมินผลการปฏิบัติราชการระดับบุคคล (USER)
|
||||
*
|
||||
*
|
||||
* @param {string} id Guid, *Id รายการประเมินผลการปฏิบัติราชการระดับบุคคล (USER)
|
||||
*/
|
||||
@Put("{id}")
|
||||
|
|
@ -119,7 +160,7 @@ export class KpiUserEvaluationController extends Controller {
|
|||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||
this.kpiUserEvalutionRepository.merge(kpiUserEvaluation, requestBody);
|
||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
||||
return new HttpSuccess(kpiUserEvaluation.id)
|
||||
return new HttpSuccess(kpiUserEvaluation.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -134,8 +175,18 @@ export class KpiUserEvaluationController extends Controller {
|
|||
async GetKpiUserEvaluationById(@Path() id: string) {
|
||||
const KpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||
where: { id: id },
|
||||
select: ["id", "profileId", "prefix", "firstName", "lastName", "kpiPeriodId", "evaluationStatus", "evaluationResults", "createdAt"],
|
||||
})
|
||||
select: [
|
||||
"id",
|
||||
"profileId",
|
||||
"prefix",
|
||||
"firstName",
|
||||
"lastName",
|
||||
"kpiPeriodId",
|
||||
"evaluationStatus",
|
||||
"evaluationResults",
|
||||
"createdAt",
|
||||
],
|
||||
});
|
||||
if (!KpiUserEvaluation) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
|
|
@ -158,20 +209,11 @@ export class KpiUserEvaluationController extends Controller {
|
|||
@Query("kpiPeriodId") kpiPeriodId?: string,
|
||||
// @Query("keyword") keyword?: string,
|
||||
) {
|
||||
|
||||
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||
.createQueryBuilder("kpiUserEvaluation")
|
||||
// .leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
||||
// .andWhere(
|
||||
// keyword == undefined
|
||||
// ? "1=1"
|
||||
// : [
|
||||
// { prefix: Like(`%${keyword}%`) },
|
||||
// { firstName: Like(`%${keyword}%`) },
|
||||
// { lastName: Like(`%${keyword}%`) },
|
||||
// ],
|
||||
// )
|
||||
.andWhere(kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", { kpiPeriodId: `%${kpiPeriodId}%` })
|
||||
.andWhere(kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", {
|
||||
kpiPeriodId: `%${kpiPeriodId}%`,
|
||||
})
|
||||
.orderBy("kpiUserEvaluation.createdAt", "ASC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
|
|
@ -193,9 +235,9 @@ export class KpiUserEvaluationController extends Controller {
|
|||
|
||||
/**
|
||||
* API ลบรายการประเมินผลการปฏิบัติราชการระดับบุคคล (USER)
|
||||
*
|
||||
*
|
||||
* @summary ลบรายการประเมินผลการปฏิบัติราชการระดับบุคคล (USER)
|
||||
*
|
||||
*
|
||||
* @param {string} id Guid, *Id รายการประเมินผลการปฏิบัติราชการระดับบุคคล (USER)
|
||||
*/
|
||||
@Delete("{id}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue