check workflow
This commit is contained in:
parent
358a17e40d
commit
168cfcee46
9 changed files with 1667 additions and 1836 deletions
|
|
@ -80,7 +80,8 @@ export class AppointController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async GetById(@Request() request: RequestWithUser, @Path() id: string) {
|
async GetById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
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({
|
const appoint = await this.appointRepository.findOne({
|
||||||
select: ["id", "topic", "status", "profileId"],
|
select: ["id", "topic", "status", "profileId"],
|
||||||
|
|
|
||||||
|
|
@ -1,59 +1,40 @@
|
||||||
import {
|
import { Controller, Post, Put, Route, Security, Tags, Body, Request, SuccessResponse, Response, Get, Query } from "tsoa"
|
||||||
Controller,
|
import { AppDataSource } from "../database/data-source"
|
||||||
Post,
|
import HttpSuccess from "../interfaces/http-success"
|
||||||
Put,
|
import HttpStatusCode from "../interfaces/http-status"
|
||||||
Route,
|
import HttpError from "../interfaces/http-error"
|
||||||
Security,
|
import { RequestWithUser } from "../middlewares/user"
|
||||||
Tags,
|
import { findEndDate, setLogDataDiff } from "../interfaces/utils"
|
||||||
Body,
|
import { Personal } from "../entities/Personal"
|
||||||
Request,
|
import permission from "../interfaces/permission"
|
||||||
SuccessResponse,
|
import { Assign, CreateAssign } from "../entities/Assign"
|
||||||
Response,
|
import { AssignDirector, CreateAssignDirector } from "../entities/AssignDirector"
|
||||||
Get,
|
import { AssignJob, CreateAssignJob } from "../entities/AssignJob"
|
||||||
Query,
|
import { AssignKnowledge, CreateAssignKnowledge } from "../entities/AssignKnowledge"
|
||||||
} from "tsoa";
|
import { AssignLaw, CreateAssignLaw } from "../entities/AssignLaw"
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AssignSkill, CreateAssignSkill } from "../entities/AssignSkill"
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import { AssignCompetency, CreateAssignCompetency } from "../entities/AssignCompetency"
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import { AssignCompetencyGroup, CreateAssignCompetencyGroup } from "../entities/AssignCompetencyGroup"
|
||||||
import HttpError from "../interfaces/http-error";
|
import { AssignOutput, CreateAssignOutput } from "../entities/AssignOutput"
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { Law } from "../entities/Law"
|
||||||
import { findEndDate, setLogDataDiff } from "../interfaces/utils";
|
import CallAPI from "../interfaces/call-api"
|
||||||
import { Personal } from "../entities/Personal";
|
|
||||||
import permission from "../interfaces/permission";
|
|
||||||
import { Assign, CreateAssign } from "../entities/Assign";
|
|
||||||
import { AssignDirector, CreateAssignDirector } from "../entities/AssignDirector";
|
|
||||||
import { AssignJob, CreateAssignJob } from "../entities/AssignJob";
|
|
||||||
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 {
|
|
||||||
AssignCompetencyGroup,
|
|
||||||
CreateAssignCompetencyGroup,
|
|
||||||
} from "../entities/AssignCompetencyGroup";
|
|
||||||
import { AssignOutput, CreateAssignOutput } from "../entities/AssignOutput";
|
|
||||||
import { Law } from "../entities/Law";
|
|
||||||
import CallAPI from "../interfaces/call-api";
|
|
||||||
|
|
||||||
@Route("api/v1/probation/assign")
|
@Route("api/v1/probation/assign")
|
||||||
@Tags("ฟอร์มมอบหมายงาน")
|
@Tags("ฟอร์มมอบหมายงาน")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
@Response(
|
@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง")
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
|
||||||
)
|
|
||||||
export class AssignController extends Controller {
|
export class AssignController extends Controller {
|
||||||
private assignRepository = AppDataSource.getRepository(Assign);
|
private assignRepository = AppDataSource.getRepository(Assign)
|
||||||
private personalRepository = AppDataSource.getRepository(Personal);
|
private personalRepository = AppDataSource.getRepository(Personal)
|
||||||
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector);
|
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector)
|
||||||
private assignJobRepository = AppDataSource.getRepository(AssignJob);
|
private assignJobRepository = AppDataSource.getRepository(AssignJob)
|
||||||
private assignKnowledgeRepository = AppDataSource.getRepository(AssignKnowledge);
|
private assignKnowledgeRepository = AppDataSource.getRepository(AssignKnowledge)
|
||||||
private assignLawRepository = AppDataSource.getRepository(AssignLaw);
|
private assignLawRepository = AppDataSource.getRepository(AssignLaw)
|
||||||
private assignSkillRepository = AppDataSource.getRepository(AssignSkill);
|
private assignSkillRepository = AppDataSource.getRepository(AssignSkill)
|
||||||
private assignCompetencyRepository = AppDataSource.getRepository(AssignCompetency);
|
private assignCompetencyRepository = AppDataSource.getRepository(AssignCompetency)
|
||||||
private assignCompetencyGroupRepository = AppDataSource.getRepository(AssignCompetencyGroup);
|
private assignCompetencyGroupRepository = AppDataSource.getRepository(AssignCompetencyGroup)
|
||||||
private assignOutputRepository = AppDataSource.getRepository(AssignOutput);
|
private assignOutputRepository = AppDataSource.getRepository(AssignOutput)
|
||||||
private lawsRepository = AppDataSource.getRepository(Law);
|
private lawsRepository = AppDataSource.getRepository(Law)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API เพิ่มข้อมูลการมอบหมายงาน
|
* API เพิ่มข้อมูลการมอบหมายงาน
|
||||||
|
|
@ -63,15 +44,15 @@ export class AssignController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("")
|
@Post("")
|
||||||
async AddAssign(@Request() request: RequestWithUser, @Body() requestBody: CreateAssign) {
|
async AddAssign(@Request() request: RequestWithUser, @Body() requestBody: CreateAssign) {
|
||||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
await new permission().PermissionUpdate(request, "SYS_PROBATION")
|
||||||
const person = await this.personalRepository.findOne({
|
const person = await this.personalRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
personal_id: requestBody.personalId,
|
personal_id: requestBody.personalId,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!person) {
|
if (!person) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const roundNo = await this.assignRepository.count({
|
const roundNo = await this.assignRepository.count({
|
||||||
|
|
@ -79,7 +60,7 @@ export class AssignController extends Controller {
|
||||||
active: 1,
|
active: 1,
|
||||||
personal_id: requestBody.personalId,
|
personal_id: requestBody.personalId,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
const data: any = {
|
const data: any = {
|
||||||
...requestBody,
|
...requestBody,
|
||||||
|
|
@ -89,10 +70,10 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
};
|
}
|
||||||
const before = null;
|
const before = null
|
||||||
const assign = await this.assignRepository.save(data, { data: request });
|
const assign = await this.assignRepository.save(data, { data: request })
|
||||||
setLogDataDiff(request, { before, after: data });
|
setLogDataDiff(request, { before, after: data })
|
||||||
|
|
||||||
const jobs = await requestBody.assign_jobs.map((x: CreateAssignJob, index: number) => ({
|
const jobs = await requestBody.assign_jobs.map((x: CreateAssignJob, index: number) => ({
|
||||||
...x,
|
...x,
|
||||||
|
|
@ -102,12 +83,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}));
|
}))
|
||||||
await this.assignJobRepository.save(jobs, { data: request });
|
await this.assignJobRepository.save(jobs, { data: request })
|
||||||
setLogDataDiff(request, { before, after: jobs });
|
setLogDataDiff(request, { before, after: jobs })
|
||||||
|
|
||||||
const knowledges = await requestBody.assign_knowledges.map(
|
const knowledges = await requestBody.assign_knowledges.map((x: CreateAssignKnowledge, index: number) => ({
|
||||||
(x: CreateAssignKnowledge, index: number) => ({
|
|
||||||
knowledge_level: x.level,
|
knowledge_level: x.level,
|
||||||
knowledge_id: x.id,
|
knowledge_id: x.id,
|
||||||
assign_id: assign.id,
|
assign_id: assign.id,
|
||||||
|
|
@ -115,10 +95,9 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
await this.assignKnowledgeRepository.save(knowledges, { data: request })
|
||||||
await this.assignKnowledgeRepository.save(knowledges, { data: request });
|
setLogDataDiff(request, { before, after: knowledges })
|
||||||
setLogDataDiff(request, { before, after: knowledges });
|
|
||||||
|
|
||||||
const laws = await requestBody.assign_law.map((x: CreateAssignLaw, index: number) => ({
|
const laws = await requestBody.assign_law.map((x: CreateAssignLaw, index: number) => ({
|
||||||
ordering: index + 1,
|
ordering: index + 1,
|
||||||
|
|
@ -128,9 +107,9 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}));
|
}))
|
||||||
await this.assignLawRepository.save(laws, { data: request });
|
await this.assignLawRepository.save(laws, { data: request })
|
||||||
setLogDataDiff(request, { before, after: laws });
|
setLogDataDiff(request, { before, after: laws })
|
||||||
|
|
||||||
const skills = await requestBody.assign_skill.map((x: CreateAssignSkill, index: number) => ({
|
const skills = await requestBody.assign_skill.map((x: CreateAssignSkill, index: number) => ({
|
||||||
skill_id: index + 1,
|
skill_id: index + 1,
|
||||||
|
|
@ -140,12 +119,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}));
|
}))
|
||||||
await this.assignSkillRepository.save(skills, { data: request });
|
await this.assignSkillRepository.save(skills, { data: request })
|
||||||
setLogDataDiff(request, { before, after: skills });
|
setLogDataDiff(request, { before, after: skills })
|
||||||
|
|
||||||
const competencise = await requestBody.assign_competency.map(
|
const competencise = await requestBody.assign_competency.map((x: CreateAssignCompetency, index: number) => ({
|
||||||
(x: CreateAssignCompetency, index: number) => ({
|
|
||||||
competency_id: x.id,
|
competency_id: x.id,
|
||||||
competency_level: x.level,
|
competency_level: x.level,
|
||||||
competency_name: x.name,
|
competency_name: x.name,
|
||||||
|
|
@ -155,13 +133,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
await this.assignCompetencyRepository.save(competencise, { data: request })
|
||||||
await this.assignCompetencyRepository.save(competencise, { data: request });
|
setLogDataDiff(request, { before, after: competencise })
|
||||||
setLogDataDiff(request, { before, after: competencise });
|
|
||||||
|
|
||||||
const competencyGroups = await requestBody.assign_competency_group.map(
|
const competencyGroups = await requestBody.assign_competency_group.map((x: CreateAssignCompetencyGroup, index: number) => ({
|
||||||
(x: CreateAssignCompetencyGroup, index: number) => ({
|
|
||||||
competency_group_id: x.id,
|
competency_group_id: x.id,
|
||||||
competency_group_level: x.level,
|
competency_group_level: x.level,
|
||||||
competency_group_name: x.name,
|
competency_group_name: x.name,
|
||||||
|
|
@ -171,15 +147,13 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
|
||||||
await this.assignCompetencyGroupRepository.save(competencyGroups, {
|
await this.assignCompetencyGroupRepository.save(competencyGroups, {
|
||||||
data: request,
|
data: request,
|
||||||
});
|
})
|
||||||
setLogDataDiff(request, { before, after: competencyGroups });
|
setLogDataDiff(request, { before, after: competencyGroups })
|
||||||
|
|
||||||
const outputs = await requestBody.assign_outputs.map(
|
const outputs = await requestBody.assign_outputs.map((x: CreateAssignOutput, index: number) => ({
|
||||||
(x: CreateAssignOutput, index: number) => ({
|
|
||||||
...x,
|
...x,
|
||||||
id: index + 1,
|
id: index + 1,
|
||||||
assign_id: assign.id,
|
assign_id: assign.id,
|
||||||
|
|
@ -187,13 +161,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
await this.assignOutputRepository.save(outputs, { data: request })
|
||||||
await this.assignOutputRepository.save(outputs, { data: request });
|
setLogDataDiff(request, { before, after: outputs })
|
||||||
setLogDataDiff(request, { before, after: outputs });
|
|
||||||
|
|
||||||
const directors = await requestBody.assign_director.map(
|
const directors = await requestBody.assign_director.map((x: CreateAssignDirector, index: number) => ({
|
||||||
(x: CreateAssignDirector, index: number) => ({
|
|
||||||
...x,
|
...x,
|
||||||
assign_id: assign.id,
|
assign_id: assign.id,
|
||||||
fullname: x.name,
|
fullname: x.name,
|
||||||
|
|
@ -202,12 +174,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
await this.assignDirectorRepository.save(directors, { data: request })
|
||||||
await this.assignDirectorRepository.save(directors, { data: request });
|
setLogDataDiff(request, { before, after: directors })
|
||||||
setLogDataDiff(request, { before, after: directors });
|
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -217,30 +188,26 @@ export class AssignController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Put("")
|
@Put("")
|
||||||
async EditAssign(
|
async EditAssign(@Query() assign_id: string, @Request() request: RequestWithUser, @Body() requestBody: CreateAssign) {
|
||||||
@Query() assign_id: string,
|
await new permission().PermissionUpdate(request, "SYS_PROBATION")
|
||||||
@Request() request: RequestWithUser,
|
|
||||||
@Body() requestBody: CreateAssign,
|
|
||||||
) {
|
|
||||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
|
||||||
|
|
||||||
const assign = await this.assignRepository.findOne({
|
const assign = await this.assignRepository.findOne({
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
})
|
||||||
let before = assign;
|
let before = assign
|
||||||
|
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน")
|
||||||
}
|
}
|
||||||
|
|
||||||
const person = await this.personalRepository.findOne({
|
const person = await this.personalRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
personal_id: requestBody.personalId,
|
personal_id: requestBody.personalId,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!person) {
|
if (!person) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const data: any = {
|
const data: any = {
|
||||||
|
|
@ -248,9 +215,9 @@ export class AssignController extends Controller {
|
||||||
id: assign_id,
|
id: assign_id,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
};
|
}
|
||||||
|
|
||||||
await this.assignJobRepository.delete({ assign_id });
|
await this.assignJobRepository.delete({ assign_id })
|
||||||
const jobs = await requestBody.assign_jobs.map((x: CreateAssignJob, index: number) => ({
|
const jobs = await requestBody.assign_jobs.map((x: CreateAssignJob, index: number) => ({
|
||||||
...x,
|
...x,
|
||||||
id: index + 1,
|
id: index + 1,
|
||||||
|
|
@ -259,12 +226,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}));
|
}))
|
||||||
await this.assignJobRepository.save(jobs);
|
await this.assignJobRepository.save(jobs)
|
||||||
|
|
||||||
await this.assignKnowledgeRepository.delete({ assign_id });
|
await this.assignKnowledgeRepository.delete({ assign_id })
|
||||||
const knowledges = await requestBody.assign_knowledges.map(
|
const knowledges = await requestBody.assign_knowledges.map((x: CreateAssignKnowledge, index: number) => ({
|
||||||
(x: CreateAssignKnowledge, index: number) => ({
|
|
||||||
knowledge_level: x.level,
|
knowledge_level: x.level,
|
||||||
knowledge_id: x.id,
|
knowledge_id: x.id,
|
||||||
assign_id: assign.id,
|
assign_id: assign.id,
|
||||||
|
|
@ -272,11 +238,10 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
await this.assignKnowledgeRepository.save(knowledges)
|
||||||
await this.assignKnowledgeRepository.save(knowledges);
|
|
||||||
|
|
||||||
await this.assignLawRepository.delete({ assign_id });
|
await this.assignLawRepository.delete({ assign_id })
|
||||||
const laws = await requestBody.assign_law.map((x: CreateAssignLaw, index: number) => ({
|
const laws = await requestBody.assign_law.map((x: CreateAssignLaw, index: number) => ({
|
||||||
ordering: index + 1,
|
ordering: index + 1,
|
||||||
law_id: x.id,
|
law_id: x.id,
|
||||||
|
|
@ -285,10 +250,10 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}));
|
}))
|
||||||
await this.assignLawRepository.save(laws);
|
await this.assignLawRepository.save(laws)
|
||||||
|
|
||||||
await this.assignSkillRepository.delete({ assign_id });
|
await this.assignSkillRepository.delete({ assign_id })
|
||||||
const skills = await requestBody.assign_skill.map((x: CreateAssignSkill, index: number) => ({
|
const skills = await requestBody.assign_skill.map((x: CreateAssignSkill, index: number) => ({
|
||||||
skill_id: index + 1,
|
skill_id: index + 1,
|
||||||
skill_level: x.level,
|
skill_level: x.level,
|
||||||
|
|
@ -297,12 +262,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}));
|
}))
|
||||||
await this.assignSkillRepository.save(skills);
|
await this.assignSkillRepository.save(skills)
|
||||||
|
|
||||||
await this.assignCompetencyRepository.delete({ assign_id });
|
await this.assignCompetencyRepository.delete({ assign_id })
|
||||||
const competencise = await requestBody.assign_competency.map(
|
const competencise = await requestBody.assign_competency.map((x: CreateAssignCompetency, index: number) => ({
|
||||||
(x: CreateAssignCompetency, index: number) => ({
|
|
||||||
competency_id: x.id,
|
competency_id: x.id,
|
||||||
competency_level: x.level,
|
competency_level: x.level,
|
||||||
competency_name: x.name,
|
competency_name: x.name,
|
||||||
|
|
@ -312,13 +276,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
await this.assignCompetencyRepository.save(competencise)
|
||||||
await this.assignCompetencyRepository.save(competencise);
|
|
||||||
|
|
||||||
await this.assignCompetencyGroupRepository.delete({ assign_id });
|
await this.assignCompetencyGroupRepository.delete({ assign_id })
|
||||||
const competencyGroups = await requestBody.assign_competency_group.map(
|
const competencyGroups = await requestBody.assign_competency_group.map((x: CreateAssignCompetencyGroup, index: number) => ({
|
||||||
(x: CreateAssignCompetencyGroup, index: number) => ({
|
|
||||||
competency_group_id: x.id,
|
competency_group_id: x.id,
|
||||||
competency_group_level: x.level,
|
competency_group_level: x.level,
|
||||||
competency_group_name: x.name,
|
competency_group_name: x.name,
|
||||||
|
|
@ -328,13 +290,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
await this.assignCompetencyGroupRepository.save(competencyGroups)
|
||||||
await this.assignCompetencyGroupRepository.save(competencyGroups);
|
|
||||||
|
|
||||||
await this.assignOutputRepository.delete({ assign_id });
|
await this.assignOutputRepository.delete({ assign_id })
|
||||||
const outputs = await requestBody.assign_outputs.map(
|
const outputs = await requestBody.assign_outputs.map((x: CreateAssignOutput, index: number) => ({
|
||||||
(x: CreateAssignOutput, index: number) => ({
|
|
||||||
...x,
|
...x,
|
||||||
id: index + 1,
|
id: index + 1,
|
||||||
assign_id: assign.id,
|
assign_id: assign.id,
|
||||||
|
|
@ -342,13 +302,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
await this.assignOutputRepository.save(outputs)
|
||||||
await this.assignOutputRepository.save(outputs);
|
|
||||||
|
|
||||||
await this.assignDirectorRepository.delete({ assign_id });
|
await this.assignDirectorRepository.delete({ assign_id })
|
||||||
const directors = await requestBody.assign_director.map(
|
const directors = await requestBody.assign_director.map((x: CreateAssignDirector, index: number) => ({
|
||||||
(x: CreateAssignDirector, index: number) => ({
|
|
||||||
...x,
|
...x,
|
||||||
assign_id: assign.id,
|
assign_id: assign.id,
|
||||||
fullname: x.name,
|
fullname: x.name,
|
||||||
|
|
@ -357,19 +315,18 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
await this.assignDirectorRepository.save(directors)
|
||||||
await this.assignDirectorRepository.save(directors);
|
|
||||||
|
|
||||||
await this.assignRepository.save(data, { data: request });
|
await this.assignRepository.save(data, { data: request })
|
||||||
setLogDataDiff(request, { before, after: data });
|
setLogDataDiff(request, { before, after: data })
|
||||||
|
|
||||||
// #noted cronjob
|
// #noted cronjob
|
||||||
// แจ้งผู้ดูแลและผู้บังคับบัญชาเข้ามาบันทึกผลทุก 2 เดือน
|
// แจ้งผู้ดูแลและผู้บังคับบัญชาเข้ามาบันทึกผลทุก 2 เดือน
|
||||||
const dateSaveForm = await findEndDate(2, requestBody.date_start);
|
const dateSaveForm = await findEndDate(2, requestBody.date_start)
|
||||||
requestBody.assign_director
|
requestBody.assign_director
|
||||||
.filter((x) => x.role == "mentor" || x.role == "commander")
|
.filter(x => x.role == "mentor" || x.role == "commander")
|
||||||
.map(async (director) => {
|
.map(async director => {
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.PostData(request, "/placement/noti", {
|
.PostData(request, "/placement/noti", {
|
||||||
subject: `ถึงกำหนดบันทึกผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ 1 ${requestBody.fullname}`,
|
subject: `ถึงกำหนดบันทึกผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ 1 ${requestBody.fullname}`,
|
||||||
|
|
@ -380,16 +337,16 @@ export class AssignController extends Controller {
|
||||||
isSendInbox: true,
|
isSendInbox: true,
|
||||||
receiveDate: dateSaveForm,
|
receiveDate: dateSaveForm,
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
console.error("Error calling API:", error);
|
console.error("Error calling API:", error)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
// แจ้งผู้บังคับบัญชา และคณะกรรมการเข้ามาประเมินทุก 3 เดือน
|
// แจ้งผู้บังคับบัญชา และคณะกรรมการเข้ามาประเมินทุก 3 เดือน
|
||||||
const dateEvaluate = await findEndDate(3, requestBody.date_start);
|
const dateEvaluate = await findEndDate(3, requestBody.date_start)
|
||||||
requestBody.assign_director
|
requestBody.assign_director
|
||||||
.filter((x) => x.role == "commander" || x.role == "chairman")
|
.filter(x => x.role == "commander" || x.role == "chairman")
|
||||||
.map(async (director) => {
|
.map(async director => {
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.PostData(request, "/placement/noti", {
|
.PostData(request, "/placement/noti", {
|
||||||
subject: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ 1 ${requestBody.fullname}`,
|
subject: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ 1 ${requestBody.fullname}`,
|
||||||
|
|
@ -400,16 +357,16 @@ export class AssignController extends Controller {
|
||||||
isSendInbox: true,
|
isSendInbox: true,
|
||||||
receiveDate: dateEvaluate,
|
receiveDate: dateEvaluate,
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
console.error("Error calling API:", error);
|
console.error("Error calling API:", error)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
// แจ้งประธาน 6 เดือน
|
// แจ้งประธาน 6 เดือน
|
||||||
const dateResult = await findEndDate(6, requestBody.date_start);
|
const dateResult = await findEndDate(6, requestBody.date_start)
|
||||||
requestBody.assign_director
|
requestBody.assign_director
|
||||||
.filter((x) => x.role == "chairman")
|
.filter(x => x.role == "chairman")
|
||||||
.map(async (director) => {
|
.map(async director => {
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.PostData(request, "/placement/noti", {
|
.PostData(request, "/placement/noti", {
|
||||||
subject: `ถึงกำหนดรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ ${requestBody.fullname}`,
|
subject: `ถึงกำหนดรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ ${requestBody.fullname}`,
|
||||||
|
|
@ -421,12 +378,12 @@ export class AssignController extends Controller {
|
||||||
// isSendNotification: true
|
// isSendNotification: true
|
||||||
receiveDate: dateResult,
|
receiveDate: dateResult,
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
console.error("Error calling API:", error);
|
console.error("Error calling API:", error)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -437,50 +394,51 @@ export class AssignController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("assign-list")
|
@Get("assign-list")
|
||||||
async ListPersonal(@Request() request: RequestWithUser, @Query() personal_id: string) {
|
async ListPersonal(@Request() request: RequestWithUser, @Query() personal_id: string) {
|
||||||
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({
|
const lists = await this.assignRepository.find({
|
||||||
select: ["id", "round_no", "date_start", "date_finish"],
|
select: ["id", "round_no", "date_start", "date_finish"],
|
||||||
where: { personal_id },
|
where: { personal_id },
|
||||||
order: { round_no: "ASC" },
|
order: { round_no: "ASC" },
|
||||||
});
|
})
|
||||||
|
|
||||||
let result: any = [];
|
let result: any = []
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
lists.map(async (item) => {
|
lists.map(async item => {
|
||||||
const director = await this.assignDirectorRepository.find({
|
const director = await this.assignDirectorRepository.find({
|
||||||
where: { assign_id: item.id },
|
where: { assign_id: item.id },
|
||||||
order: { ordering: "ASC" },
|
order: { ordering: "ASC" },
|
||||||
});
|
})
|
||||||
|
|
||||||
let mentors = "";
|
let mentors = ""
|
||||||
const mentorList = await director.filter((x) => x.role == "mentor");
|
const mentorList = await director.filter(x => x.role == "mentor")
|
||||||
if (mentorList.length > 0) {
|
if (mentorList.length > 0) {
|
||||||
for (let index = 0; index < mentorList.length; index++) {
|
for (let index = 0; index < mentorList.length; index++) {
|
||||||
const e = await mentorList[index];
|
const e = await mentorList[index]
|
||||||
mentors += e.fullname;
|
mentors += e.fullname
|
||||||
if (index < mentorList.length - 1) {
|
if (index < mentorList.length - 1) {
|
||||||
mentors += ", ";
|
mentors += ", "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 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;
|
const chairman = chairmanData ? chairmanData.fullname : null
|
||||||
|
|
||||||
await result.push({
|
await result.push({
|
||||||
...item,
|
...item,
|
||||||
mentors: mentors,
|
mentors: mentors,
|
||||||
commander: commander,
|
commander: commander,
|
||||||
chairman: chairman,
|
chairman: chairman,
|
||||||
});
|
})
|
||||||
}),
|
})
|
||||||
);
|
)
|
||||||
|
|
||||||
return new HttpSuccess(result);
|
return new HttpSuccess(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -491,7 +449,8 @@ export class AssignController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("")
|
@Get("")
|
||||||
async GetAssign(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
async GetAssign(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||||
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({
|
const assign = await this.assignRepository.findOne({
|
||||||
select: [
|
select: [
|
||||||
|
|
@ -510,31 +469,21 @@ export class AssignController extends Controller {
|
||||||
"updatedAt",
|
"updatedAt",
|
||||||
],
|
],
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน")
|
||||||
}
|
}
|
||||||
|
|
||||||
const profileData = await this.personalRepository.findOne({
|
const profileData = await this.personalRepository.findOne({
|
||||||
select: [
|
select: ["personal_id", "prefixName", "firstName", "lastName", "positionName", "positionLevelName", "positionLineName", "orgRootName", "organization"],
|
||||||
"personal_id",
|
|
||||||
"prefixName",
|
|
||||||
"firstName",
|
|
||||||
"lastName",
|
|
||||||
"positionName",
|
|
||||||
"positionLevelName",
|
|
||||||
"positionLineName",
|
|
||||||
"orgRootName",
|
|
||||||
"organization",
|
|
||||||
],
|
|
||||||
where: {
|
where: {
|
||||||
personal_id: assign.personal_id,
|
personal_id: assign.personal_id,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!profileData) {
|
if (!profileData) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = {
|
const profile = {
|
||||||
|
|
@ -544,18 +493,18 @@ export class AssignController extends Controller {
|
||||||
Department: "-",
|
Department: "-",
|
||||||
OrganizationOrganization: profileData.orgRootName,
|
OrganizationOrganization: profileData.orgRootName,
|
||||||
Oc: profileData.organization,
|
Oc: profileData.organization,
|
||||||
};
|
}
|
||||||
|
|
||||||
const jobs = await this.assignJobRepository.find({
|
const jobs = await this.assignJobRepository.find({
|
||||||
select: ["id", "activity_desc", "goal_desc"],
|
select: ["id", "activity_desc", "goal_desc"],
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
const knowledgeData = await this.assignKnowledgeRepository.find({
|
const knowledgeData = await this.assignKnowledgeRepository.find({
|
||||||
relations: ["knowledge"],
|
relations: ["knowledge"],
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
});
|
})
|
||||||
const knowledges = await knowledgeData.map((x) => ({
|
const knowledges = await knowledgeData.map(x => ({
|
||||||
id: x.knowledge_id,
|
id: x.knowledge_id,
|
||||||
level: x.knowledge_level,
|
level: x.knowledge_level,
|
||||||
title: x.knowledge.title,
|
title: x.knowledge.title,
|
||||||
|
|
@ -571,34 +520,34 @@ export class AssignController extends Controller {
|
||||||
: x.knowledge_level == 5
|
: x.knowledge_level == 5
|
||||||
? x.knowledge.level5
|
? x.knowledge.level5
|
||||||
: "",
|
: "",
|
||||||
}));
|
}))
|
||||||
|
|
||||||
const lawData = await this.lawsRepository.find({
|
const lawData = await this.lawsRepository.find({
|
||||||
where: { active: 1 },
|
where: { active: 1 },
|
||||||
});
|
})
|
||||||
|
|
||||||
const laws = await Promise.all(
|
const laws = await Promise.all(
|
||||||
lawData.map(async (x) => {
|
lawData.map(async x => {
|
||||||
const assignLaw = await this.assignLawRepository.countBy({
|
const assignLaw = await this.assignLawRepository.countBy({
|
||||||
assign_id: assign_id,
|
assign_id: assign_id,
|
||||||
law_id: x.id,
|
law_id: x.id,
|
||||||
});
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: x.id,
|
id: x.id,
|
||||||
selected: assignLaw > 0 ? 1 : 0,
|
selected: assignLaw > 0 ? 1 : 0,
|
||||||
description: x.description,
|
description: x.description,
|
||||||
status_select: x.status_select,
|
status_select: x.status_select,
|
||||||
};
|
}
|
||||||
}),
|
})
|
||||||
);
|
)
|
||||||
|
|
||||||
const skillsData = await this.assignSkillRepository.find({
|
const skillsData = await this.assignSkillRepository.find({
|
||||||
relations: ["skill"],
|
relations: ["skill"],
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
const skills = await skillsData.map((x) => ({
|
const skills = await skillsData.map(x => ({
|
||||||
id: x.skill_id,
|
id: x.skill_id,
|
||||||
level: x.skill_level,
|
level: x.skill_level,
|
||||||
title: x.skill.title,
|
title: x.skill.title,
|
||||||
|
|
@ -614,90 +563,74 @@ export class AssignController extends Controller {
|
||||||
: x.skill_level == 5
|
: x.skill_level == 5
|
||||||
? x.skill.level5
|
? x.skill.level5
|
||||||
: "",
|
: "",
|
||||||
}));
|
}))
|
||||||
|
|
||||||
const competencyData = await this.assignCompetencyRepository.find({
|
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 },
|
where: { assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
const competencys = await competencyData.map((x) => ({
|
const competencys = await competencyData.map(x => ({
|
||||||
id: x.competency_id,
|
id: x.competency_id,
|
||||||
level: x.competency_level,
|
level: x.competency_level,
|
||||||
name: x.competency_name,
|
name: x.competency_name,
|
||||||
description: x.competency_description,
|
description: x.competency_description,
|
||||||
}));
|
}))
|
||||||
|
|
||||||
const competencyGroupData = await this.assignCompetencyGroupRepository.find({
|
const competencyGroupData = await this.assignCompetencyGroupRepository.find({
|
||||||
select: [
|
select: ["competency_group_id", "competency_group_level", "competency_group_name", "competency_group_description"],
|
||||||
"competency_group_id",
|
|
||||||
"competency_group_level",
|
|
||||||
"competency_group_name",
|
|
||||||
"competency_group_description",
|
|
||||||
],
|
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
});
|
})
|
||||||
const competency_groups = await competencyGroupData.map((x) => ({
|
const competency_groups = await competencyGroupData.map(x => ({
|
||||||
id: x.competency_group_id,
|
id: x.competency_group_id,
|
||||||
level: x.competency_group_level,
|
level: x.competency_group_level,
|
||||||
name: x.competency_group_name,
|
name: x.competency_group_name,
|
||||||
description: x.competency_group_description,
|
description: x.competency_group_description,
|
||||||
}));
|
}))
|
||||||
|
|
||||||
const outputs = await this.assignOutputRepository.find({
|
const outputs = await this.assignOutputRepository.find({
|
||||||
select: ["id", "output_desc", "indicator_desc"],
|
select: ["id", "output_desc", "indicator_desc"],
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
const director = await this.assignDirectorRepository.find({
|
const director = await this.assignDirectorRepository.find({
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
order: { ordering: "ASC" },
|
order: { ordering: "ASC" },
|
||||||
});
|
})
|
||||||
|
|
||||||
let mentors = [];
|
let mentors = []
|
||||||
const mentorList = await director.filter((x) => x.role == "mentor");
|
const mentorList = await director.filter(x => x.role == "mentor")
|
||||||
if (mentorList.length > 0) {
|
if (mentorList.length > 0) {
|
||||||
for (let index = 0; index < mentorList.length; index++) {
|
for (let index = 0; index < mentorList.length; index++) {
|
||||||
const e = await mentorList[index];
|
const e = await mentorList[index]
|
||||||
mentors.push({
|
mentors.push({
|
||||||
...e,
|
...e,
|
||||||
name: e.fullname,
|
name: e.fullname,
|
||||||
label:
|
label: e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
||||||
e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
|
||||||
Position: e.position, // report
|
Position: e.position, // 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
|
const commander = await (commanderData
|
||||||
? {
|
? {
|
||||||
...commanderData,
|
...commanderData,
|
||||||
name: commanderData.fullname,
|
name: commanderData.fullname,
|
||||||
label:
|
label: commanderData.fullname + " " + (commanderData.position ? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})` : ""),
|
||||||
commanderData.fullname +
|
|
||||||
" " +
|
|
||||||
(commanderData.position
|
|
||||||
? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`
|
|
||||||
: ""),
|
|
||||||
Position: commanderData.position, // report
|
Position: commanderData.position, // report
|
||||||
}
|
}
|
||||||
: null);
|
: 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
|
const chairman = await (chairmanData
|
||||||
? {
|
? {
|
||||||
...chairmanData,
|
...chairmanData,
|
||||||
name: chairmanData.fullname,
|
name: chairmanData.fullname,
|
||||||
label:
|
label: chairmanData.fullname + " " + (chairmanData.position ? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})` : ""),
|
||||||
chairmanData.fullname +
|
|
||||||
" " +
|
|
||||||
(chairmanData.position
|
|
||||||
? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})`
|
|
||||||
: ""),
|
|
||||||
Position: chairmanData.position, // report
|
Position: chairmanData.position, // report
|
||||||
}
|
}
|
||||||
: null);
|
: null)
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
assign,
|
assign,
|
||||||
|
|
@ -712,6 +645,6 @@ export class AssignController extends Controller {
|
||||||
mentors,
|
mentors,
|
||||||
commander,
|
commander,
|
||||||
chairman,
|
chairman,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -262,7 +262,8 @@ export class DataOptionController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("new-assign")
|
@Get("new-assign")
|
||||||
async NewAssign(@Query() personal_id: string, @Request() request: RequestWithUser) {
|
async NewAssign(@Query() personal_id: string, @Request() request: RequestWithUser) {
|
||||||
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({
|
const person = await this.personalRepository.findOne({
|
||||||
select: [
|
select: [
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,8 @@ export class EvaluateChairmanController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("create")
|
@Get("create")
|
||||||
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||||
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({
|
const director = await this.assignDirectorRepository.findOne({
|
||||||
select: ["personal_id"],
|
select: ["personal_id"],
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,8 @@ export class EvaluateController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("create")
|
@Get("create")
|
||||||
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||||
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({
|
const director = await this.assignDirectorRepository.findOne({
|
||||||
select: ["personal_id"],
|
select: ["personal_id"],
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -32,7 +32,8 @@ export class EvaluateResultController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("create")
|
@Get("create")
|
||||||
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||||
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({
|
const assign = await this.assignRepository.findOne({
|
||||||
relations: ["profile"],
|
relations: ["profile"],
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,8 @@ export class PersonalController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("")
|
@Get("")
|
||||||
async GetPersonal(@Request() request: RequestWithUser, @Query() personal_id: string) {
|
async GetPersonal(@Request() request: RequestWithUser, @Query() personal_id: string) {
|
||||||
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({
|
const person = await this.personalRepository.findOne({
|
||||||
where: { personal_id: personal_id },
|
where: { personal_id: personal_id },
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -46,16 +46,6 @@ class CheckAuth {
|
||||||
.GetData(req, `/org/permission/org/${system}/${action}`)
|
.GetData(req, `/org/permission/org/${system}/${action}`)
|
||||||
.then(async x => {
|
.then(async x => {
|
||||||
let privilege = x.privilege
|
let privilege = x.privilege
|
||||||
// if (action.trim().toLocaleUpperCase() == "CREATE")
|
|
||||||
// privilege = await this.PermissionCreate(req, system);
|
|
||||||
// if (action.trim().toLocaleUpperCase() == "DELETE")
|
|
||||||
// privilege = await this.PermissionDelete(req, system);
|
|
||||||
// if (action.trim().toLocaleUpperCase() == "GET")
|
|
||||||
// privilege = await this.PermissionGet(req, system);
|
|
||||||
// if (action.trim().toLocaleUpperCase() == "LIST")
|
|
||||||
// privilege = await this.PermissionList(req, system);
|
|
||||||
// if (action.trim().toLocaleUpperCase() == "UPDATE")
|
|
||||||
// privilege = await this.PermissionUpdate(req, system);
|
|
||||||
|
|
||||||
let data: any = {
|
let data: any = {
|
||||||
root: [null],
|
root: [null],
|
||||||
|
|
@ -132,16 +122,6 @@ class CheckAuth {
|
||||||
.GetData(req, `/org/permission/user/${system}/${action}/${profileId}`)
|
.GetData(req, `/org/permission/user/${system}/${action}/${profileId}`)
|
||||||
.then(async x => {
|
.then(async x => {
|
||||||
let org = x.org
|
let org = x.org
|
||||||
// if (action.trim().toLocaleUpperCase() == "CREATE")
|
|
||||||
// org = await this.PermissionOrgCreate(req, system);
|
|
||||||
// if (action.trim().toLocaleUpperCase() == "DELETE")
|
|
||||||
// org = await this.PermissionOrgDelete(req, system);
|
|
||||||
// if (action.trim().toLocaleUpperCase() == "GET")
|
|
||||||
// org = await this.PermissionOrgGet(req, system);
|
|
||||||
// if (action.trim().toLocaleUpperCase() == "LIST")
|
|
||||||
// org = await this.PermissionOrgList(req, system);
|
|
||||||
// if (action.trim().toLocaleUpperCase() == "UPDATE")
|
|
||||||
// org = await this.PermissionOrgUpdate(req, system);
|
|
||||||
|
|
||||||
if (org.root != null) if (x.orgRootId != org.root[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล"
|
if (org.root != null) if (x.orgRootId != org.root[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล"
|
||||||
if (org.child1 != null) if (x.orgChild1Id != org.child1[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล"
|
if (org.child1 != null) if (x.orgChild1Id != org.child1[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล"
|
||||||
|
|
@ -159,6 +139,22 @@ class CheckAuth {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
public async Workflow(req: RequestWithUser, id: string, sysName: string) {
|
||||||
|
if (req.headers.hasOwnProperty("api_key") && req.headers["api_key"] && req.headers["api_key"] == process.env.API_KEY) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return await new CallAPI()
|
||||||
|
.PostData(req, "/org/workflow/keycloak/isofficer", {
|
||||||
|
refId: id,
|
||||||
|
sysName: sysName,
|
||||||
|
})
|
||||||
|
.then(x => {
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
.catch(x => {
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
}
|
||||||
public async PermissionCreate(req: RequestWithUser, system: string) {
|
public async PermissionCreate(req: RequestWithUser, system: string) {
|
||||||
return await this.Permission(req, system, "CREATE")
|
return await this.Permission(req, system, "CREATE")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue