fixing path
This commit is contained in:
parent
400b9c0b28
commit
ba612f1b2b
12 changed files with 325 additions and 723 deletions
|
|
@ -20,27 +20,22 @@ 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 { CreateEvaluateCommander, EvaluateCommander } from "../entities/EvaluateCommander";
|
||||
import { Personal } from "../entities/Personal";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
|
||||
@Route("api/v1/evaluate")
|
||||
@Route("api/v1/probation/evaluate")
|
||||
@Tags("แบบประเมินผล (ผู้บังคับบัญชา)")
|
||||
@Security("bearerAuth")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง"
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class EvaluateController extends Controller {
|
||||
private assignDirectorRepository =
|
||||
AppDataSource.getRepository(AssignDirector);
|
||||
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector);
|
||||
private assignRepository = AppDataSource.getRepository(Assign);
|
||||
private evaluateCommanderRepository =
|
||||
AppDataSource.getRepository(EvaluateCommander);
|
||||
private evaluateCommanderRepository = AppDataSource.getRepository(EvaluateCommander);
|
||||
private personalRepository = AppDataSource.getRepository(Personal);
|
||||
|
||||
/**
|
||||
|
|
@ -50,10 +45,7 @@ export class EvaluateController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("create")
|
||||
async CreateEvaluate(
|
||||
@Query() assign_id: string,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
async CreateEvaluate(@Query() assign_id: string) {
|
||||
const director = await this.assignDirectorRepository.findOne({
|
||||
select: ["personal_id"],
|
||||
where: {
|
||||
|
|
@ -71,10 +63,7 @@ export class EvaluateController extends Controller {
|
|||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
return new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const profile = await (assign.profile
|
||||
|
|
@ -82,10 +71,7 @@ export class EvaluateController 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);
|
||||
|
|
@ -103,14 +89,7 @@ export class EvaluateController extends Controller {
|
|||
: findEndDate(evaluate_amount * 3, assign.date_start);
|
||||
|
||||
const commanderData = await this.assignDirectorRepository.find({
|
||||
select: [
|
||||
"personal_id",
|
||||
"dated",
|
||||
"fullname",
|
||||
"position",
|
||||
"posType",
|
||||
"posLevel",
|
||||
],
|
||||
select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"],
|
||||
where: { personal_id: director_id },
|
||||
});
|
||||
|
||||
|
|
@ -176,10 +155,7 @@ export class EvaluateController extends Controller {
|
|||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
return new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
// const profile = await (assign.profile
|
||||
|
|
@ -208,14 +184,7 @@ export class EvaluateController extends Controller {
|
|||
// : findEndDate(evaluate_amount * 3, assign.date_start);
|
||||
|
||||
const directorData = await this.assignDirectorRepository.find({
|
||||
select: [
|
||||
"personal_id",
|
||||
"dated",
|
||||
"fullname",
|
||||
"position",
|
||||
"posType",
|
||||
"posLevel",
|
||||
],
|
||||
select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"],
|
||||
where: { personal_id: director_id },
|
||||
});
|
||||
|
||||
|
|
@ -262,7 +231,7 @@ export class EvaluateController extends Controller {
|
|||
async PostData(
|
||||
@Query() assign_id: string,
|
||||
@Body() requestBody: CreateEvaluateCommander,
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const director = await this.assignDirectorRepository.findOne({
|
||||
select: ["personal_id"],
|
||||
|
|
@ -282,10 +251,7 @@ export class EvaluateController 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,9 +270,7 @@ export class EvaluateController extends Controller {
|
|||
: 0,
|
||||
behavior_other_desc: requestBody.behavior_orther.text,
|
||||
behavior_other_level:
|
||||
requestBody.behavior_orther.text != ""
|
||||
? Number(requestBody.behavior_orther.level)
|
||||
: 0,
|
||||
requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0,
|
||||
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
|
|
@ -350,10 +314,10 @@ export class EvaluateController extends Controller {
|
|||
*/
|
||||
@Put("")
|
||||
async UpdateData(
|
||||
@Query() assign_id: string,
|
||||
// @Query() assign_id: string,
|
||||
@Query() evaluate_id: string,
|
||||
@Body() requestBody: CreateEvaluateCommander,
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
let evaluate = await this.evaluateCommanderRepository.findOne({
|
||||
where: { id: evaluate_id },
|
||||
|
|
@ -376,9 +340,7 @@ export class EvaluateController extends Controller {
|
|||
? requestBody.achievement_other.text
|
||||
: "";
|
||||
evaluate.achievement_other_level =
|
||||
requestBody.achievement_other.text != ""
|
||||
? Number(requestBody.achievement_other.level)
|
||||
: 0;
|
||||
requestBody.achievement_other.text != "" ? Number(requestBody.achievement_other.level) : 0;
|
||||
|
||||
evaluate.conduct1_level = requestBody.conduct1_level;
|
||||
evaluate.conduct2_level = requestBody.conduct2_level;
|
||||
|
|
@ -394,9 +356,7 @@ export class EvaluateController extends Controller {
|
|||
evaluate.discipline5_level = requestBody.discipline5_level;
|
||||
evaluate.behavior_other_desc = requestBody.behavior_orther.text;
|
||||
evaluate.behavior_other_level =
|
||||
requestBody.behavior_orther.text != ""
|
||||
? Number(requestBody.behavior_orther.level)
|
||||
: 0;
|
||||
requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0;
|
||||
evaluate.behavior_strength_desc = requestBody.behavior_strength_desc;
|
||||
evaluate.behavior_improve_desc = requestBody.behavior_improve_desc;
|
||||
evaluate.orientation = requestBody.orientation;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue