คอมเม้นผู้บังคับบัญชา
This commit is contained in:
parent
9576d26753
commit
7f7b676750
9 changed files with 318 additions and 10 deletions
|
|
@ -26,9 +26,14 @@ import {
|
|||
createKpiUserEvaluation,
|
||||
updateKpiUserCheckEvaluation,
|
||||
updateKpiUserEvaluation,
|
||||
updateKpiUserPointEvaluation,
|
||||
} from "../entities/kpiUserEvaluation";
|
||||
import { Like, In } from "typeorm";
|
||||
import { Like, In, Brackets } from "typeorm";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
import {
|
||||
KpiUserEvaluationReason,
|
||||
updateKpiUserReasonEvaluation,
|
||||
} from "../entities/kpiUserEvaluationReason";
|
||||
|
||||
@Route("api/v1/kpi/user/evaluation")
|
||||
@Tags("kpiUserEvaluation")
|
||||
|
|
@ -41,6 +46,7 @@ import CallAPI from "../interfaces/call-api";
|
|||
export class KpiUserEvaluationController extends Controller {
|
||||
private kpiPeriodRepository = AppDataSource.getRepository(KpiPeriod);
|
||||
private kpiUserEvalutionRepository = AppDataSource.getRepository(KpiUserEvaluation);
|
||||
private kpiUserEvaluationReasonRepository = AppDataSource.getRepository(KpiUserEvaluationReason);
|
||||
|
||||
/**
|
||||
* API
|
||||
|
|
@ -53,13 +59,20 @@ export class KpiUserEvaluationController extends Controller {
|
|||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("kpiPeriodId") kpiPeriodId?: string,
|
||||
// @Query("keyword") keyword?: string,
|
||||
@Query("keyword") keyword?: string,
|
||||
) {
|
||||
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||
.createQueryBuilder("kpiUserEvaluation")
|
||||
.andWhere(kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", {
|
||||
kpiPeriodId: kpiPeriodId,
|
||||
})
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere("kpiUserEvaluation.prefix LIKE :keyword", { keyword: `%${keyword}%` })
|
||||
.orWhere("kpiUserEvaluation.firstName LIKE :keyword", { keyword: `%${keyword}%` })
|
||||
.orWhere("kpiUserEvaluation.lastName LIKE :keyword", { keyword: `%${keyword}%` });
|
||||
}),
|
||||
)
|
||||
.orderBy("kpiUserEvaluation.createdAt", "ASC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
|
|
@ -153,6 +166,85 @@ export class KpiUserEvaluationController extends Controller {
|
|||
return new HttpSuccess(kpiUserEvaluation.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขคนประเมิน (USER)
|
||||
*
|
||||
* @summary แก้ไขคนประเมิน (USER)
|
||||
*
|
||||
* @param {string} id Guid, *Id คนประเมิน (USER)
|
||||
*/
|
||||
@Put("point/{id}")
|
||||
async updateKpiUserPointEvaluation(
|
||||
@Path() id: string,
|
||||
@Body() requestBody: updateKpiUserPointEvaluation,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!kpiUserEvaluation) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
||||
);
|
||||
}
|
||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||
Object.assign(kpiUserEvaluation, requestBody);
|
||||
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
|
||||
return new HttpSuccess(kpiUserEvaluation.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขหมายเหตุ (USER)
|
||||
*
|
||||
* @summary แก้ไขหมายเหตุ (USER)
|
||||
*
|
||||
* @param {string} id Guid, *Id คนประเมิน (USER)
|
||||
*/
|
||||
@Put("{type}/{id}")
|
||||
async updateKpiUserEvaluatorEvaluation(
|
||||
@Path() id: string,
|
||||
@Path() type: string,
|
||||
@Body() requestBody: updateKpiUserReasonEvaluation,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!kpiUserEvaluation) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
||||
);
|
||||
}
|
||||
|
||||
const kpiUserEvaluationReason = Object.assign(new KpiUserEvaluationReason(), requestBody);
|
||||
kpiUserEvaluationReason.type = type.trim().toUpperCase();
|
||||
kpiUserEvaluationReason.kpiUserEvaluationId = id;
|
||||
kpiUserEvaluationReason.createdUserId = request.user.sub;
|
||||
kpiUserEvaluationReason.createdFullName = request.user.name;
|
||||
kpiUserEvaluationReason.lastUpdateUserId = request.user.sub;
|
||||
kpiUserEvaluationReason.lastUpdateFullName = request.user.name;
|
||||
await this.kpiUserEvaluationReasonRepository.save(kpiUserEvaluationReason);
|
||||
return new HttpSuccess(kpiUserEvaluation.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* API list หมายเหตุ (USER)
|
||||
*
|
||||
* @summary list หมายเหตุ (USER)
|
||||
*
|
||||
* @param {string} id Guid, *Id คนประเมิน (USER)
|
||||
*/
|
||||
@Get("{type}/{id}")
|
||||
async listKpiUserCommanderEvaluation(@Path() id: string, @Path() type: string) {
|
||||
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonRepository.find({
|
||||
where: { kpiUserEvaluationId: id, type: type.trim().toUpperCase() },
|
||||
});
|
||||
return new HttpSuccess(kpiUserEvaluationReason);
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขรายการประเมินผลการปฏิบัติราชการระดับบุคคล (USER)
|
||||
*
|
||||
|
|
@ -217,6 +309,10 @@ export class KpiUserEvaluationController extends Controller {
|
|||
"evaluatorId",
|
||||
"commanderId",
|
||||
"commanderHighId",
|
||||
"plannedPoint",
|
||||
"rolePoint",
|
||||
"specialPoint",
|
||||
"capacityPoint",
|
||||
],
|
||||
});
|
||||
if (!kpiUserEvaluation) {
|
||||
|
|
@ -264,6 +360,10 @@ export class KpiUserEvaluationController extends Controller {
|
|||
commanderId: item.commanderId,
|
||||
commanderHighId: item.commanderHighId,
|
||||
createdAt: item.createdAt,
|
||||
plannedPoint: item.plannedPoint,
|
||||
rolePoint: item.rolePoint,
|
||||
specialPoint: item.specialPoint,
|
||||
capacityPoint: item.capacityPoint,
|
||||
}));
|
||||
return new HttpSuccess({ data: mapData, total });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue