fixing path
This commit is contained in:
parent
400b9c0b28
commit
ba612f1b2b
12 changed files with 325 additions and 723 deletions
|
|
@ -20,35 +20,25 @@ import { AppDataSource } from "../database/data-source";
|
|||
import { AssignDirector } from "../entities/AssignDirector";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { Assign } from "../entities/Assign";
|
||||
import {
|
||||
CreateEvaluateCommander,
|
||||
EvaluateCommander,
|
||||
} from "../entities/EvaluateCommander";
|
||||
import { Personal } from "../entities/Personal";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
import { EvaluateChairman } from "../entities/EvaluateChairman";
|
||||
import {
|
||||
CreateEvaluateResult,
|
||||
EvaluateResult,
|
||||
} from "../entities/EvaluateResult";
|
||||
import { CreateEvaluateResult, EvaluateResult } from "../entities/EvaluateResult";
|
||||
|
||||
@Route("api/v1/evaluate-result")
|
||||
@Route("api/v1/probation/evaluate-result")
|
||||
@Tags("แบบรายงานการประเมินฯ")
|
||||
@Security("bearerAuth")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง"
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class EvaluateResultController extends Controller {
|
||||
private assignDirectorRepository =
|
||||
AppDataSource.getRepository(AssignDirector);
|
||||
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector);
|
||||
private assignRepository = AppDataSource.getRepository(Assign);
|
||||
private evaluateChairmanRepository =
|
||||
AppDataSource.getRepository(EvaluateChairman);
|
||||
private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman);
|
||||
private personalRepository = AppDataSource.getRepository(Personal);
|
||||
private evaluateResultRepository =
|
||||
AppDataSource.getRepository(EvaluateResult);
|
||||
private evaluateResultRepository = AppDataSource.getRepository(EvaluateResult);
|
||||
|
||||
/**
|
||||
* API ข้อมูลตอนกดสร้างแบบรายงานการประเมินฯ
|
||||
|
|
@ -57,19 +47,13 @@ export class EvaluateResultController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("create")
|
||||
async CreateEvaluate(
|
||||
@Query() assign_id: string,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
async CreateEvaluate(@Query() assign_id: string) {
|
||||
const assign = await this.assignRepository.findOne({
|
||||
relations: ["profile"],
|
||||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
return new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const profile = await (assign.profile
|
||||
|
|
@ -77,10 +61,7 @@ export class EvaluateResultController extends Controller {
|
|||
...assign.profile,
|
||||
id: assign.profile.personal_id,
|
||||
name:
|
||||
assign.profile.prefixName +
|
||||
assign.profile.firstName +
|
||||
" " +
|
||||
assign.profile.lastName,
|
||||
assign.profile.prefixName + assign.profile.firstName + " " + assign.profile.lastName,
|
||||
Oc: assign.profile.organization,
|
||||
}
|
||||
: null);
|
||||
|
|
@ -90,10 +71,7 @@ export class EvaluateResultController extends Controller {
|
|||
});
|
||||
|
||||
if (!directorData) {
|
||||
return new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน"
|
||||
);
|
||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
|
||||
}
|
||||
|
||||
let mentors = "";
|
||||
|
|
@ -108,14 +86,10 @@ export class EvaluateResultController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
const commanderData = await (directorData.find(
|
||||
(x) => x.role == "commander"
|
||||
) ?? null);
|
||||
const commanderData = await (directorData.find((x) => x.role == "commander") ?? null);
|
||||
const commander = commanderData ? commanderData.fullname : null;
|
||||
|
||||
const chairmanData = await (directorData.find(
|
||||
(x) => x.role == "chairman"
|
||||
) ?? null);
|
||||
const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null);
|
||||
const chairman = chairmanData ? chairmanData.fullname : null;
|
||||
|
||||
const resultData = await this.evaluateChairmanRepository.findOne({
|
||||
|
|
@ -193,10 +167,7 @@ export class EvaluateResultController extends Controller {
|
|||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
return new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const experimenteeData = await this.personalRepository.find({
|
||||
|
|
@ -223,10 +194,7 @@ export class EvaluateResultController extends Controller {
|
|||
});
|
||||
|
||||
if (!directorData) {
|
||||
return new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน"
|
||||
);
|
||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
|
||||
}
|
||||
|
||||
let mentors = "";
|
||||
|
|
@ -241,14 +209,10 @@ export class EvaluateResultController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
const commanderData = await (directorData.find(
|
||||
(x) => x.role == "commander"
|
||||
) ?? null);
|
||||
const commanderData = await (directorData.find((x) => x.role == "commander") ?? null);
|
||||
const commander = commanderData ? commanderData.fullname : null;
|
||||
|
||||
const chairmanData = await (directorData.find(
|
||||
(x) => x.role == "chairman"
|
||||
) ?? null);
|
||||
const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null);
|
||||
const chairman = chairmanData ? chairmanData.fullname : null;
|
||||
|
||||
return new HttpSuccess({
|
||||
|
|
@ -271,7 +235,7 @@ export class EvaluateResultController extends Controller {
|
|||
async PostData(
|
||||
@Query() assign_id: string,
|
||||
@Body() requestBody: CreateEvaluateResult,
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const director = await this.assignDirectorRepository.findOne({
|
||||
select: ["personal_id"],
|
||||
|
|
@ -291,10 +255,7 @@ export class EvaluateResultController extends Controller {
|
|||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
return new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const postData: any = await {
|
||||
|
|
@ -304,8 +265,7 @@ export class EvaluateResultController extends Controller {
|
|||
no: 1,
|
||||
personal_id: assign.personal_id,
|
||||
date_start: requestBody.start_date,
|
||||
expand_month:
|
||||
requestBody.pass_result == 3 ? Number(requestBody.expand_month) : 0,
|
||||
expand_month: requestBody.pass_result == 3 ? Number(requestBody.expand_month) : 0,
|
||||
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
|
|
@ -366,7 +326,7 @@ export class EvaluateResultController extends Controller {
|
|||
@Query() assign_id: string,
|
||||
@Query() evaluate_id: string,
|
||||
@Body() requestBody: CreateEvaluateResult,
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
let evaluate = await this.evaluateResultRepository.findOne({
|
||||
where: { id: evaluate_id },
|
||||
|
|
@ -382,8 +342,7 @@ export class EvaluateResultController extends Controller {
|
|||
evaluate.date_finish = requestBody.date_finish;
|
||||
evaluate.develop_complete = requestBody.develop_complete;
|
||||
evaluate.pass_result = requestBody.pass_result;
|
||||
evaluate.expand_month =
|
||||
requestBody.pass_result == 3 ? requestBody.expand_month : 0;
|
||||
evaluate.expand_month = requestBody.pass_result == 3 ? requestBody.expand_month : 0;
|
||||
evaluate.reson = requestBody.reson;
|
||||
evaluate.chairman_dated = requestBody.chairman_dated;
|
||||
|
||||
|
|
@ -400,10 +359,7 @@ export class EvaluateResultController extends Controller {
|
|||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
return new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
const personal = await this.personalRepository.findOne({
|
||||
where: { personal_id: assign.personal_id },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue