first
This commit is contained in:
commit
925c5d1ab2
60 changed files with 18843 additions and 0 deletions
271
src/controllers/DirectorController.ts
Normal file
271
src/controllers/DirectorController.ts
Normal file
|
|
@ -0,0 +1,271 @@
|
|||
import { AppDataSource } from "../database/data-source";
|
||||
import { CreateDirector, Director } from "../entities/Director";
|
||||
import {
|
||||
Body,
|
||||
Delete,
|
||||
Get,
|
||||
Path,
|
||||
Post,
|
||||
Put,
|
||||
Response,
|
||||
Route,
|
||||
SuccessResponse,
|
||||
Tags,
|
||||
Query,
|
||||
Request,
|
||||
Security,
|
||||
} from "tsoa";
|
||||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { Not, Brackets } from "typeorm";
|
||||
import permission from "../interfaces/permission";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/evaluation/director")
|
||||
@Tags("director")
|
||||
@Security("bearerAuth")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class DirectorController {
|
||||
private directorRepository = AppDataSource.getRepository(Director);
|
||||
|
||||
/**
|
||||
* API สำหรับแสดงรายการกรรมการ
|
||||
*
|
||||
* @summary EV4_001 - รายการกรรมการ (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Get()
|
||||
async all(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword?: string,
|
||||
) {
|
||||
await new permission().PermissionList(request, "SYS_EVA_INFO");
|
||||
// const directors = await this.directorRepository.find({
|
||||
// skip: (page - 1) * pageSize,
|
||||
// take: pageSize,
|
||||
// });
|
||||
// if (keyword != undefined && keyword !== "") {
|
||||
// return directors.filter(
|
||||
// (x) =>
|
||||
// x.prefix?.includes(keyword) ||
|
||||
// x.firstName?.includes(keyword) ||
|
||||
// x.lastName?.includes(keyword) ||
|
||||
// x.position?.includes(keyword) ||
|
||||
// x.email?.includes(keyword) ||
|
||||
// x.phone?.includes(keyword),
|
||||
// );
|
||||
// }
|
||||
const directors = await AppDataSource.getRepository(Director)
|
||||
.createQueryBuilder("director")
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.where(
|
||||
keyword != null && keyword != ""
|
||||
? "CONCAT(director.prefix, director.firstName, ' ', director.lastName) LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
keyword != null && keyword != ""
|
||||
? "director.position LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
keyword != null && keyword != ""
|
||||
? "director.email LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
keyword != null && keyword != ""
|
||||
? "director.phone LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("director.createdAt", "DESC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getMany();
|
||||
|
||||
return new HttpSuccess(directors);
|
||||
}
|
||||
|
||||
@Get("admin")
|
||||
async allAdmin(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword?: string,
|
||||
) {
|
||||
// const directors = await this.directorRepository.find({
|
||||
// skip: (page - 1) * pageSize,
|
||||
// take: pageSize,
|
||||
// });
|
||||
// if (keyword != undefined && keyword !== "") {
|
||||
// return directors.filter(
|
||||
// (x) =>
|
||||
// x.prefix?.includes(keyword) ||
|
||||
// x.firstName?.includes(keyword) ||
|
||||
// x.lastName?.includes(keyword) ||
|
||||
// x.position?.includes(keyword) ||
|
||||
// x.email?.includes(keyword) ||
|
||||
// x.phone?.includes(keyword),
|
||||
// );
|
||||
// }
|
||||
const directors = await AppDataSource.getRepository(Director)
|
||||
.createQueryBuilder("director")
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.where(
|
||||
keyword != null && keyword != ""
|
||||
? "CONCAT(director.prefix, director.firstName, ' ', director.lastName) LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
keyword != null && keyword != ""
|
||||
? "director.position LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
keyword != null && keyword != ""
|
||||
? "director.email LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
keyword != null && keyword != ""
|
||||
? "director.phone LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("director.createdAt", "DESC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getMany();
|
||||
return new HttpSuccess(directors);
|
||||
}
|
||||
|
||||
/**
|
||||
* API สำหรับแสดงรายละเอียดกรรมการ
|
||||
*
|
||||
* @summary EV4_002 - รายละเอียดกรรมการ (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Get("{id}")
|
||||
async one(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
let _workflow = await new permission().Workflow(request, id, "SYS_EVA_INFO");
|
||||
if (_workflow == false) await new permission().PermissionGet(request, "SYS_EVA_INFO");
|
||||
const director = await this.directorRepository.findOne({ where: { id } });
|
||||
if (!director) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
}
|
||||
return new HttpSuccess(director);
|
||||
}
|
||||
|
||||
/**
|
||||
* API สำหรับเพิ่มรายละเอียดกรรมการ
|
||||
*
|
||||
* @summary EV4_003 - เพิ่มรายละเอียดกรรมการ (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Post()
|
||||
async save(@Body() requestBody: CreateDirector, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionCreate(request, "SYS_EVA_INFO");
|
||||
let directorDup = await this.directorRepository.findOne({
|
||||
where: { firstName: requestBody.firstName, lastName: requestBody.lastName },
|
||||
});
|
||||
if (directorDup != null) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อกรรมการนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
const director = Object.assign(new Director(), requestBody);
|
||||
director.createdUserId = request.user.sub;
|
||||
director.createdFullName = request.user.name;
|
||||
director.createdAt = new Date();
|
||||
director.lastUpdateUserId = request.user.sub;
|
||||
director.lastUpdateFullName = request.user.name;
|
||||
director.lastUpdatedAt = new Date();
|
||||
|
||||
const before = null;
|
||||
|
||||
await this.directorRepository.save(director, { data: request });
|
||||
setLogDataDiff(request, { before, after: director });
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API สำหรับแก้ไขรายละเอียดกรรมการ
|
||||
*
|
||||
* @summary EV4_004 - แก้ไขรายละเอียดกรรมการ (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Put("{id}")
|
||||
async update(@Path() id: string, @Body() u: CreateDirector, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionUpdate(request, "SYS_EVA_INFO");
|
||||
let directorDup = await this.directorRepository.findOne({
|
||||
where: { firstName: u.firstName, lastName: u.lastName, id: Not(id) },
|
||||
});
|
||||
if (directorDup != null) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อกรรมการนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
let director = await this.directorRepository.findOneBy({ id });
|
||||
if (!director) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
}
|
||||
const before = structuredClone(directorDup);
|
||||
director.lastUpdateUserId = request.user.sub;
|
||||
director.lastUpdateFullName = request.user.name;
|
||||
director.lastUpdatedAt = new Date();
|
||||
this.directorRepository.merge(director, u);
|
||||
await this.directorRepository.save(director, { data: request });
|
||||
setLogDataDiff(request, { before, after: director });
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API สำหรับลบรายละเอียดกรรมการ
|
||||
*
|
||||
* @summary EV4_005 - ลบรายละเอียดกรรมการ (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Delete("{id}")
|
||||
async remove(id: string, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionDelete(request, "SYS_EVA_INFO");
|
||||
let director = await this.directorRepository.findOneBy({ id });
|
||||
if (!director) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
}
|
||||
await this.directorRepository.remove(director, { data: request });
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
320
src/controllers/DocumentController.ts
Normal file
320
src/controllers/DocumentController.ts
Normal file
|
|
@ -0,0 +1,320 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
Post,
|
||||
Route,
|
||||
SuccessResponse,
|
||||
Tags,
|
||||
} from "tsoa";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
import {
|
||||
createFile,
|
||||
createFolder,
|
||||
deleteFile,
|
||||
deleteFolder,
|
||||
downloadFile,
|
||||
listFile,
|
||||
updateFile,
|
||||
} from "../services/storage";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import { Evaluation } from "../entities/Evaluation";
|
||||
|
||||
@Route("api/v1/evaluation/document")
|
||||
@Tags("document")
|
||||
export class DocumentController extends Controller {
|
||||
/**
|
||||
* @example volume "เล่ม 1"
|
||||
* @example id "00000000-0000-0000-0000-000000000000"
|
||||
*
|
||||
* @summary ข้อมูลเอกสารทั้งชุด
|
||||
*/
|
||||
@Get("{volume}/{id}")
|
||||
@SuccessResponse(200, "สำเร็จ")
|
||||
@Example([
|
||||
{
|
||||
pathname: "string",
|
||||
path: "ระบบประเมิน/เล่ม 1/1-แบบพิจารณาคุณสมบัติบุคคล",
|
||||
title: "1-แบบพิจารณาคุณสมบัติบุคคล.docx",
|
||||
description: "",
|
||||
author: "นายก",
|
||||
metadata: {
|
||||
tag: 1,
|
||||
},
|
||||
keyword: [],
|
||||
category: [],
|
||||
fileType: "",
|
||||
fileSize: 1024,
|
||||
fileName: "1-แบบพิจารณาคุณสมบัติบุคคล.docx",
|
||||
upload: true,
|
||||
createdAt: "2021-07-20T12:33:13.018Z",
|
||||
createdBy: "service-account-ext-api",
|
||||
updatedAt: "2021-07-20T12:33:13.018Z",
|
||||
updatedBy: "service-account-ext-api",
|
||||
},
|
||||
])
|
||||
public async getFile(@Path() volume: string, @Path() id: string) {
|
||||
const list = await listFile(["ระบบประเมิน", volume, id]);
|
||||
if (!list) throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถสร้างแฟ้มได้");
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* ข้อควรระวัง: หากลิงก์ยาวเกินไปอาจทำให้ไม่สามารถอัปโหลดได้
|
||||
*
|
||||
* @example volume "เล่ม 1"
|
||||
* @example id "00000000-0000-0000-0000-000000000000"
|
||||
* @example file "1-แบบพิจารณาคุณสมบัติบุคคล"
|
||||
*
|
||||
* @summary ข้อมูลเอกสารพร้อมลิงก์ดาวน์โหลด
|
||||
*/
|
||||
@Get("{volume}/{id}/{file}")
|
||||
@SuccessResponse(200, "สำเร็จ")
|
||||
@Example({
|
||||
pathname: "string",
|
||||
path: "ระบบประเมิน/เล่ม 1/1-แบบพิจารณาคุณสมบัติบุคคล",
|
||||
title: "1-แบบพิจารณาคุณสมบัติบุคคล.docx",
|
||||
description: "",
|
||||
author: "นายก",
|
||||
keyword: [],
|
||||
category: [],
|
||||
metadata: {
|
||||
tag: 1,
|
||||
},
|
||||
fileName: "1-แบบพิจารณาคุณสมบัติบุคคล.docx",
|
||||
fileType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
fileSize: 1024,
|
||||
hidden: false,
|
||||
upload: true,
|
||||
createdAt: "2021-07-20T12:33:13.018Z",
|
||||
createdBy: "service-account-ext-api",
|
||||
updatedAt: "2021-07-20T12:33:13.018Z",
|
||||
updatedBy: "service-account-ext-api",
|
||||
downloadUrl: "https://.../...", // Presigned Download URL 7 Days Exp
|
||||
})
|
||||
public async getFileDownload(@Path() id: string, @Path() volume: string, @Path() file: string) {
|
||||
const data = await downloadFile(["ระบบประเมิน", volume, id], file);
|
||||
if (!data) throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถสร้างแฟ้มได้");
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* ข้อควรระวัง: หากลิงก์ภาษาไทยยาวเกินไปอาจทำให้ไม่สามารถอัปโหลดได้ (น่าจะเป็นปัญหาทางด้านเทคนิคของ DNS)
|
||||
*
|
||||
* เมื่ออัปโหลดไฟล์โดย PUT Method จำเป็นต้องแนบ Content-Type ที่ถูกต้องของไฟล์ไปด้วยเพื่อให้ระบบรู้จักไฟล์นั้นๆ
|
||||
* โดย Content-Type จะเป็น mime-type เช่น docx เป็น application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
||||
* ทั้งนี้ Content-Type อาจจะต่างกันแม้นามสกุลจะเหมือนกันได้
|
||||
*
|
||||
* โดยปกติเมื่อเลือกไฟล์แล้ว Browser จะเก็บประเภทของไฟล์ไว้ด้วย ซึ่งเป็น Object ของ File มี attribute ชื่อ type ซึ่งเก็บ mime-type ไว้
|
||||
*
|
||||
* หากไม่มีการป้อนชื่อ title ระบบ EDM จะใช้ title เป็นชื่อเดียวกับ ชื่อไฟล์โดยอัตโนมัติ
|
||||
*
|
||||
* @example volume "เล่ม 1"
|
||||
* @example id "00000000-0000-0000-0000-000000000000"
|
||||
*
|
||||
* @summary ร้องขอการอัปโหลดเอกสาร
|
||||
*/
|
||||
@Post("{volume}/{id}")
|
||||
@Example([
|
||||
{
|
||||
pathname: "string",
|
||||
path: "ระบบประเมิน/เล่ม 1/1-แบบพิจารณาคุณสมบัติบุคคล",
|
||||
title: "1-แบบพิจารณาคุณสมบัติบุคคล.docx",
|
||||
description: "1-แบบพิจารณาคุณสมบัติบุคคล.docx",
|
||||
author: "นายก",
|
||||
keyword: [],
|
||||
category: [],
|
||||
metadata: {
|
||||
tag: 1,
|
||||
},
|
||||
fileName: "1-แบบพิจารณาคุณสมบัติบุคคล.docx",
|
||||
fileSize: 0,
|
||||
fileType: "",
|
||||
hidden: false,
|
||||
upload: false,
|
||||
createdAt: "2021-07-20T12:33:13.018Z",
|
||||
createdBy: "service-account-ext-api",
|
||||
updatedAt: "2021-07-20T12:33:13.018Z",
|
||||
updatedBy: "service-account-ext-api",
|
||||
uploadUrl: "https://.../...", // Presigned Upload URL 7 Days Exp
|
||||
},
|
||||
])
|
||||
@SuccessResponse(200, "Success")
|
||||
public async uploadFile(
|
||||
@Path() volume: string,
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
body: {
|
||||
/**
|
||||
* @example [
|
||||
* {
|
||||
* "fileName": "1-แบบพิจารณาคุณสมบัติบุคคล.docx",
|
||||
* "title": "1-แบบพิจารณาคุณสมบัติบุคคล.docx"
|
||||
* },
|
||||
* {
|
||||
* "fileName": "2-แบบแสดงรายละเอียดการเสนอผลงาน.docx",
|
||||
* "description": "2-แบบแสดงรายละเอียดการเสนอผลงาน.docx"
|
||||
* },
|
||||
* {
|
||||
* "fileName": "3-แบบตรวจสอบความถูกต้องครบถ้วนของข้อมูล.docx",
|
||||
* "keyword": ["3-แบบตรวจสอบความถูกต้องครบถ้วนของข้อมูล.docx"]
|
||||
* },
|
||||
* {
|
||||
* "fileName": "4-แบบประเมินคุณลักษณะบุคคล.docx",
|
||||
* "category": ["4-แบบประเมินคุณลักษณะบุคคล.docx"]
|
||||
* },
|
||||
* {
|
||||
* "fileName": "5-แบบสรุปข้อมูลของผู้ขอรับการคัดเลือก.docx",
|
||||
* "author": "นายก"
|
||||
* },
|
||||
* {
|
||||
* "fileName": "6-ผลงานที่จะส่งประเมิน.docx",
|
||||
* "metadata": { "tag1": "value1", "tag2": "value2" }
|
||||
* }
|
||||
* ]
|
||||
*/
|
||||
fileList: {
|
||||
fileName: string;
|
||||
title?: string;
|
||||
description?: string;
|
||||
keyword?: string[];
|
||||
category?: string[];
|
||||
author?: string;
|
||||
metadata?: {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
}[];
|
||||
/**
|
||||
* @example false
|
||||
*/
|
||||
replace?: boolean;
|
||||
},
|
||||
) {
|
||||
const path = ["ระบบประเมิน", volume];
|
||||
|
||||
if (!(await createFolder(path, id, true))) {
|
||||
throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถสร้างแฟ้มได้");
|
||||
}
|
||||
|
||||
const list = await listFile(["ระบบประเมิน", volume, id]);
|
||||
|
||||
if (!list || !Array.isArray(list)) {
|
||||
throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถสร้างแฟ้มได้");
|
||||
}
|
||||
|
||||
let used: string[] = [];
|
||||
|
||||
const evaluation = AppDataSource.getRepository(Evaluation);
|
||||
|
||||
let author = await evaluation.findOne({
|
||||
where: { id },
|
||||
});
|
||||
|
||||
let fileList = !body.replace
|
||||
? body.fileList.map(({ fileName, ...props }) => {
|
||||
const dotIndex = fileName.lastIndexOf(".");
|
||||
const originalName =
|
||||
dotIndex !== -1 && !fileName.startsWith(".") ? fileName.slice(0, dotIndex) : fileName;
|
||||
const extension =
|
||||
dotIndex !== -1 && !fileName.startsWith(".") ? fileName.slice(dotIndex) : "";
|
||||
|
||||
let i = 1;
|
||||
while (list.findIndex((v) => v.fileName === fileName) !== -1 || used.includes(fileName)) {
|
||||
fileName = `${originalName} (${i++})`;
|
||||
if (dotIndex !== -1) fileName += extension;
|
||||
}
|
||||
if(author){
|
||||
props.author = `${author.prefix}${author.fullName}`;
|
||||
}else{
|
||||
props.author = "ไม่พบข้อมูล";
|
||||
}
|
||||
|
||||
used.push(fileName);
|
||||
return { fileName: fileName, ...props };
|
||||
})
|
||||
: body.fileList;
|
||||
|
||||
const map = fileList.map(async ({ fileName, ...props }) => [
|
||||
fileName,
|
||||
await createFile([...path, id], fileName, props),
|
||||
]);
|
||||
|
||||
const result = await Promise.all(map).catch((e) =>
|
||||
console.error(`Storage Service Error: ${e}`),
|
||||
);
|
||||
|
||||
if (!result || result.some((v) => !v[1])) {
|
||||
throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถอัปโหลดไฟล์ได้");
|
||||
}
|
||||
|
||||
return Object.fromEntries(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @example volume "เล่ม 1"
|
||||
* @example id "00000000-0000-0000-0000-000000000000"
|
||||
* @example file "1-แบบพิจารณาคุณสมบัติบุคคล.docx"
|
||||
*
|
||||
* @summary แก้ไขข้อมูลไฟล์ของ id นั้นๆ
|
||||
*/
|
||||
@Patch("{volume}/{id}/{file}")
|
||||
public async updateFile(
|
||||
@Path() volume: string,
|
||||
@Path() id: string,
|
||||
@Path() file: string,
|
||||
@Body()
|
||||
body: {
|
||||
title?: string;
|
||||
description?: string;
|
||||
keyword?: string[];
|
||||
category?: string[];
|
||||
author?: string;
|
||||
metadata?: { [key: string]: unknown };
|
||||
},
|
||||
) {
|
||||
const props = body;
|
||||
const result = await updateFile(["ระบบประเมิน", volume, id], file, props);
|
||||
|
||||
if (!result) {
|
||||
throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถอัปโหลดไฟล์ได้");
|
||||
}
|
||||
return this.setStatus(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @example volume "เล่ม 1"
|
||||
* @example id "00000000-0000-0000-0000-000000000000"
|
||||
*
|
||||
* @summary ลบไฟล์ทั้งหมดของ id นั้นๆ
|
||||
*/
|
||||
@Delete("{volume}/{id}")
|
||||
public async deleteFolder(@Path() volume: string, @Path() id: string) {
|
||||
const result = await deleteFolder(["ระบบประเมิน", volume], id);
|
||||
|
||||
if (!result) {
|
||||
throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถอัปโหลดไฟล์ได้");
|
||||
}
|
||||
return this.setStatus(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @example volume "เล่ม 1"
|
||||
* @example id "00000000-0000-0000-0000-000000000000"
|
||||
* @example file "1-แบบพิจารณาคุณสมบัติบุคคล.docx"
|
||||
*
|
||||
* @summary ลบไฟล์ของ id นั้นๆ
|
||||
*/
|
||||
@Delete("{volume}/{id}/{file}")
|
||||
public async deleteFile(@Path() volume: string, @Path() id: string, @Path() file: string) {
|
||||
const result = await deleteFile(["ระบบประเมิน", volume, id], file);
|
||||
|
||||
if (!result) {
|
||||
throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถอัปโหลดไฟล์ได้");
|
||||
}
|
||||
return this.setStatus(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
}
|
||||
2520
src/controllers/EvaluationController.ts
Normal file
2520
src/controllers/EvaluationController.ts
Normal file
File diff suppressed because it is too large
Load diff
212
src/controllers/MeetingController.ts
Normal file
212
src/controllers/MeetingController.ts
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
import { AppDataSource } from "../database/data-source";
|
||||
import { CreateMeeting, Meeting } from "../entities/Meeting";
|
||||
import {
|
||||
Body,
|
||||
Delete,
|
||||
Get,
|
||||
Path,
|
||||
Post,
|
||||
Put,
|
||||
Response,
|
||||
Route,
|
||||
SuccessResponse,
|
||||
Tags,
|
||||
Query,
|
||||
Request,
|
||||
Security,
|
||||
} from "tsoa";
|
||||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
import { Brackets } from "typeorm";
|
||||
|
||||
@Route("api/v1/evaluation/meeting")
|
||||
@Tags("meeting")
|
||||
@Security("bearerAuth")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class MeetingController {
|
||||
private meetingRepository = AppDataSource.getRepository(Meeting);
|
||||
|
||||
/**
|
||||
* API สำหรับแสดงรายการการประชุม
|
||||
*
|
||||
* @summary EV4_006 - รายการการประชุม (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Get()
|
||||
async all(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword?: string,
|
||||
) {
|
||||
await new permission().PermissionList(request, "SYS_EVA_INFO");
|
||||
// const meetings = await this.meetingRepository.find({
|
||||
// skip: (page - 1) * pageSize,
|
||||
// take: pageSize,
|
||||
// });
|
||||
// if (keyword != undefined && keyword !== "") {
|
||||
// return meetings.filter((x) => x.title?.includes(keyword) || x.round?.includes(keyword));
|
||||
// }
|
||||
const meetings = await AppDataSource.getRepository(Meeting)
|
||||
.createQueryBuilder("meeting")
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.where(
|
||||
keyword != null && keyword != ""
|
||||
? "meeting.title LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
keyword != null && keyword != ""
|
||||
? "meeting.round LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("meeting.createdAt", "DESC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getMany();
|
||||
return new HttpSuccess(meetings);
|
||||
}
|
||||
|
||||
@Get("admin")
|
||||
async allAdmin(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword?: string,
|
||||
) {
|
||||
// const meetings = await this.meetingRepository.find({
|
||||
// skip: (page - 1) * pageSize,
|
||||
// take: pageSize,
|
||||
// });
|
||||
// if (keyword != undefined && keyword !== "") {
|
||||
// return meetings.filter((x) => x.title?.includes(keyword) || x.round?.includes(keyword));
|
||||
// }
|
||||
|
||||
const meetings = await AppDataSource.getRepository(Meeting)
|
||||
.createQueryBuilder("meeting")
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.where(
|
||||
keyword != null && keyword != ""
|
||||
? "meeting.title LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
keyword != null && keyword != ""
|
||||
? "meeting.round LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("meeting.createdAt", "DESC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getMany();
|
||||
return new HttpSuccess(meetings);
|
||||
}
|
||||
|
||||
/**
|
||||
* API สำหรับแสดงรายละเอียดการประชุม
|
||||
*
|
||||
* @summary EV4_007 - รายละเอียดการประชุม (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Get("{id}")
|
||||
async one(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
let _workflow = await new permission().Workflow(request, id, "SYS_EVA_INFO");
|
||||
if (_workflow == false) await new permission().PermissionGet(request, "SYS_EVA_INFO");
|
||||
const meeting = await this.meetingRepository.findOne({ where: { id } });
|
||||
if (!meeting) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
}
|
||||
return new HttpSuccess(meeting);
|
||||
}
|
||||
|
||||
/**
|
||||
* API สำหรับเพิ่มรายละเอียดการประชุม
|
||||
*
|
||||
* @summary EV4_008 - เพิ่มรายละเอียดการประชุม (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Post()
|
||||
async save(@Body() requestBody: CreateMeeting, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionCreate(request, "SYS_EVA_INFO");
|
||||
const meeting = Object.assign(new Meeting(), requestBody);
|
||||
meeting.createdUserId = request.user.sub;
|
||||
meeting.createdFullName = request.user.name;
|
||||
meeting.createdAt = new Date();
|
||||
meeting.lastUpdateUserId = request.user.sub;
|
||||
meeting.lastUpdateFullName = request.user.name;
|
||||
meeting.lastUpdatedAt = new Date();
|
||||
const before = null;
|
||||
|
||||
await this.meetingRepository.save(meeting, { data: request });
|
||||
setLogDataDiff(request, { before, after: meeting });
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API สำหรับแก้ไขรายละเอียดการประชุม
|
||||
*
|
||||
* @summary EV4_009 - แก้ไขรายละเอียดการประชุม (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Put("{id}")
|
||||
async update(@Path() id: string, @Body() u: CreateMeeting, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionUpdate(request, "SYS_EVA_INFO");
|
||||
let meeting = await this.meetingRepository.findOneBy({ id });
|
||||
if (!meeting) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
}
|
||||
const before = structuredClone(meeting);
|
||||
meeting.lastUpdateUserId = request.user.sub;
|
||||
meeting.lastUpdateFullName = request.user.name;
|
||||
meeting.lastUpdatedAt = new Date();
|
||||
this.meetingRepository.merge(meeting, u);
|
||||
await this.meetingRepository.save(meeting, { data: request });
|
||||
setLogDataDiff(request, { before, after: meeting });
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API สำหรับลบรายละเอียดการประชุม
|
||||
*
|
||||
* @summary EV4_010 - ลบรายละเอียดการประชุม (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Delete("{id}")
|
||||
async remove(id: string, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionDelete(request, "SYS_EVA_INFO");
|
||||
let meeting = await this.meetingRepository.findOneBy({ id });
|
||||
if (!meeting) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
}
|
||||
await this.meetingRepository.remove(meeting, { data: request });
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
370
src/controllers/ReportController.ts
Normal file
370
src/controllers/ReportController.ts
Normal file
|
|
@ -0,0 +1,370 @@
|
|||
import { AppDataSource } from "../database/data-source";
|
||||
import {
|
||||
Body,
|
||||
Example,
|
||||
Get,
|
||||
Path,
|
||||
Post,
|
||||
Put,
|
||||
Request,
|
||||
Response,
|
||||
Route,
|
||||
Security,
|
||||
SuccessResponse,
|
||||
Tags,
|
||||
Delete,
|
||||
} from "tsoa";
|
||||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import { Evaluation } from "../entities/Evaluation";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import { EvaluationLogs } from "../entities/EvaluationLogs";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { Education } from "../entities/Education";
|
||||
import { Certificate } from "../entities/Certificate";
|
||||
import { Salary } from "../entities/Salary";
|
||||
import { Training } from "../entities/Training";
|
||||
import { Assessment } from "../entities/Assessment";
|
||||
import { Director } from "../entities/Director";
|
||||
import { Meeting } from "../entities/Meeting";
|
||||
import { Brackets } from "typeorm";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import Extension from "../interfaces/extension";
|
||||
import { Not } from "typeorm"
|
||||
@Route("api/v1/evaluation/report")
|
||||
@Tags("report")
|
||||
@Security("bearerAuth")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถทำรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class ReoportController {
|
||||
private evaluationRepository = AppDataSource.getRepository(Evaluation);
|
||||
private evaluationLogsRepository = AppDataSource.getRepository(EvaluationLogs);
|
||||
private educationRepository = AppDataSource.getRepository(Education);
|
||||
private certificateRepository = AppDataSource.getRepository(Certificate);
|
||||
private salaryRepository = AppDataSource.getRepository(Salary);
|
||||
private trainingRepository = AppDataSource.getRepository(Training);
|
||||
private assessmentRepository = AppDataSource.getRepository(Assessment);
|
||||
private directorRepository = AppDataSource.getRepository(Director);
|
||||
private meetingRepository = AppDataSource.getRepository(Meeting);
|
||||
|
||||
/**
|
||||
* Report ระบบประเมินบุคคล
|
||||
*
|
||||
* @summary Report ระบบประเมินบุคคล (ADMIN & USER)
|
||||
*
|
||||
* @param {string} id id ข้อมูลการประเมิน
|
||||
*/
|
||||
@Get("check-spec-report/{id}")
|
||||
async checkSpecGetReport(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
const evaluation = await AppDataSource.getRepository(Evaluation)
|
||||
.createQueryBuilder("evaluation")
|
||||
.leftJoin("evaluation.education", "education")
|
||||
.leftJoin("evaluation.certificate", "certificate")
|
||||
.leftJoin("evaluation.salaries", "salaries")
|
||||
.leftJoin("evaluation.training", "training")
|
||||
.leftJoin("evaluation.assessment", "assessment")
|
||||
.where("evaluation.id = :id", { id })
|
||||
.select([
|
||||
"evaluation.id",
|
||||
"evaluation.userId",
|
||||
"evaluation.subject",
|
||||
"evaluation.isEducationalQft",
|
||||
"evaluation.isGovermantServiceHtr",
|
||||
"evaluation.isOperatingExp",
|
||||
"evaluation.isMinPeriodOfTenure",
|
||||
"evaluation.isHaveSpecificQft",
|
||||
"evaluation.isHaveProLicense",
|
||||
"evaluation.isHaveMinPeriodOrHoldPos",
|
||||
"evaluation.type",
|
||||
"evaluation.prefix",
|
||||
"evaluation.fullName",
|
||||
"evaluation.position",
|
||||
"evaluation.posNo",
|
||||
"evaluation.oc",
|
||||
"evaluation.salary",
|
||||
"evaluation.positionLevel",
|
||||
"evaluation.birthDate",
|
||||
"evaluation.govAge",
|
||||
"evaluation.experience",
|
||||
|
||||
"education.educationLevel",
|
||||
"education.institute",
|
||||
"education.isDate",
|
||||
"education.startDate",
|
||||
"education.endDate",
|
||||
"education.finishDate",
|
||||
"education.isEducation",
|
||||
"education.degree",
|
||||
"education.field",
|
||||
"education.fundName",
|
||||
"education.gpa",
|
||||
"education.country",
|
||||
"education.other",
|
||||
"education.duration",
|
||||
"education.durationYear",
|
||||
|
||||
"certificate.certificateType",
|
||||
"certificate.issuer",
|
||||
"certificate.certificateNo",
|
||||
"certificate.issueDate",
|
||||
"certificate.expireDate",
|
||||
|
||||
"salaries.date",
|
||||
"salaries.amount",
|
||||
"salaries.positionSalaryAmount",
|
||||
"salaries.mouthSalaryAmount",
|
||||
"salaries.position",
|
||||
"salaries.posNo",
|
||||
"salaries.salaryClass",
|
||||
"salaries.salaryRef",
|
||||
"salaries.refCommandNo",
|
||||
"salaries.refCommandDate",
|
||||
"salaries.salaryStatus",
|
||||
|
||||
"training.name",
|
||||
"training.topic",
|
||||
"training.startDate",
|
||||
"training.endDate",
|
||||
"training.yearly",
|
||||
"training.place",
|
||||
"training.duration",
|
||||
"training.department",
|
||||
"training.numberOrder",
|
||||
"training.dateOrder",
|
||||
|
||||
"assessment.date",
|
||||
"assessment.point1Total",
|
||||
"assessment.point1",
|
||||
"assessment.point2Total",
|
||||
"assessment.point2",
|
||||
"assessment.pointSumTotal",
|
||||
"assessment.pointSum",
|
||||
])
|
||||
.getOne();
|
||||
|
||||
if (!evaluation) {
|
||||
return "ไม่พบข้อมูล";
|
||||
}
|
||||
let root: any
|
||||
let dateStart: any
|
||||
let dateRetireLaw: any
|
||||
let org: any
|
||||
let commanderFullname: any
|
||||
let commanderPosition: any
|
||||
let commanderRootName: any
|
||||
let commanderOrg: any
|
||||
let commanderAboveFullname: any
|
||||
let commanderAbovePosition: any
|
||||
let commanderAboveRootName: any
|
||||
let commanderAboveOrg: any
|
||||
if (!evaluation.userId) {
|
||||
return "ไม่พบข้อมูลผู้ขอประเมิน";
|
||||
}
|
||||
await new CallAPI()
|
||||
.GetData(request, `/org/profile/keycloak/commander/${evaluation.userId}`)
|
||||
.then(async (x) => {
|
||||
root = x.root,
|
||||
dateStart = x.dateStart,
|
||||
dateRetireLaw = x.dateRetireLaw,
|
||||
org = x.org,
|
||||
commanderFullname = x.commanderFullname,
|
||||
commanderPosition = x.commanderPosition,
|
||||
commanderRootName = x.commanderRootName,
|
||||
commanderOrg = x.commanderOrg,
|
||||
commanderAboveFullname = x.commanderAboveFullname,
|
||||
commanderAbovePosition = x.commanderAbovePosition,
|
||||
commanderAboveRootName = x.commanderAboveRootName,
|
||||
commanderAboveOrg = x.commanderAboveOrg
|
||||
})
|
||||
.catch();
|
||||
const evaluationOld = await this.evaluationRepository.find({
|
||||
where: {
|
||||
id: Not(id),
|
||||
userId: evaluation.userId,
|
||||
step: "DONE"
|
||||
}
|
||||
});
|
||||
let subjectOld = evaluationOld.length > 0
|
||||
? evaluationOld.map(x => x.subject).join(", ")
|
||||
: "ไม่มี"
|
||||
let thaiYear:number = new Date().getFullYear()+543
|
||||
let years = {
|
||||
lastTwoYear: Extension.ToThaiNumber((thaiYear-2).toString()),
|
||||
lastOneYear: Extension.ToThaiNumber((thaiYear-1).toString()),
|
||||
currentYear: Extension.ToThaiNumber(thaiYear.toString()),
|
||||
}
|
||||
const dataEvaluation = {
|
||||
isEducationalQft: evaluation.isEducationalQft,
|
||||
isGovermantServiceHtr: evaluation.isGovermantServiceHtr,
|
||||
isOperatingExp: evaluation.isOperatingExp,
|
||||
isMinPeriodOfTenure: evaluation.isMinPeriodOfTenure,
|
||||
isHaveSpecificQft: evaluation.isHaveSpecificQft,
|
||||
isHaveProLicense: evaluation.isHaveProLicense,
|
||||
isHaveMinPeriodOrHoldPos: evaluation.isHaveMinPeriodOrHoldPos,
|
||||
type: evaluation.type,
|
||||
prefix: evaluation.prefix,
|
||||
fullName: evaluation.prefix && evaluation.fullName ? `${evaluation.prefix}${evaluation.fullName}` : "-",
|
||||
position: evaluation.position ? evaluation.position : "-",
|
||||
posNo: evaluation.posNo ? Extension.ToThaiNumber(evaluation.posNo) : "-",
|
||||
oc: evaluation.oc ? evaluation.oc : "-",
|
||||
org: org ? org : "-", //สังกัด
|
||||
root: root ? root : "-", //หน่วยงาน
|
||||
salary: evaluation.salary ? Extension.ToThaiNumber(evaluation.salary) : "-",
|
||||
positionLevel: evaluation.positionLevel ? evaluation.positionLevel : "-",
|
||||
birthDate: evaluation.birthDate != null && evaluation.birthDate != ""
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(new Date(evaluation.birthDate)))
|
||||
: "-",
|
||||
govAge: evaluation.govAge != null
|
||||
? Extension.ToThaiNumber(evaluation.govAge)
|
||||
: "-",
|
||||
experience: evaluation.experience ? evaluation.experience : "-",
|
||||
dateStart: dateStart
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date(dateStart)))
|
||||
: "-",
|
||||
dateRetireLaw: dateRetireLaw
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date(dateRetireLaw)))
|
||||
: "-",
|
||||
subject: evaluation.subject != null ? evaluation.subject : "-",
|
||||
subjectOld: subjectOld,
|
||||
educations: evaluation.education.length > 0
|
||||
? evaluation.education.map((education) => ({
|
||||
educationLevel: education.educationLevel
|
||||
? Extension.ToThaiNumber(education.educationLevel)
|
||||
: "-",
|
||||
institute: education.institute
|
||||
? Extension.ToThaiNumber(education.institute)
|
||||
: "-",
|
||||
finishYear: education.finishDate
|
||||
? Extension.ToThaiNumber((Extension.ToThaiYear(education.finishDate.getFullYear())).toString())
|
||||
: "-",
|
||||
isDate: education.isDate,
|
||||
startDate: education.startDate,
|
||||
endDate: education.endDate,
|
||||
finishDate: education.finishDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate(education.finishDate).toString())
|
||||
: "-",
|
||||
isEducation: education.isEducation,
|
||||
degree: education.degree
|
||||
? Extension.ToThaiNumber(education.degree)
|
||||
: "-",
|
||||
field: education.field
|
||||
? Extension.ToThaiNumber(education.field)
|
||||
: "-",
|
||||
fundName: education.fundName,
|
||||
gpa: education.gpa,
|
||||
country: education.country,
|
||||
other: education.other,
|
||||
duration: education.duration,
|
||||
durationYear: education.durationYear,
|
||||
}))
|
||||
: [{
|
||||
educationLevel: "-",
|
||||
institute: "-",
|
||||
finishYear: "-",
|
||||
finishDate: "-",
|
||||
degree: "-",
|
||||
field: "-"
|
||||
}],
|
||||
certificates: evaluation.certificate.length > 0
|
||||
? evaluation.certificate.map((certificate) => ({
|
||||
certificateType: certificate.certificateType
|
||||
? Extension.ToThaiNumber(certificate.certificateType)
|
||||
: "-",
|
||||
issuer: certificate.issuer
|
||||
? Extension.ToThaiNumber(certificate.issuer)
|
||||
: "-",
|
||||
certificateNo: certificate.certificateNo
|
||||
? Extension.ToThaiNumber(certificate.certificateNo)
|
||||
: "-",
|
||||
issueDate: certificate.issueDate,
|
||||
expireDate: certificate.expireDate,
|
||||
}))
|
||||
: [{
|
||||
certificateType: "-",
|
||||
issuer: "-",
|
||||
certificateNo: "-",
|
||||
issueDate: "-",
|
||||
expireDate: "-",
|
||||
}],
|
||||
salaries: evaluation.salaries.length > 0
|
||||
? evaluation.salaries.map((salaries) => ({
|
||||
date: salaries.date
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(salaries.date))
|
||||
: "-",
|
||||
amount: salaries.amount
|
||||
? Extension.ToThaiNumber(salaries.amount.toLocaleString())
|
||||
: "-",
|
||||
position: salaries.position
|
||||
? Extension.ToThaiNumber(salaries.position)
|
||||
: "-",
|
||||
positionSalaryAmount: salaries.positionSalaryAmount,
|
||||
mouthSalaryAmount: salaries.mouthSalaryAmount,
|
||||
posNo: salaries.posNo,
|
||||
salaryClass: salaries.salaryClass,
|
||||
salaryRef: salaries.salaryRef,
|
||||
refCommandNo: salaries.refCommandNo,
|
||||
refCommandDate: salaries.refCommandDate,
|
||||
salaryStatus: salaries.salaryStatus,
|
||||
}))
|
||||
: [{
|
||||
date: "-",
|
||||
amount: "-",
|
||||
position: "-",
|
||||
}],
|
||||
trainings: evaluation.training.length > 0
|
||||
? evaluation.training.map((training) => ({
|
||||
name: training.name
|
||||
? Extension.ToThaiNumber(training.name)
|
||||
: "-",
|
||||
topic: training.topic
|
||||
? Extension.ToThaiNumber(training.topic)
|
||||
: "-",
|
||||
startDate: training.startDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(training.startDate))
|
||||
: "-",
|
||||
endDate: training.endDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(training.endDate))
|
||||
: "-",
|
||||
yearly: training.yearly
|
||||
? Extension.ToThaiNumber(training.yearly.toString())
|
||||
: "-",
|
||||
place: training.place,
|
||||
duration: training.duration,
|
||||
department: training.department,
|
||||
numberOrder: training.numberOrder,
|
||||
dateOrder: training.dateOrder,
|
||||
}))
|
||||
: [{
|
||||
name: "-",
|
||||
topic: "-",
|
||||
yearly: "-",
|
||||
}],
|
||||
assessments: evaluation.assessment.map((assessment) => ({
|
||||
date: assessment.date,
|
||||
point1Total: assessment.point1Total,
|
||||
point1: assessment.point1,
|
||||
point2Total: assessment.point2Total,
|
||||
point2: assessment.point2,
|
||||
pointSumTotal: assessment.pointSumTotal,
|
||||
pointSum: assessment.pointSum,
|
||||
})),
|
||||
commanderFullname: commanderFullname ? commanderFullname : "-",
|
||||
commanderPosition: commanderPosition ? commanderPosition : "-",
|
||||
commanderRootName: commanderRootName ? commanderRootName : "-",
|
||||
commanderOrg: commanderOrg ? commanderOrg : "-",
|
||||
commanderAboveFullname: commanderAboveFullname ? commanderAboveFullname : "-",
|
||||
commanderAbovePosition: commanderAbovePosition ? commanderAbovePosition : "-",
|
||||
commanderAboveRootName: commanderAboveRootName ? commanderAboveRootName : "-",
|
||||
commanderAboveOrg: commanderAboveOrg ? commanderAboveOrg : "-",
|
||||
years: years
|
||||
};
|
||||
|
||||
if (!dataEvaluation) {
|
||||
return "ไม่พบข้อมูล";
|
||||
}
|
||||
return new HttpSuccess(dataEvaluation);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue