fixing throw error message
This commit is contained in:
parent
a38adb9598
commit
1a6dc0214e
12 changed files with 622 additions and 1325 deletions
|
|
@ -22,12 +22,7 @@ import HttpStatusCode from "../interfaces/http-status";
|
|||
import HttpError from "../interfaces/http-error";
|
||||
import permission from "../interfaces/permission";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import {
|
||||
Appoint,
|
||||
CreateAppoint,
|
||||
Person,
|
||||
UpdateAppoint,
|
||||
} from "../entities/Appoint";
|
||||
import { Appoint, CreateAppoint, Person, UpdateAppoint } from "../entities/Appoint";
|
||||
import { AppointDirector } from "../entities/AppointDirector";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
|
||||
|
|
@ -36,12 +31,11 @@ import CallAPI from "../interfaces/call-api";
|
|||
@Security("bearerAuth")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง"
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||
)
|
||||
export class AppointController extends Controller {
|
||||
private appointRepository = AppDataSource.getRepository(Appoint);
|
||||
private appointDirectorRepository =
|
||||
AppDataSource.getRepository(AppointDirector);
|
||||
private appointDirectorRepository = AppDataSource.getRepository(AppointDirector);
|
||||
|
||||
/**
|
||||
* API รายการแต่งตั้งคณะกรรมการฯ ทดลองงาน
|
||||
|
|
@ -54,7 +48,7 @@ export class AppointController extends Controller {
|
|||
@Query() keyword: string = "",
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
try {
|
||||
const appoint = await this.appointRepository.find({
|
||||
|
|
@ -67,7 +61,7 @@ export class AppointController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
// await new permission().PermissionList(request, "SYS_PROBATION")
|
||||
// const _data = await new permission().PermissionOrgList(request, "SYS_PROBATION")
|
||||
|
|
@ -102,10 +96,7 @@ export class AppointController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("list/{id}")
|
||||
async GetListCommand(
|
||||
@Request() request: RequestWithUser,
|
||||
@Path() id: string
|
||||
) {
|
||||
async GetListCommand(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
try {
|
||||
const appoint = await this.appointRepository.find({
|
||||
relations: ["directors"],
|
||||
|
|
@ -116,7 +107,7 @@ export class AppointController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -127,10 +118,7 @@ export class AppointController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Post("")
|
||||
async Create(
|
||||
@Request() request: RequestWithUser,
|
||||
@Body() requestBody: CreateAppoint
|
||||
) {
|
||||
async Create(@Request() request: RequestWithUser, @Body() requestBody: CreateAppoint) {
|
||||
try {
|
||||
await new permission().PermissionCreate(request, "SYS_PROBATION");
|
||||
|
||||
|
|
@ -150,7 +138,7 @@ export class AppointController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -163,13 +151,8 @@ export class AppointController extends Controller {
|
|||
@Get("{id}")
|
||||
async GetById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
try {
|
||||
let _workflow = await new permission().Workflow(
|
||||
request,
|
||||
id,
|
||||
"SYS_PROBATION"
|
||||
);
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
let _workflow = await new permission().Workflow(request, id, "SYS_PROBATION");
|
||||
if (_workflow == false) await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
|
||||
const appoint = await this.appointRepository.findOne({
|
||||
select: ["id", "topic", "status", "profileId"],
|
||||
|
|
@ -181,7 +164,7 @@ export class AppointController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -195,7 +178,7 @@ export class AppointController extends Controller {
|
|||
async Update(
|
||||
@Request() request: RequestWithUser,
|
||||
@Body() requestBody: UpdateAppoint,
|
||||
@Path() id: string
|
||||
@Path() id: string,
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
|
|
@ -205,10 +188,7 @@ export class AppointController extends Controller {
|
|||
});
|
||||
|
||||
if (!appoint) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลการแต่งตั้งคณะกรรมการฯ"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการแต่งตั้งคณะกรรมการฯ");
|
||||
}
|
||||
|
||||
const before = appoint;
|
||||
|
|
@ -234,7 +214,7 @@ export class AppointController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -245,10 +225,7 @@ export class AppointController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Delete("{id}")
|
||||
public async deleteRole(
|
||||
@Path() id: string,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
public async deleteRole(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
try {
|
||||
await new permission().PermissionDelete(request, "SYS_PROBATION");
|
||||
|
||||
|
|
@ -261,7 +238,7 @@ export class AppointController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -272,10 +249,7 @@ export class AppointController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("/committee/{profileId}")
|
||||
async GetCheckById(
|
||||
@Request() request: RequestWithUser,
|
||||
@Path() profileId: string
|
||||
) {
|
||||
async GetCheckById(@Request() request: RequestWithUser, @Path() profileId: string) {
|
||||
try {
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
|
||||
|
|
@ -293,7 +267,7 @@ export class AppointController extends Controller {
|
|||
{
|
||||
directorId,
|
||||
profileId,
|
||||
}
|
||||
},
|
||||
)
|
||||
.orderBy("appoint.createdAt", "DESC")
|
||||
.getOne();
|
||||
|
|
@ -302,7 +276,7 @@ export class AppointController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,21 +21,12 @@ import { findEndDate, setLogDataDiff } from "../interfaces/utils";
|
|||
import { Personal } from "../entities/Personal";
|
||||
import permission from "../interfaces/permission";
|
||||
import { Assign, CreateAssign } from "../entities/Assign";
|
||||
import {
|
||||
AssignDirector,
|
||||
CreateAssignDirector,
|
||||
} from "../entities/AssignDirector";
|
||||
import { AssignDirector, CreateAssignDirector } from "../entities/AssignDirector";
|
||||
import { AssignJob, CreateAssignJob } from "../entities/AssignJob";
|
||||
import {
|
||||
AssignKnowledge,
|
||||
CreateAssignKnowledge,
|
||||
} from "../entities/AssignKnowledge";
|
||||
import { AssignKnowledge, CreateAssignKnowledge } from "../entities/AssignKnowledge";
|
||||
import { AssignLaw, CreateAssignLaw } from "../entities/AssignLaw";
|
||||
import { AssignSkill, CreateAssignSkill } from "../entities/AssignSkill";
|
||||
import {
|
||||
AssignCompetency,
|
||||
CreateAssignCompetency,
|
||||
} from "../entities/AssignCompetency";
|
||||
import { AssignCompetency, CreateAssignCompetency } from "../entities/AssignCompetency";
|
||||
import {
|
||||
AssignCompetencyGroup,
|
||||
CreateAssignCompetencyGroup,
|
||||
|
|
@ -49,23 +40,18 @@ import CallAPI from "../interfaces/call-api";
|
|||
@Security("bearerAuth")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง"
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||
)
|
||||
export class AssignController extends Controller {
|
||||
private assignRepository = AppDataSource.getRepository(Assign);
|
||||
private personalRepository = AppDataSource.getRepository(Personal);
|
||||
private assignDirectorRepository =
|
||||
AppDataSource.getRepository(AssignDirector);
|
||||
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector);
|
||||
private assignJobRepository = AppDataSource.getRepository(AssignJob);
|
||||
private assignKnowledgeRepository =
|
||||
AppDataSource.getRepository(AssignKnowledge);
|
||||
private assignKnowledgeRepository = AppDataSource.getRepository(AssignKnowledge);
|
||||
private assignLawRepository = AppDataSource.getRepository(AssignLaw);
|
||||
private assignSkillRepository = AppDataSource.getRepository(AssignSkill);
|
||||
private assignCompetencyRepository =
|
||||
AppDataSource.getRepository(AssignCompetency);
|
||||
private assignCompetencyGroupRepository = AppDataSource.getRepository(
|
||||
AssignCompetencyGroup
|
||||
);
|
||||
private assignCompetencyRepository = AppDataSource.getRepository(AssignCompetency);
|
||||
private assignCompetencyGroupRepository = AppDataSource.getRepository(AssignCompetencyGroup);
|
||||
private assignOutputRepository = AppDataSource.getRepository(AssignOutput);
|
||||
private lawsRepository = AppDataSource.getRepository(Law);
|
||||
|
||||
|
|
@ -87,10 +73,7 @@ export class AssignController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Post("")
|
||||
async AddAssign(
|
||||
@Request() request: RequestWithUser,
|
||||
@Body() requestBody: CreateAssign
|
||||
) {
|
||||
async AddAssign(@Request() request: RequestWithUser, @Body() requestBody: CreateAssign) {
|
||||
try {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
const person = await this.personalRepository.findOne({
|
||||
|
|
@ -126,17 +109,15 @@ export class AssignController extends Controller {
|
|||
const assign = await this.assignRepository.save(data, { data: request });
|
||||
setLogDataDiff(request, { before, after: data });
|
||||
|
||||
const jobs = await requestBody.assign_jobs.map(
|
||||
(x: CreateAssignJob, index: number) => ({
|
||||
...x,
|
||||
id: index + 1,
|
||||
assign_id: assign.id,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
})
|
||||
);
|
||||
const jobs = await requestBody.assign_jobs.map((x: CreateAssignJob, index: number) => ({
|
||||
...x,
|
||||
id: index + 1,
|
||||
assign_id: assign.id,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
}));
|
||||
await this.assignJobRepository.save(jobs, { data: request });
|
||||
setLogDataDiff(request, { before, after: jobs });
|
||||
|
||||
|
|
@ -149,36 +130,32 @@ export class AssignController extends Controller {
|
|||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
})
|
||||
}),
|
||||
);
|
||||
await this.assignKnowledgeRepository.save(knowledges, { data: request });
|
||||
setLogDataDiff(request, { before, after: knowledges });
|
||||
|
||||
const laws = await requestBody.assign_law.map(
|
||||
(x: CreateAssignLaw, index: number) => ({
|
||||
ordering: index + 1,
|
||||
law_id: x.id,
|
||||
assign_id: assign.id,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
})
|
||||
);
|
||||
const laws = await requestBody.assign_law.map((x: CreateAssignLaw, index: number) => ({
|
||||
ordering: index + 1,
|
||||
law_id: x.id,
|
||||
assign_id: assign.id,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
}));
|
||||
await this.assignLawRepository.save(laws, { data: request });
|
||||
setLogDataDiff(request, { before, after: laws });
|
||||
|
||||
const skills = await requestBody.assign_skill.map(
|
||||
(x: CreateAssignSkill, index: number) => ({
|
||||
skill_id: index + 1,
|
||||
skill_level: x.level,
|
||||
assign_id: assign.id,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
})
|
||||
);
|
||||
const skills = await requestBody.assign_skill.map((x: CreateAssignSkill, index: number) => ({
|
||||
skill_id: index + 1,
|
||||
skill_level: x.level,
|
||||
assign_id: assign.id,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
}));
|
||||
await this.assignSkillRepository.save(skills, { data: request });
|
||||
setLogDataDiff(request, { before, after: skills });
|
||||
|
||||
|
|
@ -193,7 +170,7 @@ export class AssignController extends Controller {
|
|||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
})
|
||||
}),
|
||||
);
|
||||
await this.assignCompetencyRepository.save(competencise, {
|
||||
data: request,
|
||||
|
|
@ -211,7 +188,7 @@ export class AssignController extends Controller {
|
|||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
})
|
||||
}),
|
||||
);
|
||||
await this.assignCompetencyGroupRepository.save(competencyGroups, {
|
||||
data: request,
|
||||
|
|
@ -227,7 +204,7 @@ export class AssignController extends Controller {
|
|||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
})
|
||||
}),
|
||||
);
|
||||
await this.assignOutputRepository.save(outputs, { data: request });
|
||||
setLogDataDiff(request, { before, after: outputs });
|
||||
|
|
@ -242,7 +219,7 @@ export class AssignController extends Controller {
|
|||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
})
|
||||
}),
|
||||
);
|
||||
await this.assignDirectorRepository.save(directors, { data: request });
|
||||
setLogDataDiff(request, { before, after: directors });
|
||||
|
|
@ -251,7 +228,7 @@ export class AssignController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -265,7 +242,7 @@ export class AssignController extends Controller {
|
|||
async EditAssign(
|
||||
@Query() assign_id: string,
|
||||
@Request() request: RequestWithUser,
|
||||
@Body() requestBody: CreateAssign
|
||||
@Body() requestBody: CreateAssign,
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
|
|
@ -276,10 +253,7 @@ export class AssignController extends Controller {
|
|||
let before = assign;
|
||||
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const person = await this.personalRepository.findOne({
|
||||
|
|
@ -303,17 +277,15 @@ export class AssignController extends Controller {
|
|||
};
|
||||
|
||||
await this.assignJobRepository.delete({ assign_id });
|
||||
const jobs = await requestBody.assign_jobs.map(
|
||||
(x: CreateAssignJob, index: number) => ({
|
||||
...x,
|
||||
id: index + 1,
|
||||
assign_id: assign.id,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
})
|
||||
);
|
||||
const jobs = await requestBody.assign_jobs.map((x: CreateAssignJob, index: number) => ({
|
||||
...x,
|
||||
id: index + 1,
|
||||
assign_id: assign.id,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
}));
|
||||
await this.assignJobRepository.save(jobs);
|
||||
|
||||
await this.assignKnowledgeRepository.delete({ assign_id });
|
||||
|
|
@ -326,36 +298,32 @@ export class AssignController extends Controller {
|
|||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
})
|
||||
}),
|
||||
);
|
||||
await this.assignKnowledgeRepository.save(knowledges);
|
||||
|
||||
await this.assignLawRepository.delete({ assign_id });
|
||||
const laws = await requestBody.assign_law.map(
|
||||
(x: CreateAssignLaw, index: number) => ({
|
||||
ordering: index + 1,
|
||||
law_id: x.id,
|
||||
assign_id: assign.id,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
})
|
||||
);
|
||||
const laws = await requestBody.assign_law.map((x: CreateAssignLaw, index: number) => ({
|
||||
ordering: index + 1,
|
||||
law_id: x.id,
|
||||
assign_id: assign.id,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
}));
|
||||
await this.assignLawRepository.save(laws);
|
||||
|
||||
await this.assignSkillRepository.delete({ assign_id });
|
||||
const skills = await requestBody.assign_skill.map(
|
||||
(x: CreateAssignSkill, index: number) => ({
|
||||
skill_id: index + 1,
|
||||
skill_level: x.level,
|
||||
assign_id: assign.id,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
})
|
||||
);
|
||||
const skills = await requestBody.assign_skill.map((x: CreateAssignSkill, index: number) => ({
|
||||
skill_id: index + 1,
|
||||
skill_level: x.level,
|
||||
assign_id: assign.id,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
}));
|
||||
await this.assignSkillRepository.save(skills);
|
||||
|
||||
await this.assignCompetencyRepository.delete({ assign_id });
|
||||
|
|
@ -370,7 +338,7 @@ export class AssignController extends Controller {
|
|||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
})
|
||||
}),
|
||||
);
|
||||
await this.assignCompetencyRepository.save(competencise);
|
||||
|
||||
|
|
@ -386,7 +354,7 @@ export class AssignController extends Controller {
|
|||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
})
|
||||
}),
|
||||
);
|
||||
await this.assignCompetencyGroupRepository.save(competencyGroups);
|
||||
|
||||
|
|
@ -400,7 +368,7 @@ export class AssignController extends Controller {
|
|||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
})
|
||||
}),
|
||||
);
|
||||
await this.assignOutputRepository.save(outputs);
|
||||
|
||||
|
|
@ -415,7 +383,7 @@ export class AssignController extends Controller {
|
|||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
})
|
||||
}),
|
||||
);
|
||||
await this.assignDirectorRepository.save(directors);
|
||||
|
||||
|
|
@ -488,7 +456,7 @@ export class AssignController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -499,18 +467,10 @@ export class AssignController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("assign-list")
|
||||
async ListPersonal(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query() personal_id: string
|
||||
) {
|
||||
async ListPersonal(@Request() request: RequestWithUser, @Query() personal_id: string) {
|
||||
try {
|
||||
let _workflow = await new permission().Workflow(
|
||||
request,
|
||||
personal_id,
|
||||
"SYS_PROBATION"
|
||||
);
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
let _workflow = await new permission().Workflow(request, personal_id, "SYS_PROBATION");
|
||||
if (_workflow == false) await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
const lists = await this.assignRepository.find({
|
||||
select: ["id", "round_no", "date_start", "date_finish"],
|
||||
where: { personal_id },
|
||||
|
|
@ -538,14 +498,10 @@ export class AssignController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
const commanderData = await (director.find(
|
||||
(x) => x.role == "commander"
|
||||
) ?? null);
|
||||
const commanderData = await (director.find((x) => x.role == "commander") ?? null);
|
||||
const commander = commanderData ? commanderData.fullname : null;
|
||||
|
||||
const chairmanData = await (director.find(
|
||||
(x) => x.role == "chairman"
|
||||
) ?? null);
|
||||
const chairmanData = await (director.find((x) => x.role == "chairman") ?? null);
|
||||
const chairman = chairmanData ? chairmanData.fullname : null;
|
||||
|
||||
await result.push({
|
||||
|
|
@ -554,14 +510,14 @@ export class AssignController extends Controller {
|
|||
commander: commander,
|
||||
chairman: chairman,
|
||||
});
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
return new HttpSuccess(result);
|
||||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -572,10 +528,7 @@ export class AssignController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("assign-user-list")
|
||||
async ListPersonalUser(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query() personal_id: string
|
||||
) {
|
||||
async ListPersonalUser(@Request() request: RequestWithUser, @Query() personal_id: string) {
|
||||
try {
|
||||
const lists = await this.assignRepository.find({
|
||||
select: ["id", "round_no", "date_start", "date_finish"],
|
||||
|
|
@ -604,14 +557,10 @@ export class AssignController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
const commanderData = await (director.find(
|
||||
(x) => x.role == "commander"
|
||||
) ?? null);
|
||||
const commanderData = await (director.find((x) => x.role == "commander") ?? null);
|
||||
const commander = commanderData ? commanderData.fullname : null;
|
||||
|
||||
const chairmanData = await (director.find(
|
||||
(x) => x.role == "chairman"
|
||||
) ?? null);
|
||||
const chairmanData = await (director.find((x) => x.role == "chairman") ?? null);
|
||||
const chairman = chairmanData ? chairmanData.fullname : null;
|
||||
|
||||
await result.push({
|
||||
|
|
@ -620,14 +569,14 @@ export class AssignController extends Controller {
|
|||
commander: commander,
|
||||
chairman: chairman,
|
||||
});
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
return new HttpSuccess(result);
|
||||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -641,16 +590,11 @@ export class AssignController extends Controller {
|
|||
async GetAssign(
|
||||
@Query() assign_id: string,
|
||||
@Query() isReport: boolean = false,
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
try {
|
||||
let _workflow = await new permission().Workflow(
|
||||
request,
|
||||
assign_id,
|
||||
"SYS_PROBATION"
|
||||
);
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
let _workflow = await new permission().Workflow(request, assign_id, "SYS_PROBATION");
|
||||
if (_workflow == false) await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
|
||||
const assign = await this.assignRepository.findOne({
|
||||
select: [
|
||||
|
|
@ -673,10 +617,7 @@ export class AssignController extends Controller {
|
|||
});
|
||||
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const profileData = await this.personalRepository.findOne({
|
||||
|
|
@ -707,11 +648,9 @@ export class AssignController extends Controller {
|
|||
name: `${profileData.prefixName}${profileData.firstName} ${profileData.lastName}`,
|
||||
Position: profileData.positionName,
|
||||
Department: splitOcAmount > 2 ? splitOc[splitOcAmount - 3] : "-",
|
||||
OrganizationOrganization:
|
||||
splitOcAmount > 1 ? splitOc[splitOcAmount - 2] : "-",
|
||||
OrganizationOrganization: splitOcAmount > 1 ? splitOc[splitOcAmount - 2] : "-",
|
||||
Oc: profileData.orgRootName,
|
||||
PositionAndLevel:
|
||||
profileData.positionName + profileData.positionLevelName,
|
||||
PositionAndLevel: profileData.positionName + profileData.positionLevelName,
|
||||
};
|
||||
|
||||
const jobs = await this.assignJobRepository.find({
|
||||
|
|
@ -764,7 +703,7 @@ export class AssignController extends Controller {
|
|||
description: description,
|
||||
status_select: x.status_select,
|
||||
};
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
const skillsData = await this.assignSkillRepository.find({
|
||||
|
|
@ -791,12 +730,7 @@ export class AssignController extends Controller {
|
|||
}));
|
||||
|
||||
const competencyData = await this.assignCompetencyRepository.find({
|
||||
select: [
|
||||
"competency_id",
|
||||
"competency_level",
|
||||
"competency_name",
|
||||
"competency_description",
|
||||
],
|
||||
select: ["competency_id", "competency_level", "competency_name", "competency_description"],
|
||||
where: { assign_id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
|
|
@ -808,17 +742,16 @@ export class AssignController extends Controller {
|
|||
description: x.competency_description,
|
||||
}));
|
||||
|
||||
const competencyGroupData =
|
||||
await this.assignCompetencyGroupRepository.find({
|
||||
select: [
|
||||
"competency_group_id",
|
||||
"competency_group_level",
|
||||
"competency_group_name",
|
||||
"competency_group_description",
|
||||
],
|
||||
where: { assign_id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
const competencyGroupData = await this.assignCompetencyGroupRepository.find({
|
||||
select: [
|
||||
"competency_group_id",
|
||||
"competency_group_level",
|
||||
"competency_group_name",
|
||||
"competency_group_description",
|
||||
],
|
||||
where: { assign_id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
const competency_groups = await competencyGroupData.map((x) => ({
|
||||
id: x.competency_group_id,
|
||||
level: x.competency_group_level,
|
||||
|
|
@ -844,18 +777,13 @@ export class AssignController extends Controller {
|
|||
mentors.push({
|
||||
...e,
|
||||
name: e.fullname,
|
||||
label:
|
||||
e.fullname +
|
||||
" " +
|
||||
(e.position ? `(${e.position}${e.posLevel})` : ""),
|
||||
label: e.fullname + " " + (e.position ? `(${e.position}${e.posLevel})` : ""),
|
||||
Position: e.position + e.posLevel, // report
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const commanderData = await (director.find(
|
||||
(x) => x.role == "commander"
|
||||
) ?? null);
|
||||
const commanderData = await (director.find((x) => x.role == "commander") ?? null);
|
||||
const commander = await (commanderData
|
||||
? {
|
||||
...commanderData,
|
||||
|
|
@ -870,8 +798,7 @@ export class AssignController extends Controller {
|
|||
}
|
||||
: null);
|
||||
|
||||
const chairmanData = await (director.find((x) => x.role == "chairman") ??
|
||||
null);
|
||||
const chairmanData = await (director.find((x) => x.role == "chairman") ?? null);
|
||||
const chairman = await (chairmanData
|
||||
? {
|
||||
...chairmanData,
|
||||
|
|
@ -879,9 +806,7 @@ export class AssignController extends Controller {
|
|||
label:
|
||||
chairmanData.fullname +
|
||||
" " +
|
||||
(chairmanData.position
|
||||
? `(${chairmanData.position}${chairmanData.posLevel})`
|
||||
: ""),
|
||||
(chairmanData.position ? `(${chairmanData.position}${chairmanData.posLevel})` : ""),
|
||||
Position: chairmanData.position + chairmanData.posLevel, // report
|
||||
}
|
||||
: null);
|
||||
|
|
@ -903,7 +828,7 @@ export class AssignController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -917,7 +842,7 @@ export class AssignController extends Controller {
|
|||
async GetAssignUser(
|
||||
@Query() assign_id: string,
|
||||
@Query() isReport: boolean = false,
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
try {
|
||||
const assign = await this.assignRepository.findOne({
|
||||
|
|
@ -941,10 +866,7 @@ export class AssignController extends Controller {
|
|||
});
|
||||
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const profileData = await this.personalRepository.findOne({
|
||||
|
|
@ -975,11 +897,9 @@ export class AssignController extends Controller {
|
|||
name: `${profileData.prefixName}${profileData.firstName} ${profileData.lastName}`,
|
||||
Position: profileData.positionName,
|
||||
Department: splitOcAmount > 2 ? splitOc[splitOcAmount - 3] : "-",
|
||||
OrganizationOrganization:
|
||||
splitOcAmount > 1 ? splitOc[splitOcAmount - 2] : "-",
|
||||
OrganizationOrganization: splitOcAmount > 1 ? splitOc[splitOcAmount - 2] : "-",
|
||||
Oc: profileData.orgRootName,
|
||||
PositionAndLevel:
|
||||
profileData.positionName + profileData.positionLevelName,
|
||||
PositionAndLevel: profileData.positionName + profileData.positionLevelName,
|
||||
};
|
||||
|
||||
const jobs = await this.assignJobRepository.find({
|
||||
|
|
@ -1032,7 +952,7 @@ export class AssignController extends Controller {
|
|||
description: description,
|
||||
status_select: x.status_select,
|
||||
};
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
const skillsData = await this.assignSkillRepository.find({
|
||||
|
|
@ -1059,12 +979,7 @@ export class AssignController extends Controller {
|
|||
}));
|
||||
|
||||
const competencyData = await this.assignCompetencyRepository.find({
|
||||
select: [
|
||||
"competency_id",
|
||||
"competency_level",
|
||||
"competency_name",
|
||||
"competency_description",
|
||||
],
|
||||
select: ["competency_id", "competency_level", "competency_name", "competency_description"],
|
||||
where: { assign_id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
|
|
@ -1076,17 +991,16 @@ export class AssignController extends Controller {
|
|||
description: x.competency_description,
|
||||
}));
|
||||
|
||||
const competencyGroupData =
|
||||
await this.assignCompetencyGroupRepository.find({
|
||||
select: [
|
||||
"competency_group_id",
|
||||
"competency_group_level",
|
||||
"competency_group_name",
|
||||
"competency_group_description",
|
||||
],
|
||||
where: { assign_id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
const competencyGroupData = await this.assignCompetencyGroupRepository.find({
|
||||
select: [
|
||||
"competency_group_id",
|
||||
"competency_group_level",
|
||||
"competency_group_name",
|
||||
"competency_group_description",
|
||||
],
|
||||
where: { assign_id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
const competency_groups = await competencyGroupData.map((x) => ({
|
||||
id: x.competency_group_id,
|
||||
level: x.competency_group_level,
|
||||
|
|
@ -1112,18 +1026,13 @@ export class AssignController extends Controller {
|
|||
mentors.push({
|
||||
...e,
|
||||
name: e.fullname,
|
||||
label:
|
||||
e.fullname +
|
||||
" " +
|
||||
(e.position ? `(${e.position}${e.posLevel})` : ""),
|
||||
label: e.fullname + " " + (e.position ? `(${e.position}${e.posLevel})` : ""),
|
||||
Position: e.position + e.posLevel, // report
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const commanderData = await (director.find(
|
||||
(x) => x.role == "commander"
|
||||
) ?? null);
|
||||
const commanderData = await (director.find((x) => x.role == "commander") ?? null);
|
||||
const commander = await (commanderData
|
||||
? {
|
||||
...commanderData,
|
||||
|
|
@ -1138,8 +1047,7 @@ export class AssignController extends Controller {
|
|||
}
|
||||
: null);
|
||||
|
||||
const chairmanData = await (director.find((x) => x.role == "chairman") ??
|
||||
null);
|
||||
const chairmanData = await (director.find((x) => x.role == "chairman") ?? null);
|
||||
const chairman = await (chairmanData
|
||||
? {
|
||||
...chairmanData,
|
||||
|
|
@ -1147,9 +1055,7 @@ export class AssignController extends Controller {
|
|||
label:
|
||||
chairmanData.fullname +
|
||||
" " +
|
||||
(chairmanData.position
|
||||
? `(${chairmanData.position}${chairmanData.posLevel})`
|
||||
: ""),
|
||||
(chairmanData.position ? `(${chairmanData.position}${chairmanData.posLevel})` : ""),
|
||||
Position: chairmanData.position + chairmanData.posLevel, // report
|
||||
}
|
||||
: null);
|
||||
|
|
@ -1171,7 +1077,7 @@ export class AssignController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,10 +17,7 @@ export class AssignPermissionsController extends Controller {
|
|||
private assignRepository = AppDataSource.getRepository(Assign);
|
||||
|
||||
@Get("{id}")
|
||||
async GetAssignPermissions(
|
||||
@Request() request: RequestWithUser,
|
||||
@Path() id: string
|
||||
) {
|
||||
async GetAssignPermissions(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
try {
|
||||
const director = await this.assignDirector.find({
|
||||
where: { assign_id: id },
|
||||
|
|
@ -32,8 +29,7 @@ export class AssignPermissionsController extends Controller {
|
|||
console.error("Error calling API:", error);
|
||||
});
|
||||
|
||||
const role = await director.find((e: any) => e.personal_id === personalId)
|
||||
?.role;
|
||||
const role = await director.find((e: any) => e.personal_id === personalId)?.role;
|
||||
|
||||
const reportPersonId = await this.assignRepository.findOneBy({
|
||||
id,
|
||||
|
|
@ -75,7 +71,7 @@ export class AssignPermissionsController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import { findEndDate } from "../interfaces/utils";
|
|||
@Security("bearerAuth")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง"
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||
)
|
||||
export class CalculateController extends Controller {
|
||||
/**
|
||||
|
|
@ -37,7 +37,7 @@ export class CalculateController extends Controller {
|
|||
month: number;
|
||||
start_date: Date;
|
||||
},
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
try {
|
||||
const { month, start_date } = requestBody;
|
||||
|
|
@ -47,7 +47,7 @@ export class CalculateController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,13 +27,12 @@ import permission from "../interfaces/permission";
|
|||
@Security("bearerAuth")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง"
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||
)
|
||||
export class DataOptionController extends Controller {
|
||||
private personalRepository = AppDataSource.getRepository(Personal);
|
||||
private knowledgeRepository = AppDataSource.getRepository(Knowledge);
|
||||
private mapKnowledgeSkillRepository =
|
||||
AppDataSource.getRepository(MapKnowledgeSkill);
|
||||
private mapKnowledgeSkillRepository = AppDataSource.getRepository(MapKnowledgeSkill);
|
||||
private skillRepository = AppDataSource.getRepository(Skill);
|
||||
private lawRepository = AppDataSource.getRepository(Law);
|
||||
private assignRepository = AppDataSource.getRepository(Assign);
|
||||
|
|
@ -74,10 +73,7 @@ export class DataOptionController extends Controller {
|
|||
}
|
||||
|
||||
if (!result) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลความรู้ที่ตรงกับตำแหน่ง"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลความรู้ที่ตรงกับตำแหน่ง");
|
||||
}
|
||||
|
||||
const knowledges = await this.knowledgeRepository.find({
|
||||
|
|
@ -103,7 +99,7 @@ export class DataOptionController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -155,10 +151,7 @@ export class DataOptionController extends Controller {
|
|||
}
|
||||
|
||||
if (!result) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลทักษะที่ตรงกับตำแหน่ง"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะที่ตรงกับตำแหน่ง");
|
||||
}
|
||||
|
||||
const computerData = await this.skillRepository.findOne({
|
||||
|
|
@ -166,10 +159,7 @@ export class DataOptionController extends Controller {
|
|||
});
|
||||
|
||||
if (!computerData) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลทักษะคอมพิวเตอร์"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะคอมพิวเตอร์");
|
||||
}
|
||||
const computer = await {
|
||||
id: computerData.id,
|
||||
|
|
@ -192,10 +182,7 @@ export class DataOptionController extends Controller {
|
|||
});
|
||||
|
||||
if (!englishData) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลทักษะภาษาอังกฤษ"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะภาษาอังกฤษ");
|
||||
}
|
||||
|
||||
const english = await {
|
||||
|
|
@ -270,7 +257,7 @@ export class DataOptionController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -303,7 +290,7 @@ export class DataOptionController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -314,18 +301,10 @@ export class DataOptionController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("new-assign")
|
||||
async NewAssign(
|
||||
@Query() personal_id: string,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
async NewAssign(@Query() personal_id: string, @Request() request: RequestWithUser) {
|
||||
try {
|
||||
let _workflow = await new permission().Workflow(
|
||||
request,
|
||||
personal_id,
|
||||
"SYS_PROBATION"
|
||||
);
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
let _workflow = await new permission().Workflow(request, personal_id, "SYS_PROBATION");
|
||||
if (_workflow == false) await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
|
||||
const person = await this.personalRepository.findOne({
|
||||
select: [
|
||||
|
|
@ -369,7 +348,7 @@ export class DataOptionController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
|
@ -379,10 +358,7 @@ export class DataOptionController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("new-assign-user")
|
||||
async NewAssignUser(
|
||||
@Query() personal_id: string,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
async NewAssignUser(@Query() personal_id: string, @Request() request: RequestWithUser) {
|
||||
try {
|
||||
const person = await this.personalRepository.findOne({
|
||||
select: [
|
||||
|
|
@ -426,7 +402,7 @@ export class DataOptionController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,24 +22,19 @@ import HttpError from "../interfaces/http-error";
|
|||
import { Assign } from "../entities/Assign";
|
||||
import { Personal } from "../entities/Personal";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
import {
|
||||
CreateEvaluateChairman,
|
||||
EvaluateChairman,
|
||||
} from "../entities/EvaluateChairman";
|
||||
import { CreateEvaluateChairman, EvaluateChairman } from "../entities/EvaluateChairman";
|
||||
import permission from "../interfaces/permission";
|
||||
@Route("api/v1/probation/evaluate-chairman")
|
||||
@Tags("แบบประเมินผล (คณะกรรมการ)")
|
||||
@Security("bearerAuth")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง"
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||
)
|
||||
export class EvaluateChairmanController 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);
|
||||
|
||||
/**
|
||||
|
|
@ -49,18 +44,10 @@ export class EvaluateChairmanController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("create")
|
||||
async CreateEvaluate(
|
||||
@Query() assign_id: string,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||
try {
|
||||
let _workflow = await new permission().Workflow(
|
||||
request,
|
||||
assign_id,
|
||||
"SYS_PROBATION"
|
||||
);
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
let _workflow = await new permission().Workflow(request, assign_id, "SYS_PROBATION");
|
||||
if (_workflow == false) await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
|
||||
const director = await this.assignDirectorRepository.findOne({
|
||||
select: ["personal_id"],
|
||||
|
|
@ -79,10 +66,7 @@ export class EvaluateChairmanController extends Controller {
|
|||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const profile = await (assign.profile
|
||||
|
|
@ -90,10 +74,7 @@ export class EvaluateChairmanController 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);
|
||||
|
|
@ -116,10 +97,7 @@ export class EvaluateChairmanController extends Controller {
|
|||
});
|
||||
|
||||
if (!directorData) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
|
||||
}
|
||||
|
||||
let mentors = [];
|
||||
|
|
@ -132,10 +110,7 @@ export class EvaluateChairmanController extends Controller {
|
|||
personal_id: e.personal_id,
|
||||
dated: e.dated,
|
||||
name: e.fullname,
|
||||
label:
|
||||
e.fullname +
|
||||
" " +
|
||||
(e.position ? `(${e.position}${e.posLevel})` : ""),
|
||||
label: e.fullname + " " + (e.position ? `(${e.position}${e.posLevel})` : ""),
|
||||
position: e.position,
|
||||
posType: e.posType,
|
||||
posLevel: e.posLevel,
|
||||
|
|
@ -143,9 +118,7 @@ export class EvaluateChairmanController 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 != null
|
||||
|
|
@ -165,9 +138,7 @@ export class EvaluateChairmanController extends Controller {
|
|||
}
|
||||
: null;
|
||||
|
||||
const chairmanData = await (directorData.find(
|
||||
(x) => x.role == "chairman"
|
||||
) ?? null);
|
||||
const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null);
|
||||
const chairman =
|
||||
chairmanData != null
|
||||
? {
|
||||
|
|
@ -177,9 +148,7 @@ export class EvaluateChairmanController extends Controller {
|
|||
label:
|
||||
chairmanData.fullname +
|
||||
" " +
|
||||
(chairmanData.position
|
||||
? `(${chairmanData.position}${chairmanData.posLevel})`
|
||||
: ""),
|
||||
(chairmanData.position ? `(${chairmanData.position}${chairmanData.posLevel})` : ""),
|
||||
position: chairmanData.position,
|
||||
posType: chairmanData.posType,
|
||||
posLevel: chairmanData.posLevel,
|
||||
|
|
@ -199,7 +168,7 @@ export class EvaluateChairmanController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -213,7 +182,7 @@ export class EvaluateChairmanController extends Controller {
|
|||
async GetEvaluate(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query() assign_id: string,
|
||||
@Query() evaluate_no?: string
|
||||
@Query() evaluate_no?: string,
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
|
|
@ -261,10 +230,7 @@ export class EvaluateChairmanController extends Controller {
|
|||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const experimenteeData = await this.personalRepository.find({
|
||||
|
|
@ -292,10 +258,7 @@ export class EvaluateChairmanController extends Controller {
|
|||
});
|
||||
|
||||
if (!directorData) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
|
||||
}
|
||||
|
||||
let mentors = [];
|
||||
|
|
@ -308,10 +271,7 @@ export class EvaluateChairmanController extends Controller {
|
|||
personal_id: e.personal_id,
|
||||
dated: e.dated,
|
||||
name: e.fullname,
|
||||
label:
|
||||
e.fullname +
|
||||
" " +
|
||||
(e.position ? `(${e.position}${e.posLevel})` : ""),
|
||||
label: e.fullname + " " + (e.position ? `(${e.position}${e.posLevel})` : ""),
|
||||
position: e.position,
|
||||
posType: e.posType,
|
||||
posLevel: e.posLevel,
|
||||
|
|
@ -319,9 +279,7 @@ export class EvaluateChairmanController 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 != null
|
||||
|
|
@ -341,9 +299,7 @@ export class EvaluateChairmanController extends Controller {
|
|||
}
|
||||
: null;
|
||||
|
||||
const chairmanData = await (directorData.find(
|
||||
(x) => x.role == "chairman"
|
||||
) ?? null);
|
||||
const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null);
|
||||
const chairman =
|
||||
chairmanData != null
|
||||
? {
|
||||
|
|
@ -353,9 +309,7 @@ export class EvaluateChairmanController extends Controller {
|
|||
label:
|
||||
chairmanData.fullname +
|
||||
" " +
|
||||
(chairmanData.position
|
||||
? `(${chairmanData.position}${chairmanData.posLevel})`
|
||||
: ""),
|
||||
(chairmanData.position ? `(${chairmanData.position}${chairmanData.posLevel})` : ""),
|
||||
position: chairmanData.position,
|
||||
posType: chairmanData.posType,
|
||||
posLevel: chairmanData.posLevel,
|
||||
|
|
@ -373,7 +327,7 @@ export class EvaluateChairmanController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -387,7 +341,7 @@ export class EvaluateChairmanController extends Controller {
|
|||
async PostData(
|
||||
@Query() assign_id: string,
|
||||
@Body() requestBody: CreateEvaluateChairman,
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
|
|
@ -410,10 +364,7 @@ export class EvaluateChairmanController extends Controller {
|
|||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const postData: any = await {
|
||||
|
|
@ -432,9 +383,7 @@ export class EvaluateChairmanController 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,
|
||||
|
|
@ -471,7 +420,7 @@ export class EvaluateChairmanController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -486,7 +435,7 @@ export class EvaluateChairmanController extends Controller {
|
|||
// @Query() assign_id: string,
|
||||
@Query() evaluate_id: string,
|
||||
@Body() requestBody: CreateEvaluateChairman,
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
|
|
@ -511,9 +460,7 @@ export class EvaluateChairmanController 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;
|
||||
|
|
@ -529,25 +476,15 @@ export class EvaluateChairmanController 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;
|
||||
evaluate.develop_orientation_score =
|
||||
requestBody.develop_orientation_score;
|
||||
evaluate.develop_self_learning_score =
|
||||
requestBody.develop_self_learning_score;
|
||||
evaluate.develop_training_seminar_score =
|
||||
requestBody.develop_training_seminar_score;
|
||||
evaluate.develop_other_training_score =
|
||||
requestBody.develop_other_training_score;
|
||||
evaluate.develop_orientation_percent =
|
||||
requestBody.develop_orientation_percent;
|
||||
evaluate.develop_self_learning_percent =
|
||||
requestBody.develop_self_learning_percent;
|
||||
evaluate.develop_training_seminar_percent =
|
||||
requestBody.develop_training_seminar_percent;
|
||||
evaluate.develop_other_training_percent =
|
||||
requestBody.develop_other_training_percent;
|
||||
requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0;
|
||||
evaluate.develop_orientation_score = requestBody.develop_orientation_score;
|
||||
evaluate.develop_self_learning_score = requestBody.develop_self_learning_score;
|
||||
evaluate.develop_training_seminar_score = requestBody.develop_training_seminar_score;
|
||||
evaluate.develop_other_training_score = requestBody.develop_other_training_score;
|
||||
evaluate.develop_orientation_percent = requestBody.develop_orientation_percent;
|
||||
evaluate.develop_self_learning_percent = requestBody.develop_self_learning_percent;
|
||||
evaluate.develop_training_seminar_percent = requestBody.develop_training_seminar_percent;
|
||||
evaluate.develop_other_training_percent = requestBody.develop_other_training_percent;
|
||||
evaluate.develop_result = requestBody.develop_result;
|
||||
evaluate.achievement_score = requestBody.achievement_score;
|
||||
evaluate.achievement_score_total = requestBody.achievement_score_total;
|
||||
|
|
@ -571,7 +508,7 @@ export class EvaluateChairmanController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,7 @@ 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";
|
||||
import permission from "../interfaces/permission";
|
||||
|
|
@ -32,14 +29,12 @@ import permission from "../interfaces/permission";
|
|||
@Security("bearerAuth")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง"
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||
)
|
||||
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);
|
||||
|
||||
/**
|
||||
|
|
@ -49,18 +44,10 @@ export class EvaluateController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("create")
|
||||
async CreateEvaluate(
|
||||
@Query() assign_id: string,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||
try {
|
||||
let _workflow = await new permission().Workflow(
|
||||
request,
|
||||
assign_id,
|
||||
"SYS_PROBATION"
|
||||
);
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
let _workflow = await new permission().Workflow(request, assign_id, "SYS_PROBATION");
|
||||
if (_workflow == false) await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
|
||||
const director = await this.assignDirectorRepository.findOne({
|
||||
select: ["personal_id"],
|
||||
|
|
@ -79,10 +66,7 @@ export class EvaluateController extends Controller {
|
|||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const profile = await (assign.profile
|
||||
|
|
@ -90,10 +74,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);
|
||||
|
|
@ -111,21 +92,11 @@ export class EvaluateController extends Controller {
|
|||
: findEndDate(evaluate_amount * 3, assign.date_start);
|
||||
|
||||
const commanderData = await this.assignDirectorRepository.findOne({
|
||||
select: [
|
||||
"personal_id",
|
||||
"dated",
|
||||
"fullname",
|
||||
"position",
|
||||
"posType",
|
||||
"posLevel",
|
||||
],
|
||||
select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"],
|
||||
where: { personal_id: director_id },
|
||||
});
|
||||
if (!commanderData) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลผู้บังคับบัญชา"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้บังคับบัญชา");
|
||||
}
|
||||
const commander = await {
|
||||
...commanderData,
|
||||
|
|
@ -144,7 +115,7 @@ export class EvaluateController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -158,7 +129,7 @@ export class EvaluateController extends Controller {
|
|||
async GetEvaluate(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query() assign_id: string,
|
||||
@Query() evaluate_no?: string
|
||||
@Query() evaluate_no?: string,
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
|
|
@ -207,10 +178,7 @@ export class EvaluateController extends Controller {
|
|||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
// const profile = await (assign.profile
|
||||
|
|
@ -239,14 +207,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 },
|
||||
});
|
||||
|
||||
|
|
@ -284,7 +245,7 @@ export class EvaluateController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -298,7 +259,7 @@ export class EvaluateController extends Controller {
|
|||
async PostData(
|
||||
@Query() assign_id: string,
|
||||
@Body() requestBody: CreateEvaluateCommander,
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
|
|
@ -321,10 +282,7 @@ export class EvaluateController extends Controller {
|
|||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const postData: any = await {
|
||||
|
|
@ -343,9 +301,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,
|
||||
|
|
@ -382,7 +338,7 @@ export class EvaluateController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -397,7 +353,7 @@ export class EvaluateController extends Controller {
|
|||
// @Query() assign_id: string,
|
||||
@Query() evaluate_id: string,
|
||||
@Body() requestBody: CreateEvaluateCommander,
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
|
|
@ -423,9 +379,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;
|
||||
|
|
@ -441,9 +395,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;
|
||||
|
|
@ -460,7 +412,7 @@ export class EvaluateController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,14 +22,8 @@ import HttpError from "../interfaces/http-error";
|
|||
import { Assign } from "../entities/Assign";
|
||||
import { Personal } from "../entities/Personal";
|
||||
import { AssignOutput } from "../entities/AssignOutput";
|
||||
import {
|
||||
CreateEvaluateAssessor,
|
||||
EvaluateAssessor,
|
||||
} from "../entities/EvaluateAssessor";
|
||||
import {
|
||||
CreateEvaluateAchievement,
|
||||
EvaluateAchievement,
|
||||
} from "../entities/EvaluateAchievement";
|
||||
import { CreateEvaluateAssessor, EvaluateAssessor } from "../entities/EvaluateAssessor";
|
||||
import { CreateEvaluateAchievement, EvaluateAchievement } from "../entities/EvaluateAchievement";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
import permission from "../interfaces/permission";
|
||||
@Route("api/v1/probation/evaluate-record")
|
||||
|
|
@ -37,18 +31,15 @@ import permission from "../interfaces/permission";
|
|||
@Security("bearerAuth")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง"
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||
)
|
||||
export class EvaluateRecordController extends Controller {
|
||||
private assignDirectorRepository =
|
||||
AppDataSource.getRepository(AssignDirector);
|
||||
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector);
|
||||
private assignRepository = AppDataSource.getRepository(Assign);
|
||||
private personalRepository = AppDataSource.getRepository(Personal);
|
||||
private assignOutputRepository = AppDataSource.getRepository(AssignOutput);
|
||||
private evaluateAssessorRepository =
|
||||
AppDataSource.getRepository(EvaluateAssessor);
|
||||
private evaluateAchievementRepository =
|
||||
AppDataSource.getRepository(EvaluateAchievement);
|
||||
private evaluateAssessorRepository = AppDataSource.getRepository(EvaluateAssessor);
|
||||
private evaluateAchievementRepository = AppDataSource.getRepository(EvaluateAchievement);
|
||||
|
||||
/**
|
||||
* API ดึงข้อมูลตอนกดสร้างแบบบันทึกผล
|
||||
|
|
@ -57,28 +48,13 @@ export class EvaluateRecordController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("create")
|
||||
async GetCreate(
|
||||
@Query() assign_id: string,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
async GetCreate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||
try {
|
||||
let _workflow = await new permission().Workflow(
|
||||
request,
|
||||
assign_id,
|
||||
"SYS_PROBATION"
|
||||
);
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
let _workflow = await new permission().Workflow(request, assign_id, "SYS_PROBATION");
|
||||
if (_workflow == false) await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
|
||||
const directorData = await this.assignDirectorRepository.findOne({
|
||||
select: [
|
||||
"personal_id",
|
||||
"dated",
|
||||
"fullname",
|
||||
"position",
|
||||
"posType",
|
||||
"posLevel",
|
||||
],
|
||||
select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"],
|
||||
where: {
|
||||
assign_id,
|
||||
role: "mentor",
|
||||
|
|
@ -104,10 +80,7 @@ export class EvaluateRecordController extends Controller {
|
|||
});
|
||||
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const profileData = await this.personalRepository.findOne({
|
||||
|
|
@ -130,11 +103,7 @@ export class EvaluateRecordController extends Controller {
|
|||
|
||||
const profile = await {
|
||||
id: profileData.personal_id,
|
||||
name:
|
||||
profileData.prefixName +
|
||||
profileData.firstName +
|
||||
" " +
|
||||
profileData.lastName,
|
||||
name: profileData.prefixName + profileData.firstName + " " + profileData.lastName,
|
||||
positionName: profileData.positionName,
|
||||
positionLevelName: profileData.positionLevelName,
|
||||
Oc: profileData.organization,
|
||||
|
|
@ -161,22 +130,12 @@ export class EvaluateRecordController extends Controller {
|
|||
: findEndDate(evaluate_amount * 2, assign.date_start));
|
||||
|
||||
var commanderData = await this.assignDirectorRepository.findOne({
|
||||
select: [
|
||||
"personal_id",
|
||||
"dated",
|
||||
"fullname",
|
||||
"position",
|
||||
"posType",
|
||||
"posLevel",
|
||||
],
|
||||
select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"],
|
||||
where: { personal_id: director_id },
|
||||
});
|
||||
|
||||
if (!commanderData) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลผู้บังคับบัญชา"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้บังคับบัญชา");
|
||||
}
|
||||
|
||||
const commander = await {
|
||||
|
|
@ -197,7 +156,7 @@ export class EvaluateRecordController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -211,7 +170,7 @@ export class EvaluateRecordController extends Controller {
|
|||
async GetData(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query() assign_id: string,
|
||||
@Query() evaluate_no?: string
|
||||
@Query() evaluate_no?: string,
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
|
|
@ -241,19 +200,11 @@ export class EvaluateRecordController extends Controller {
|
|||
});
|
||||
|
||||
if (!evaluate) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบประเมิน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน");
|
||||
}
|
||||
|
||||
const achievementData = await this.evaluateAchievementRepository.find({
|
||||
select: [
|
||||
"output_desc",
|
||||
"evaluate_expect_level",
|
||||
"output_desc",
|
||||
"evaluate_output_level",
|
||||
],
|
||||
select: ["output_desc", "evaluate_expect_level", "output_desc", "evaluate_output_level"],
|
||||
where: {
|
||||
evaluate_id: evaluate.id,
|
||||
},
|
||||
|
|
@ -327,19 +278,18 @@ export class EvaluateRecordController extends Controller {
|
|||
|
||||
await Promise.all(
|
||||
evaluate.map(async (element: any, index: number) => {
|
||||
const achievementData =
|
||||
await this.evaluateAchievementRepository.find({
|
||||
select: [
|
||||
"output_desc",
|
||||
"evaluate_expect_level",
|
||||
"output_desc",
|
||||
"evaluate_output_level",
|
||||
],
|
||||
where: {
|
||||
evaluate_id: element.id,
|
||||
},
|
||||
order: { output_id: "ASC" },
|
||||
});
|
||||
const achievementData = await this.evaluateAchievementRepository.find({
|
||||
select: [
|
||||
"output_desc",
|
||||
"evaluate_expect_level",
|
||||
"output_desc",
|
||||
"evaluate_output_level",
|
||||
],
|
||||
where: {
|
||||
evaluate_id: element.id,
|
||||
},
|
||||
order: { output_id: "ASC" },
|
||||
});
|
||||
|
||||
const achievements = await achievementData.map((achievement) => {
|
||||
return {
|
||||
|
|
@ -390,7 +340,7 @@ export class EvaluateRecordController extends Controller {
|
|||
updatedAt: element.updatedAt,
|
||||
achievements: achievements,
|
||||
};
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -401,10 +351,7 @@ export class EvaluateRecordController extends Controller {
|
|||
});
|
||||
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const experimenteeData = await this.personalRepository.find({
|
||||
|
|
@ -427,14 +374,7 @@ export class EvaluateRecordController extends Controller {
|
|||
}));
|
||||
|
||||
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 },
|
||||
});
|
||||
|
||||
|
|
@ -453,7 +393,7 @@ export class EvaluateRecordController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -467,7 +407,7 @@ export class EvaluateRecordController extends Controller {
|
|||
async PostData(
|
||||
@Query() assign_id: string,
|
||||
@Body() requestBody: CreateEvaluateAssessor,
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
|
|
@ -490,10 +430,7 @@ export class EvaluateRecordController extends Controller {
|
|||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const postData: any = await {
|
||||
|
|
@ -512,9 +449,7 @@ export class EvaluateRecordController extends Controller {
|
|||
: 0,
|
||||
behavior_other_desc: requestBody.behavio_orther.text,
|
||||
behavior_other_level:
|
||||
requestBody.behavio_orther.text != ""
|
||||
? Number(requestBody.behavio_orther.level)
|
||||
: 0,
|
||||
requestBody.behavio_orther.text != "" ? Number(requestBody.behavio_orther.level) : 0,
|
||||
behavior_strength_desc: requestBody.behavior_strength_desc,
|
||||
behavior_improve_desc: requestBody.behavior_improve_desc,
|
||||
orientation: requestBody.orientation,
|
||||
|
|
@ -527,12 +462,9 @@ export class EvaluateRecordController extends Controller {
|
|||
updateFullName: request.user.name,
|
||||
};
|
||||
|
||||
const evaluateAssessor = await this.evaluateAssessorRepository.save(
|
||||
postData,
|
||||
{
|
||||
data: request,
|
||||
}
|
||||
);
|
||||
const evaluateAssessor = await this.evaluateAssessorRepository.save(postData, {
|
||||
data: request,
|
||||
});
|
||||
|
||||
if (evaluateAssessor) {
|
||||
await Promise.all(
|
||||
|
|
@ -545,9 +477,7 @@ export class EvaluateRecordController extends Controller {
|
|||
assessor_id: director_id,
|
||||
evaluate_expect_level: Number(expenct.level),
|
||||
output_desc: requestBody.evaluate_ouptut[index].text,
|
||||
evaluate_output_level: Number(
|
||||
requestBody.evaluate_ouptut[index].level
|
||||
),
|
||||
evaluate_output_level: Number(requestBody.evaluate_ouptut[index].level),
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
|
|
@ -556,7 +486,7 @@ export class EvaluateRecordController extends Controller {
|
|||
await this.evaluateAchievementRepository.save(evaluateAchievement, {
|
||||
data: request,
|
||||
});
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -586,7 +516,7 @@ export class EvaluateRecordController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -601,7 +531,7 @@ export class EvaluateRecordController extends Controller {
|
|||
@Query() assign_id: string,
|
||||
@Query() evaluate_id: string,
|
||||
@Body() requestBody: CreateEvaluateAssessor,
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
|
|
@ -639,12 +569,9 @@ export class EvaluateRecordController 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.achievement_strength_desc =
|
||||
requestBody.achievement_strength_desc;
|
||||
evaluate.achievement_strength_desc = requestBody.achievement_strength_desc;
|
||||
evaluate.achievement_improve_desc = requestBody.achievement_improve_desc;
|
||||
evaluate.conduct1_level = requestBody.conduct1_level;
|
||||
evaluate.conduct2_level = requestBody.conduct2_level;
|
||||
|
|
@ -660,9 +587,7 @@ export class EvaluateRecordController extends Controller {
|
|||
evaluate.discipline5_level = requestBody.discipline5_level;
|
||||
evaluate.behavior_other_desc = requestBody.behavio_orther.text;
|
||||
evaluate.behavior_other_level =
|
||||
requestBody.behavio_orther.text != ""
|
||||
? Number(requestBody.behavio_orther.level)
|
||||
: 0;
|
||||
requestBody.behavio_orther.text != "" ? Number(requestBody.behavio_orther.level) : 0;
|
||||
evaluate.behavior_strength_desc = requestBody.behavior_strength_desc;
|
||||
evaluate.behavior_improve_desc = requestBody.behavior_improve_desc;
|
||||
evaluate.orientation = requestBody.orientation;
|
||||
|
|
@ -672,12 +597,9 @@ export class EvaluateRecordController extends Controller {
|
|||
evaluate.updateUserId = request.user.sub;
|
||||
evaluate.updateFullName = request.user.name;
|
||||
|
||||
const evaluateAssessor = await this.evaluateAssessorRepository.save(
|
||||
evaluate,
|
||||
{
|
||||
data: request,
|
||||
}
|
||||
);
|
||||
const evaluateAssessor = await this.evaluateAssessorRepository.save(evaluate, {
|
||||
data: request,
|
||||
});
|
||||
|
||||
if (evaluateAssessor) {
|
||||
await this.evaluateAchievementRepository.delete({
|
||||
|
|
@ -692,9 +614,7 @@ export class EvaluateRecordController extends Controller {
|
|||
assessor_id: director_id,
|
||||
evaluate_expect_level: Number(expenct.level),
|
||||
output_desc: requestBody.evaluate_ouptut[index].text,
|
||||
evaluate_output_level: Number(
|
||||
requestBody.evaluate_ouptut[index].level
|
||||
),
|
||||
evaluate_output_level: Number(requestBody.evaluate_ouptut[index].level),
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
|
|
@ -703,7 +623,7 @@ export class EvaluateRecordController extends Controller {
|
|||
await this.evaluateAchievementRepository.save(evaluateAchievement, {
|
||||
data: request,
|
||||
});
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -713,7 +633,7 @@ export class EvaluateRecordController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -724,28 +644,13 @@ export class EvaluateRecordController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("create/commander")
|
||||
async GetCreateCommander(
|
||||
@Query() assign_id: string,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
async GetCreateCommander(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||
try {
|
||||
let _workflow = await new permission().Workflow(
|
||||
request,
|
||||
assign_id,
|
||||
"SYS_PROBATION"
|
||||
);
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
let _workflow = await new permission().Workflow(request, assign_id, "SYS_PROBATION");
|
||||
if (_workflow == false) await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
|
||||
const directorData = await this.assignDirectorRepository.findOne({
|
||||
select: [
|
||||
"personal_id",
|
||||
"dated",
|
||||
"fullname",
|
||||
"position",
|
||||
"posType",
|
||||
"posLevel",
|
||||
],
|
||||
select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"],
|
||||
where: {
|
||||
assign_id,
|
||||
role: "commander",
|
||||
|
|
@ -771,10 +676,7 @@ export class EvaluateRecordController extends Controller {
|
|||
});
|
||||
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const profileData = await this.personalRepository.findOne({
|
||||
|
|
@ -797,11 +699,7 @@ export class EvaluateRecordController extends Controller {
|
|||
|
||||
const profile = await {
|
||||
id: profileData.personal_id,
|
||||
name:
|
||||
profileData.prefixName +
|
||||
profileData.firstName +
|
||||
" " +
|
||||
profileData.lastName,
|
||||
name: profileData.prefixName + profileData.firstName + " " + profileData.lastName,
|
||||
positionName: profileData.positionName,
|
||||
positionLevelName: profileData.positionLevelName,
|
||||
Oc: profileData.organization,
|
||||
|
|
@ -839,7 +737,7 @@ export class EvaluateRecordController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -853,7 +751,7 @@ export class EvaluateRecordController extends Controller {
|
|||
async GetDataCommander(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query() assign_id: string,
|
||||
@Query() evaluate_no?: string
|
||||
@Query() evaluate_no?: string,
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
|
|
@ -883,19 +781,11 @@ export class EvaluateRecordController extends Controller {
|
|||
});
|
||||
|
||||
if (!evaluate) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบประเมิน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน");
|
||||
}
|
||||
|
||||
const achievementData = await this.evaluateAchievementRepository.find({
|
||||
select: [
|
||||
"output_desc",
|
||||
"evaluate_expect_level",
|
||||
"output_desc",
|
||||
"evaluate_output_level",
|
||||
],
|
||||
select: ["output_desc", "evaluate_expect_level", "output_desc", "evaluate_output_level"],
|
||||
where: {
|
||||
evaluate_id: evaluate.id,
|
||||
},
|
||||
|
|
@ -969,19 +859,18 @@ export class EvaluateRecordController extends Controller {
|
|||
|
||||
await Promise.all(
|
||||
evaluate.map(async (element: any, index: number) => {
|
||||
const achievementData =
|
||||
await this.evaluateAchievementRepository.find({
|
||||
select: [
|
||||
"output_desc",
|
||||
"evaluate_expect_level",
|
||||
"output_desc",
|
||||
"evaluate_output_level",
|
||||
],
|
||||
where: {
|
||||
evaluate_id: element.id,
|
||||
},
|
||||
order: { output_id: "ASC" },
|
||||
});
|
||||
const achievementData = await this.evaluateAchievementRepository.find({
|
||||
select: [
|
||||
"output_desc",
|
||||
"evaluate_expect_level",
|
||||
"output_desc",
|
||||
"evaluate_output_level",
|
||||
],
|
||||
where: {
|
||||
evaluate_id: element.id,
|
||||
},
|
||||
order: { output_id: "ASC" },
|
||||
});
|
||||
|
||||
const achievements = await achievementData.map((achievement) => {
|
||||
return {
|
||||
|
|
@ -1032,7 +921,7 @@ export class EvaluateRecordController extends Controller {
|
|||
updatedAt: element.updatedAt,
|
||||
achievements: achievements,
|
||||
};
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -1043,10 +932,7 @@ export class EvaluateRecordController extends Controller {
|
|||
});
|
||||
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const experimenteeData = await this.personalRepository.find({
|
||||
|
|
@ -1069,14 +955,7 @@ export class EvaluateRecordController extends Controller {
|
|||
}));
|
||||
|
||||
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 },
|
||||
});
|
||||
|
||||
|
|
@ -1095,7 +974,7 @@ export class EvaluateRecordController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1109,7 +988,7 @@ export class EvaluateRecordController extends Controller {
|
|||
async PostDataCommander(
|
||||
@Query() assign_id: string,
|
||||
@Body() requestBody: CreateEvaluateAssessor,
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
|
|
@ -1132,10 +1011,7 @@ export class EvaluateRecordController extends Controller {
|
|||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const postData: any = await {
|
||||
|
|
@ -1154,9 +1030,7 @@ export class EvaluateRecordController extends Controller {
|
|||
: 0,
|
||||
behavior_other_desc: requestBody.behavio_orther.text,
|
||||
behavior_other_level:
|
||||
requestBody.behavio_orther.text != ""
|
||||
? Number(requestBody.behavio_orther.level)
|
||||
: 0,
|
||||
requestBody.behavio_orther.text != "" ? Number(requestBody.behavio_orther.level) : 0,
|
||||
behavior_strength_desc: requestBody.behavior_strength_desc,
|
||||
behavior_improve_desc: requestBody.behavior_improve_desc,
|
||||
orientation: requestBody.orientation,
|
||||
|
|
@ -1169,12 +1043,9 @@ export class EvaluateRecordController extends Controller {
|
|||
updateFullName: request.user.name,
|
||||
};
|
||||
|
||||
const evaluateAssessor = await this.evaluateAssessorRepository.save(
|
||||
postData,
|
||||
{
|
||||
data: request,
|
||||
}
|
||||
);
|
||||
const evaluateAssessor = await this.evaluateAssessorRepository.save(postData, {
|
||||
data: request,
|
||||
});
|
||||
if (evaluateAssessor) {
|
||||
await Promise.all(
|
||||
requestBody.evaluate_expenct_level.map(async (expenct, index) => {
|
||||
|
|
@ -1185,9 +1056,7 @@ export class EvaluateRecordController extends Controller {
|
|||
assessor_id: director_id,
|
||||
evaluate_expect_level: Number(expenct.level),
|
||||
output_desc: requestBody.evaluate_ouptut[index].text,
|
||||
evaluate_output_level: Number(
|
||||
requestBody.evaluate_ouptut[index].level
|
||||
),
|
||||
evaluate_output_level: Number(requestBody.evaluate_ouptut[index].level),
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
|
|
@ -1196,7 +1065,7 @@ export class EvaluateRecordController extends Controller {
|
|||
await this.evaluateAchievementRepository.save(evaluateAchievement, {
|
||||
data: request,
|
||||
});
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -1226,7 +1095,7 @@ export class EvaluateRecordController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1240,7 +1109,7 @@ export class EvaluateRecordController extends Controller {
|
|||
@Query() assign_id: string,
|
||||
@Query() evaluate_id: string,
|
||||
@Body() requestBody: CreateEvaluateAssessor,
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
|
|
@ -1277,12 +1146,9 @@ export class EvaluateRecordController 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.achievement_strength_desc =
|
||||
requestBody.achievement_strength_desc;
|
||||
evaluate.achievement_strength_desc = requestBody.achievement_strength_desc;
|
||||
evaluate.achievement_improve_desc = requestBody.achievement_improve_desc;
|
||||
evaluate.conduct1_level = requestBody.conduct1_level;
|
||||
evaluate.conduct2_level = requestBody.conduct2_level;
|
||||
|
|
@ -1298,9 +1164,7 @@ export class EvaluateRecordController extends Controller {
|
|||
evaluate.discipline5_level = requestBody.discipline5_level;
|
||||
evaluate.behavior_other_desc = requestBody.behavio_orther.text;
|
||||
evaluate.behavior_other_level =
|
||||
requestBody.behavio_orther.text != ""
|
||||
? Number(requestBody.behavio_orther.level)
|
||||
: 0;
|
||||
requestBody.behavio_orther.text != "" ? Number(requestBody.behavio_orther.level) : 0;
|
||||
evaluate.behavior_strength_desc = requestBody.behavior_strength_desc;
|
||||
evaluate.behavior_improve_desc = requestBody.behavior_improve_desc;
|
||||
evaluate.orientation = requestBody.orientation;
|
||||
|
|
@ -1310,12 +1174,9 @@ export class EvaluateRecordController extends Controller {
|
|||
evaluate.updateUserId = request.user.sub;
|
||||
evaluate.updateFullName = request.user.name;
|
||||
|
||||
const evaluateAssessor = await this.evaluateAssessorRepository.save(
|
||||
evaluate,
|
||||
{
|
||||
data: request,
|
||||
}
|
||||
);
|
||||
const evaluateAssessor = await this.evaluateAssessorRepository.save(evaluate, {
|
||||
data: request,
|
||||
});
|
||||
|
||||
if (evaluateAssessor) {
|
||||
await this.evaluateAchievementRepository.delete({
|
||||
|
|
@ -1330,9 +1191,7 @@ export class EvaluateRecordController extends Controller {
|
|||
assessor_id: director_id,
|
||||
evaluate_expect_level: Number(expenct.level),
|
||||
output_desc: requestBody.evaluate_ouptut[index].text,
|
||||
evaluate_output_level: Number(
|
||||
requestBody.evaluate_ouptut[index].level
|
||||
),
|
||||
evaluate_output_level: Number(requestBody.evaluate_ouptut[index].level),
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
|
|
@ -1341,7 +1200,7 @@ export class EvaluateRecordController extends Controller {
|
|||
await this.evaluateAchievementRepository.save(evaluateAchievement, {
|
||||
data: request,
|
||||
});
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -1351,7 +1210,7 @@ export class EvaluateRecordController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,10 +24,7 @@ import { Assign } from "../entities/Assign";
|
|||
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";
|
||||
import permission from "../interfaces/permission";
|
||||
|
||||
@Route("api/v1/probation/evaluate-result")
|
||||
|
|
@ -35,17 +32,14 @@ import permission from "../interfaces/permission";
|
|||
@Security("bearerAuth")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง"
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||
)
|
||||
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 ข้อมูลตอนกดสร้างแบบรายงานการประเมินฯ
|
||||
|
|
@ -54,28 +48,17 @@ export class EvaluateResultController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("create")
|
||||
async CreateEvaluate(
|
||||
@Query() assign_id: string,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||
try {
|
||||
let _workflow = await new permission().Workflow(
|
||||
request,
|
||||
assign_id,
|
||||
"SYS_PROBATION"
|
||||
);
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
let _workflow = await new permission().Workflow(request, assign_id, "SYS_PROBATION");
|
||||
if (_workflow == false) await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
|
||||
const assign = await this.assignRepository.findOne({
|
||||
relations: ["profile"],
|
||||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const profile = await (assign.profile
|
||||
|
|
@ -83,10 +66,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);
|
||||
|
|
@ -97,10 +77,7 @@ export class EvaluateResultController extends Controller {
|
|||
});
|
||||
|
||||
if (!directorData) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
|
||||
}
|
||||
|
||||
let mentors = [];
|
||||
|
|
@ -113,10 +90,7 @@ export class EvaluateResultController extends Controller {
|
|||
personal_id: e.personal_id,
|
||||
dated: e.dated,
|
||||
name: e.fullname,
|
||||
label:
|
||||
e.fullname +
|
||||
" " +
|
||||
(e.position ? `(${e.position}${e.posLevel})` : ""),
|
||||
label: e.fullname + " " + (e.position ? `(${e.position}${e.posLevel})` : ""),
|
||||
position: e.position,
|
||||
posType: e.posType,
|
||||
posLevel: e.posLevel,
|
||||
|
|
@ -124,9 +98,7 @@ 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 != null
|
||||
|
|
@ -146,9 +118,7 @@ export class EvaluateResultController extends Controller {
|
|||
}
|
||||
: null;
|
||||
|
||||
const chairmanData = await (directorData.find(
|
||||
(x) => x.role == "chairman"
|
||||
) ?? null);
|
||||
const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null);
|
||||
const chairman =
|
||||
chairmanData != null
|
||||
? {
|
||||
|
|
@ -158,9 +128,7 @@ export class EvaluateResultController extends Controller {
|
|||
label:
|
||||
chairmanData.fullname +
|
||||
" " +
|
||||
(chairmanData.position
|
||||
? `(${chairmanData.position}${chairmanData.posLevel})`
|
||||
: ""),
|
||||
(chairmanData.position ? `(${chairmanData.position}${chairmanData.posLevel})` : ""),
|
||||
position: chairmanData.position,
|
||||
posType: chairmanData.posType,
|
||||
posLevel: chairmanData.posLevel,
|
||||
|
|
@ -181,10 +149,7 @@ export class EvaluateResultController extends Controller {
|
|||
});
|
||||
|
||||
if (!resultData) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลการประเมินผล"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมินผล");
|
||||
}
|
||||
|
||||
const result = await Promise.all(
|
||||
|
|
@ -224,7 +189,7 @@ export class EvaluateResultController extends Controller {
|
|||
start_date: startDate,
|
||||
end_date: endDate,
|
||||
};
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
// const develop_complete = await (resultData.develop_orientation_score > 0 &&
|
||||
|
|
@ -251,7 +216,7 @@ export class EvaluateResultController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -265,7 +230,7 @@ export class EvaluateResultController extends Controller {
|
|||
async GetEvaluate(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query() assign_id: string,
|
||||
@Query() evaluate_no?: string
|
||||
@Query() evaluate_no?: string,
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
|
|
@ -299,10 +264,7 @@ export class EvaluateResultController extends Controller {
|
|||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const experimenteeData = await this.personalRepository.findOne({
|
||||
|
|
@ -332,11 +294,9 @@ export class EvaluateResultController extends Controller {
|
|||
experimenteeData.firstName +
|
||||
" " +
|
||||
experimenteeData.lastName,
|
||||
PositionLevel:
|
||||
experimenteeData.positionName + experimenteeData.positionLevelName,
|
||||
PositionLevel: experimenteeData.positionName + experimenteeData.positionLevelName,
|
||||
Department: splitOcAmount > 2 ? splitOc[splitOcAmount - 3] : "-",
|
||||
OrganizationOrganization:
|
||||
splitOcAmount > 1 ? splitOc[splitOcAmount - 2] : "-",
|
||||
OrganizationOrganization: splitOcAmount > 1 ? splitOc[splitOcAmount - 2] : "-",
|
||||
Oc: experimenteeData.orgRootName,
|
||||
};
|
||||
|
||||
|
|
@ -346,10 +306,7 @@ export class EvaluateResultController extends Controller {
|
|||
});
|
||||
|
||||
if (!directorData) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
|
||||
}
|
||||
|
||||
let mentors = [];
|
||||
|
|
@ -362,10 +319,7 @@ export class EvaluateResultController extends Controller {
|
|||
personal_id: e.personal_id,
|
||||
dated: e.dated,
|
||||
name: e.fullname,
|
||||
label:
|
||||
e.fullname +
|
||||
" " +
|
||||
(e.position ? `(${e.position}${e.posLevel})` : ""),
|
||||
label: e.fullname + " " + (e.position ? `(${e.position}${e.posLevel})` : ""),
|
||||
position: e.position + e.posLevel,
|
||||
posType: e.posType,
|
||||
posLevel: e.posLevel,
|
||||
|
|
@ -401,9 +355,7 @@ export class EvaluateResultController extends Controller {
|
|||
posType: evaluate.authority_type,
|
||||
posLevel: evaluate.authority_level,
|
||||
};
|
||||
const chairmanData = await (directorData.find(
|
||||
(x) => x.role == "chairman"
|
||||
) ?? null);
|
||||
const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null);
|
||||
const chairman =
|
||||
chairmanData != null
|
||||
? {
|
||||
|
|
@ -413,9 +365,7 @@ export class EvaluateResultController extends Controller {
|
|||
label:
|
||||
chairmanData.fullname +
|
||||
" " +
|
||||
(chairmanData.position
|
||||
? `(${chairmanData.position}${chairmanData.posLevel})`
|
||||
: ""),
|
||||
(chairmanData.position ? `(${chairmanData.position}${chairmanData.posLevel})` : ""),
|
||||
position: chairmanData.position + chairmanData.posLevel,
|
||||
posType: chairmanData.posType,
|
||||
posLevel: chairmanData.posLevel,
|
||||
|
|
@ -433,7 +383,7 @@ export class EvaluateResultController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -447,7 +397,7 @@ export class EvaluateResultController extends Controller {
|
|||
async PostData(
|
||||
@Query() assign_id: string,
|
||||
@Body() requestBody: CreateEvaluateResult,
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
|
|
@ -470,10 +420,7 @@ export class EvaluateResultController extends Controller {
|
|||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const postData: any = await {
|
||||
|
|
@ -483,8 +430,7 @@ export class EvaluateResultController extends Controller {
|
|||
no: requestBody.evaluate_no,
|
||||
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,
|
||||
|
|
@ -501,7 +447,7 @@ export class EvaluateResultController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -515,7 +461,7 @@ export class EvaluateResultController extends Controller {
|
|||
async PatchData(
|
||||
@Query() assign_id: string,
|
||||
@Query() evaluate_no: number | string,
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
|
|
@ -525,10 +471,7 @@ export class EvaluateResultController extends Controller {
|
|||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const result = await this.evaluateResultRepository.findOne({
|
||||
|
|
@ -536,10 +479,7 @@ export class EvaluateResultController extends Controller {
|
|||
});
|
||||
|
||||
if (!result) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลผลการประเมิน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผลการประเมิน");
|
||||
}
|
||||
|
||||
const personal = await this.personalRepository.findOne({
|
||||
|
|
@ -581,7 +521,7 @@ export class EvaluateResultController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -596,7 +536,7 @@ export class EvaluateResultController extends Controller {
|
|||
@Query() assign_id: string,
|
||||
@Query() evaluate_id: string,
|
||||
@Body() requestBody: CreateEvaluateResult,
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
|
|
@ -635,10 +575,7 @@ export class EvaluateResultController extends Controller {
|
|||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
const personal = await this.personalRepository.findOne({
|
||||
where: { personal_id: assign.personal_id },
|
||||
|
|
@ -680,7 +617,7 @@ export class EvaluateResultController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ export class PersonalController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -244,7 +244,7 @@ export class PersonalController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -287,7 +287,7 @@ export class PersonalController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -70,7 +70,7 @@ export class SurveyController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ export class SurveyController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -183,7 +183,7 @@ export class SurveyController extends Controller {
|
|||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||
}
|
||||
// await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue