Merge branch 'develop'
This commit is contained in:
commit
47d6e7d6b7
8 changed files with 330 additions and 161 deletions
|
|
@ -22,6 +22,7 @@ import { Not, Brackets } from "typeorm";
|
|||
import permission from "../interfaces/permission";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
import { evaluation_directors_director } from "../entities/evaluation_directors_director";
|
||||
@Route("api/v1/evaluation/director")
|
||||
@Tags("director")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -32,6 +33,9 @@ import { setLogDataDiff } from "../interfaces/utils";
|
|||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class DirectorController {
|
||||
private directorRepository = AppDataSource.getRepository(Director);
|
||||
private evaluation_directors_directorRepository = AppDataSource.getRepository(
|
||||
evaluation_directors_director,
|
||||
);
|
||||
|
||||
/**
|
||||
* API สำหรับแสดงรายการกรรมการ
|
||||
|
|
@ -200,10 +204,14 @@ export class DirectorController {
|
|||
*
|
||||
*/
|
||||
@Put("duty/{id}")
|
||||
async updateDuty(@Path() id: string, @Body() body:{duty: string} , @Request() request: RequestWithUser) {
|
||||
async updateDuty(
|
||||
@Path() id: string,
|
||||
@Body() body: { duty: string },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionUpdate(request, "SYS_EVA_INFO");
|
||||
let director = await this.directorRepository.findOneBy({ id });
|
||||
let director = await this.evaluation_directors_directorRepository.findOneBy({ id });
|
||||
if (!director) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกรรมการ");
|
||||
}
|
||||
|
|
@ -212,7 +220,7 @@ export class DirectorController {
|
|||
director.lastUpdateUserId = request.user.sub;
|
||||
director.lastUpdateFullName = request.user.name;
|
||||
director.lastUpdatedAt = new Date();
|
||||
await this.directorRepository.save(director, { data: request });
|
||||
await this.evaluation_directors_directorRepository.save(director, { data: request });
|
||||
setLogDataDiff(request, { before, after: director });
|
||||
return new HttpSuccess();
|
||||
} catch (error: any) {
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import Extension from "../interfaces/extension";
|
|||
import { Portfolio } from "../entities/Portfolio";
|
||||
import { Performance } from "../entities/Performance";
|
||||
import { AnnounceTemplate } from "../entities/AnnounceTemplate";
|
||||
import { evaluation_directors_director } from "../entities/evaluation_directors_director";
|
||||
|
||||
@Route("api/v1/evaluation")
|
||||
@Tags("evaluation")
|
||||
|
|
@ -58,6 +59,9 @@ export class EvaluationController {
|
|||
private directorRepository = AppDataSource.getRepository(Director);
|
||||
private meetingRepository = AppDataSource.getRepository(Meeting);
|
||||
private announceTemplateRepository = AppDataSource.getRepository(AnnounceTemplate);
|
||||
private evaluation_directors_directorRepository = AppDataSource.getRepository(
|
||||
evaluation_directors_director,
|
||||
);
|
||||
|
||||
/**
|
||||
* API ล้างข้อมูล
|
||||
|
|
@ -79,29 +83,41 @@ export class EvaluationController {
|
|||
@Get("performance/user")
|
||||
async listPerformance(@Request() request: RequestWithUser) {
|
||||
const list = await AppDataSource.getRepository(Evaluation)
|
||||
.createQueryBuilder("evaluation")
|
||||
.where("evaluation.userId = :userId", { userId: request.user.sub })
|
||||
.andWhere("evaluation.step = :step", { step: "DONE" })
|
||||
.andWhere("evaluation.evaluationResult IN (:...evaluationResult)", {
|
||||
evaluationResult: ["PASS", "NOTPASS"],
|
||||
})
|
||||
.select([
|
||||
"evaluation.id",
|
||||
"evaluation.type",
|
||||
"evaluation.subject",
|
||||
"evaluation.evaluationResult",
|
||||
"evaluation.lastUpdatedAt",
|
||||
])
|
||||
.orderBy("evaluation.lastUpdatedAt", "ASC")
|
||||
.getMany();
|
||||
.createQueryBuilder("evaluation")
|
||||
.where("evaluation.userId = :userId", { userId: request.user.sub })
|
||||
.andWhere("evaluation.step = :step", { step: "DONE" })
|
||||
.andWhere("evaluation.evaluationResult IN (:...evaluationResult)", {
|
||||
evaluationResult: ["PASS", "NOTPASS"],
|
||||
})
|
||||
.select([
|
||||
"evaluation.id",
|
||||
"evaluation.type",
|
||||
"evaluation.subject",
|
||||
"evaluation.evaluationResult",
|
||||
"evaluation.lastUpdatedAt",
|
||||
])
|
||||
.orderBy("evaluation.lastUpdatedAt", "ASC")
|
||||
.getMany();
|
||||
|
||||
const performance = list.map((item) => ({
|
||||
id: item.id,
|
||||
year: item.lastUpdatedAt?Extension.ToThaiYear(item.lastUpdatedAt.getFullYear()):null,
|
||||
type: item.type == "EXPERT" ? "ชำนาญการ" : item.type == "EXPERTISE" ? "เชียวชาญ" : item.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ": null,
|
||||
subject: item.subject?item.subject[0]:null,
|
||||
evaluationResult: item.evaluationResult == "PASS" ? "ผ่าน" : item.evaluationResult == "NOTPASS" ? "ไม่ผ่าน" : null,
|
||||
}));
|
||||
const performance = list.map((item) => ({
|
||||
id: item.id,
|
||||
year: item.lastUpdatedAt ? Extension.ToThaiYear(item.lastUpdatedAt.getFullYear()) : null,
|
||||
type:
|
||||
item.type == "EXPERT"
|
||||
? "ชำนาญการ"
|
||||
: item.type == "EXPERTISE"
|
||||
? "เชียวชาญ"
|
||||
: item.type == "SPECIAL_EXPERT"
|
||||
? "ชำนาญการพิเศษ"
|
||||
: null,
|
||||
subject: item.subject ? item.subject[0] : null,
|
||||
evaluationResult:
|
||||
item.evaluationResult == "PASS"
|
||||
? "ผ่าน"
|
||||
: item.evaluationResult == "NOTPASS"
|
||||
? "ไม่ผ่าน"
|
||||
: null,
|
||||
}));
|
||||
|
||||
return new HttpSuccess(performance);
|
||||
}
|
||||
|
|
@ -134,6 +150,12 @@ export class EvaluationController {
|
|||
try {
|
||||
// await new permission().PermissionList(request, "SYS_EVA_REQ");
|
||||
let _data = await new permission().PermissionOrgList(request, "SYS_EVA_REQ");
|
||||
await new CallAPI()
|
||||
.PostData(request, "/org/finddna", _data)
|
||||
.then((x) => {
|
||||
_data = x;
|
||||
})
|
||||
.catch((x) => {});
|
||||
const [evaluation, total] = await AppDataSource.getRepository(Evaluation)
|
||||
.createQueryBuilder("evaluation")
|
||||
.andWhere(
|
||||
|
|
@ -349,18 +371,21 @@ export class EvaluationController {
|
|||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* API get template ประกาศคัดเลือก
|
||||
*
|
||||
* @summary get template ประกาศคัดเลือก (ADMIN)
|
||||
*
|
||||
* @param {string} id id ข้อมูลการประเมิน
|
||||
*/
|
||||
@Get("get-announce-template/{id}")
|
||||
async getAnnounceTemp(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
@Get("get-announce-template/{id}")
|
||||
async getAnnounceTemp(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
try {
|
||||
const evaluation = await this.evaluationRepository.findOne({ where: { id } , select: ["id","detailAnnounceStep5Body","detailAnnounceStep5Footer"]});
|
||||
const evaluation = await this.evaluationRepository.findOne({
|
||||
where: { id },
|
||||
select: ["id", "detailAnnounceStep5Body", "detailAnnounceStep5Footer"],
|
||||
});
|
||||
if (!evaluation) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
|
||||
}
|
||||
|
|
@ -370,7 +395,7 @@ export class EvaluationController {
|
|||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ดึงข้อมูลรายละเอียด step การขอประเมิน
|
||||
|
|
@ -510,24 +535,41 @@ export class EvaluationController {
|
|||
if (!evaluation) {
|
||||
return `not found data`;
|
||||
}
|
||||
let _code = requestBody.type == "EXPERT" ? "ST05-1" : requestBody.type == "EXPERTISE" ? "ST05-1" : requestBody.type == "SPECIAL_EXPERT" ? "ST05-2" : "ST05-1";
|
||||
let _code =
|
||||
requestBody.type == "EXPERT"
|
||||
? "ST05-1"
|
||||
: requestBody.type == "EXPERTISE"
|
||||
? "ST05-1"
|
||||
: requestBody.type == "SPECIAL_EXPERT"
|
||||
? "ST05-2"
|
||||
: "ST05-1";
|
||||
const announceTemplate5 = await this.announceTemplateRepository.findOne({
|
||||
where:{
|
||||
code : _code
|
||||
where: {
|
||||
code: _code,
|
||||
},
|
||||
select: ["detailBody","detailFooter"]
|
||||
})
|
||||
select: ["detailBody", "detailFooter"],
|
||||
});
|
||||
const before = null;
|
||||
let typeTh =
|
||||
requestBody.type == "EXPERT"
|
||||
? "ชำนาญการ"
|
||||
: requestBody.type == "EXPERTISE"
|
||||
? "เชียวชาญ"
|
||||
: requestBody.type == "SPECIAL_EXPERT"
|
||||
? "ชำนาญการพิเศษ"
|
||||
: "";
|
||||
await new CallAPI()
|
||||
.GetData(request, `/org/profile/keycloak/commander/${request.user.sub}`)
|
||||
.then(async (x) => {
|
||||
evaluation.rootDnaId = x.rootDnaId;
|
||||
evaluation.child1DnaId = x.child1DnaId;
|
||||
evaluation.child2DnaId = x.child2DnaId;
|
||||
evaluation.child3DnaId = x.child3DnaId;
|
||||
evaluation.child4DnaId = x.child4DnaId;
|
||||
})
|
||||
.catch();
|
||||
.GetData(request, `/org/profile/keycloak/commander/${request.user.sub}`)
|
||||
.then(async (x) => {
|
||||
evaluation.rootDnaId = x.rootDnaId;
|
||||
evaluation.child1DnaId = x.child1DnaId;
|
||||
evaluation.child2DnaId = x.child2DnaId;
|
||||
evaluation.child3DnaId = x.child3DnaId;
|
||||
evaluation.child4DnaId = x.child4DnaId;
|
||||
})
|
||||
.catch();
|
||||
evaluation.assignedPosition = requestBody.position ? requestBody.position : _null;
|
||||
evaluation.assignedPosLevel = typeTh;
|
||||
evaluation.step = "PREPARE_DOC_V1";
|
||||
evaluation.type = requestBody.type == "EXPERT" ? "EXPERT" : "SPECIAL_EXPERT";
|
||||
evaluation.fullName = requestBody.fullName;
|
||||
|
|
@ -538,10 +580,16 @@ export class EvaluationController {
|
|||
evaluation.lastUpdateFullName = request.user.name;
|
||||
evaluation.lastUpdatedAt = new Date();
|
||||
evaluation.userId = request.user.sub;
|
||||
evaluation.detailAnnounceStep5Body = announceTemplate5?.detailBody??_null;
|
||||
evaluation.detailAnnounceStep5Footer = announceTemplate5?.detailFooter??_null;
|
||||
evaluation.positionArea = requestBody.positionArea && requestBody.positionArea !== "" ? requestBody.positionArea : _null;
|
||||
evaluation.posExecutive = requestBody.posExecutive && requestBody.posExecutive !== "" ? requestBody.posExecutive : _null;
|
||||
evaluation.detailAnnounceStep5Body = announceTemplate5?.detailBody ?? _null;
|
||||
evaluation.detailAnnounceStep5Footer = announceTemplate5?.detailFooter ?? _null;
|
||||
evaluation.positionArea =
|
||||
requestBody.positionArea && requestBody.positionArea !== ""
|
||||
? requestBody.positionArea
|
||||
: _null;
|
||||
evaluation.posExecutive =
|
||||
requestBody.posExecutive && requestBody.posExecutive !== ""
|
||||
? requestBody.posExecutive
|
||||
: _null;
|
||||
await this.evaluationRepository.save(evaluation, { data: request });
|
||||
setLogDataDiff(request, { before, after: evaluation });
|
||||
|
||||
|
|
@ -663,7 +711,7 @@ export class EvaluationController {
|
|||
salaries.lastUpdateUserId = request.user.sub;
|
||||
salaries.lastUpdateFullName = request.user.name;
|
||||
salaries.lastUpdatedAt = new Date();
|
||||
|
||||
|
||||
await this.salaryRepository.save(salaries, { data: request });
|
||||
setLogDataDiff(request, { before, after: salaries });
|
||||
});
|
||||
|
|
@ -714,7 +762,7 @@ export class EvaluationController {
|
|||
await this.assessmentRepository.save(assessment, { data: request });
|
||||
setLogDataDiff(request, { before, after: assessment });
|
||||
});
|
||||
|
||||
|
||||
//Portfolio
|
||||
if (requestBody.portfolios != null)
|
||||
requestBody.portfolios.forEach(async (pfo) => {
|
||||
|
|
@ -730,7 +778,7 @@ export class EvaluationController {
|
|||
portfolio.evaluation = evaluation;
|
||||
await this.portfolioRepository.save(portfolio, { data: request });
|
||||
setLogDataDiff(request, { before, after: portfolio });
|
||||
});
|
||||
});
|
||||
|
||||
//Performance
|
||||
if (requestBody.performances != null)
|
||||
|
|
@ -749,8 +797,8 @@ export class EvaluationController {
|
|||
performance.evaluation = evaluation;
|
||||
await this.performanceRepository.save(performance, { data: request });
|
||||
setLogDataDiff(request, { before, after: performance });
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
//EvaluationLogs
|
||||
const evaluationLogs = new EvaluationLogs();
|
||||
evaluationLogs.step = (await ConvertToThaiStep("PREPARE_DOC_V1")) ?? _null;
|
||||
|
|
@ -799,6 +847,7 @@ export class EvaluationController {
|
|||
const evaluation = Object.assign(new Evaluation(), requestBody);
|
||||
const before = null;
|
||||
let org: any;
|
||||
const __null: any = null;
|
||||
await new CallAPI()
|
||||
.GetData(request, `/org/profile/keycloak/commander/${request.user.sub}`)
|
||||
.then(async (x) => {
|
||||
|
|
@ -808,9 +857,12 @@ export class EvaluationController {
|
|||
evaluation.child2DnaId = x.child2DnaId;
|
||||
evaluation.child3DnaId = x.child3DnaId;
|
||||
evaluation.child4DnaId = x.child4DnaId;
|
||||
evaluation.positionLevel = x.posLevelName;
|
||||
})
|
||||
.catch();
|
||||
//Evaluation
|
||||
evaluation.assignedPosition = requestBody.position ? requestBody.position : __null;
|
||||
evaluation.assignedPosLevel = "เชียวชาญ";
|
||||
evaluation.oc = org;
|
||||
evaluation.step = "DONE";
|
||||
evaluation.type = "EXPERTISE";
|
||||
|
|
@ -1807,21 +1859,20 @@ export class EvaluationController {
|
|||
})
|
||||
.catch((x) => {});
|
||||
await Promise.all(
|
||||
_director.map((director:any) => {
|
||||
_director.map((director: any) => {
|
||||
return new CallAPI()
|
||||
.PostData(request, "/placement/noti/keycloak", {
|
||||
subject: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`,
|
||||
body: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`,
|
||||
receiverUserId: director.keycloak,
|
||||
payload: "",
|
||||
isSendMail: true,
|
||||
isSendInbox: true,
|
||||
isSendNotification: true,
|
||||
})
|
||||
.then((x) => {
|
||||
})
|
||||
.catch((x) => {});
|
||||
})
|
||||
.PostData(request, "/placement/noti/keycloak", {
|
||||
subject: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`,
|
||||
body: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`,
|
||||
receiverUserId: director.keycloak,
|
||||
payload: "",
|
||||
isSendMail: true,
|
||||
isSendInbox: true,
|
||||
isSendNotification: true,
|
||||
})
|
||||
.then((x) => {})
|
||||
.catch((x) => {});
|
||||
}),
|
||||
);
|
||||
return new HttpSuccess();
|
||||
} catch (error: any) {
|
||||
|
|
@ -2115,39 +2166,43 @@ export class EvaluationController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* API แก้ไข template ประกาศคัดเลือก
|
||||
*
|
||||
* @summary แก้ไข template ประกาศคัดเลือก (ADMIN)
|
||||
*
|
||||
* @param {string} id id ข้อมูลการประเมิน
|
||||
*/
|
||||
@Put("edit-announce-template/{id}")
|
||||
async editAnnounceTemp(@Path() id: string, @Request() request: RequestWithUser, @Body() body: {detailBody: string, detailFooter: string}) {
|
||||
try {
|
||||
await new permission().PermissionUpdate(request, "SYS_EVA_REQ");
|
||||
|
||||
const evaluation = await this.evaluationRepository.findOne({ where: { id } });
|
||||
if (!evaluation) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
}
|
||||
const before = structuredClone(evaluation);
|
||||
|
||||
evaluation.detailAnnounceStep5Body = body.detailBody;
|
||||
evaluation.detailAnnounceStep5Footer = body.detailFooter;
|
||||
evaluation.lastUpdateUserId = request.user.sub;
|
||||
evaluation.lastUpdateFullName = request.user.name;
|
||||
evaluation.lastUpdatedAt = new Date();
|
||||
await this.evaluationRepository.save(evaluation, { data: request });
|
||||
setLogDataDiff(request, { before, after: evaluation });
|
||||
|
||||
return new HttpSuccess();
|
||||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
}
|
||||
}
|
||||
@Put("edit-announce-template/{id}")
|
||||
async editAnnounceTemp(
|
||||
@Path() id: string,
|
||||
@Request() request: RequestWithUser,
|
||||
@Body() body: { detailBody: string; detailFooter: string },
|
||||
) {
|
||||
try {
|
||||
await new permission().PermissionUpdate(request, "SYS_EVA_REQ");
|
||||
|
||||
const evaluation = await this.evaluationRepository.findOne({ where: { id } });
|
||||
if (!evaluation) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
}
|
||||
const before = structuredClone(evaluation);
|
||||
|
||||
evaluation.detailAnnounceStep5Body = body.detailBody;
|
||||
evaluation.detailAnnounceStep5Footer = body.detailFooter;
|
||||
evaluation.lastUpdateUserId = request.user.sub;
|
||||
evaluation.lastUpdateFullName = request.user.name;
|
||||
evaluation.lastUpdatedAt = new Date();
|
||||
await this.evaluationRepository.save(evaluation, { data: request });
|
||||
setLogDataDiff(request, { before, after: evaluation });
|
||||
|
||||
return new HttpSuccess();
|
||||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API บันทึกแจ้งผลการประกาศคัดเลือก
|
||||
|
|
@ -2180,11 +2235,11 @@ export class EvaluationController {
|
|||
setLogDataDiff(request, { before: null, after: evaluationLogs });
|
||||
}
|
||||
const before = structuredClone(evaluation);
|
||||
|
||||
evaluation.step = "PREPARE_DOC_V2";
|
||||
evaluation.subjectDoc2 = evaluation.subject;
|
||||
evaluation.authorDoc2 = evaluation.author;
|
||||
evaluation.assignedPosition = evaluation.position;
|
||||
evaluation.assignedPosition = evaluation.assignedPosition;
|
||||
evaluation.assignedPosLevel = evaluation.assignedPosLevel;
|
||||
evaluation.commanderFullnameDoc2 = evaluation.commanderFullname;
|
||||
evaluation.commanderPositionDoc2 = evaluation.commanderPosition;
|
||||
evaluation.commanderAboveFullnameDoc2 = evaluation.commanderAboveFullname;
|
||||
|
|
@ -2196,7 +2251,7 @@ export class EvaluationController {
|
|||
evaluation.commanderAboveOrgDoc2 = evaluation.commanderAboveOrg;
|
||||
evaluation.commanderAboveOrgOldDoc2 = evaluation.commanderAboveOrgOld;
|
||||
evaluation.commanderAbovePositionOldDoc2 = evaluation.commanderAbovePositionOld;
|
||||
|
||||
|
||||
evaluation.datePrepareDoc2 = new Date();
|
||||
evaluation.lastUpdateUserId = request.user.sub;
|
||||
evaluation.lastUpdateFullName = request.user.name;
|
||||
|
|
@ -2441,12 +2496,23 @@ export class EvaluationController {
|
|||
if (!evaluation) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
}
|
||||
if (!evaluation.directors) {
|
||||
evaluation.directors = [];
|
||||
if (!evaluation.evaluation_directors_director) {
|
||||
evaluation.evaluation_directors_director = [];
|
||||
}
|
||||
body.directors.forEach(async (directorId) => {
|
||||
const director = await this.directorRepository.findOne({ where: { id: directorId } });
|
||||
if (director != null) evaluation.directors.push(director);
|
||||
if (director != null) {
|
||||
await this.evaluation_directors_directorRepository.save({
|
||||
directorId: director.id,
|
||||
evaluationId: evaluation.id,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
lastUpdateUserId: request.user.sub,
|
||||
lastUpdateFullName: request.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
evaluation.lastUpdateUserId = request.user.sub;
|
||||
|
|
@ -2543,20 +2609,24 @@ export class EvaluationController {
|
|||
|
||||
const evaluation = await this.evaluationRepository.findOne({
|
||||
where: { id },
|
||||
relations: ["directors", "meetings"],
|
||||
relations: [
|
||||
"evaluation_directors_director",
|
||||
"evaluation_directors_director.director",
|
||||
"meetings",
|
||||
],
|
||||
});
|
||||
if (!evaluation) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
}
|
||||
const directors = evaluation.directors.map((director) => ({
|
||||
const directors = evaluation.evaluation_directors_director.map((director) => ({
|
||||
id: director.id,
|
||||
prefix: director.prefix,
|
||||
firstName: director.firstName,
|
||||
lastName: director.lastName,
|
||||
position: director.position,
|
||||
prefix: director.director.prefix,
|
||||
firstName: director.director.firstName,
|
||||
lastName: director.director.lastName,
|
||||
position: director.director.position,
|
||||
positionName: null,
|
||||
email: director.email,
|
||||
phone: director.phone,
|
||||
email: director.director.email,
|
||||
phone: director.director.phone,
|
||||
duty: director.duty,
|
||||
}));
|
||||
|
||||
|
|
@ -2770,7 +2840,7 @@ export class EvaluationController {
|
|||
"commanderAbovePositionOld",
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
if (!evaluation) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
}
|
||||
|
|
@ -2839,6 +2909,7 @@ export class EvaluationController {
|
|||
"authorDoc2",
|
||||
"subjectDoc2",
|
||||
"assignedPosition",
|
||||
"assignedPosLevel",
|
||||
"commanderFullnameDoc2",
|
||||
"commanderOrgDoc2",
|
||||
"commanderOrgOldDoc2",
|
||||
|
|
@ -2883,6 +2954,7 @@ export class EvaluationController {
|
|||
"authorDoc2",
|
||||
"subjectDoc2",
|
||||
"assignedPosition",
|
||||
"assignedPosLevel",
|
||||
"commanderFullnameDoc2",
|
||||
"commanderOrgDoc2",
|
||||
"commanderOrgOldDoc2",
|
||||
|
|
@ -2951,19 +3023,19 @@ export class EvaluationController {
|
|||
if (!evaluation) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
}
|
||||
const _null:any = null;
|
||||
const _null: any = null;
|
||||
evaluation.author = body.author;
|
||||
evaluation.subject = body.subject;
|
||||
evaluation.commanderFullname = body.commanderFullname;
|
||||
evaluation.commanderOrg = body.commanderOrg??_null;
|
||||
evaluation.commanderOrgOld = body.commanderOrgOld??_null;
|
||||
evaluation.commanderOrg = body.commanderOrg ?? _null;
|
||||
evaluation.commanderOrgOld = body.commanderOrgOld ?? _null;
|
||||
evaluation.commanderPosition = body.commanderPosition;
|
||||
evaluation.commanderPositionOld = body.commanderPositionOld??_null;
|
||||
evaluation.commanderPositionOld = body.commanderPositionOld ?? _null;
|
||||
evaluation.commanderAboveFullname = body.commanderAboveFullname;
|
||||
evaluation.commanderAboveOrg = body.commanderAboveOrg??_null;
|
||||
evaluation.commanderAboveOrgOld = body.commanderAboveOrgOld??_null;
|
||||
evaluation.commanderAboveOrg = body.commanderAboveOrg ?? _null;
|
||||
evaluation.commanderAboveOrgOld = body.commanderAboveOrgOld ?? _null;
|
||||
evaluation.commanderAbovePosition = body.commanderAbovePosition;
|
||||
evaluation.commanderAbovePositionOld = body.commanderAbovePositionOld??_null;
|
||||
evaluation.commanderAbovePositionOld = body.commanderAbovePositionOld ?? _null;
|
||||
evaluation.lastUpdateUserId = request.user.sub;
|
||||
evaluation.lastUpdateFullName = request.user.name;
|
||||
evaluation.lastUpdatedAt = new Date();
|
||||
|
|
@ -2992,6 +3064,7 @@ export class EvaluationController {
|
|||
authorDoc2: "string",
|
||||
subjectDoc2: "string",
|
||||
assignedPosition: "string",
|
||||
assignedPosLevel: "string",
|
||||
commanderFullnameDoc2: "string",
|
||||
commanderPositionDoc2: "string",
|
||||
commanderAboveFullnameDoc2: "string",
|
||||
|
|
@ -3005,6 +3078,7 @@ export class EvaluationController {
|
|||
authorDoc2: string;
|
||||
subjectDoc2: string[];
|
||||
assignedPosition: string;
|
||||
assignedPosLevel?: string;
|
||||
commanderFullnameDoc2: string;
|
||||
commanderPositionDoc2: string;
|
||||
commanderAboveFullnameDoc2: string;
|
||||
|
|
@ -3024,20 +3098,21 @@ export class EvaluationController {
|
|||
if (!evaluation) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
}
|
||||
const _null:any = null;
|
||||
const _null: any = null;
|
||||
evaluation.authorDoc2 = body.authorDoc2;
|
||||
evaluation.subjectDoc2 = body.subjectDoc2;
|
||||
evaluation.assignedPosition = body.assignedPosition;
|
||||
evaluation.assignedPosLevel = body.assignedPosLevel ? body.assignedPosLevel : evaluation.assignedPosLevel;
|
||||
evaluation.commanderFullnameDoc2 = body.commanderFullnameDoc2;
|
||||
evaluation.commanderOrgDoc2 = body.commanderOrgDoc2??_null;
|
||||
evaluation.commanderOrgOldDoc2 = body.commanderOrgOldDoc2??_null;
|
||||
evaluation.commanderOrgDoc2 = body.commanderOrgDoc2 ?? _null;
|
||||
evaluation.commanderOrgOldDoc2 = body.commanderOrgOldDoc2 ?? _null;
|
||||
evaluation.commanderPositionDoc2 = body.commanderPositionDoc2;
|
||||
evaluation.commanderPositionOldDoc2 = body.commanderPositionOldDoc2??_null;
|
||||
evaluation.commanderPositionOldDoc2 = body.commanderPositionOldDoc2 ?? _null;
|
||||
evaluation.commanderAboveFullnameDoc2 = body.commanderAboveFullnameDoc2;
|
||||
evaluation.commanderAboveOrgDoc2 = body.commanderAboveOrgDoc2??_null;
|
||||
evaluation.commanderAboveOrgOldDoc2 = body.commanderAboveOrgOldDoc2??_null;
|
||||
evaluation.commanderAboveOrgDoc2 = body.commanderAboveOrgDoc2 ?? _null;
|
||||
evaluation.commanderAboveOrgOldDoc2 = body.commanderAboveOrgOldDoc2 ?? _null;
|
||||
evaluation.commanderAbovePositionDoc2 = body.commanderAbovePositionDoc2;
|
||||
evaluation.commanderAbovePositionOldDoc2 = body.commanderAbovePositionOldDoc2??_null;
|
||||
evaluation.commanderAbovePositionOldDoc2 = body.commanderAbovePositionOldDoc2 ?? _null;
|
||||
evaluation.isUpdated = true;
|
||||
evaluation.lastUpdateUserId = request.user.sub;
|
||||
evaluation.lastUpdateFullName = request.user.name;
|
||||
|
|
@ -3067,7 +3142,7 @@ export class EvaluationController {
|
|||
// await new permission().PermissionDelete(request, "SYS_EVA_REQ");
|
||||
const evaluation = await this.evaluationRepository.findOne({
|
||||
where: { id },
|
||||
relations: ["meetings", "directors"],
|
||||
relations: ["meetings", "evaluation_directors_director"],
|
||||
});
|
||||
|
||||
if (!evaluation) {
|
||||
|
|
@ -3088,11 +3163,7 @@ export class EvaluationController {
|
|||
this.meetingRepository.remove(meeting, { data: request }),
|
||||
),
|
||||
);
|
||||
await Promise.all(
|
||||
evaluation.directors.map((director) =>
|
||||
this.directorRepository.remove(director, { data: request }),
|
||||
),
|
||||
);
|
||||
await this.evaluation_directors_directorRepository.delete({ evaluationId: id });
|
||||
await this.evaluationRepository.delete({ id });
|
||||
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
|
|
@ -200,6 +200,9 @@ export class ReoportController {
|
|||
"evaluation.commanderAbovePositionOld",
|
||||
"evaluation.commanderAboveOrg",
|
||||
"evaluation.commanderAboveOrgOld",
|
||||
"evaluation.root",
|
||||
"evaluation.assignedPosition",
|
||||
"evaluation.assignedPosLevel",
|
||||
|
||||
"education.educationLevel",
|
||||
"education.institute",
|
||||
|
|
@ -318,7 +321,7 @@ export class ReoportController {
|
|||
lastOneYear: Extension.ToThaiNumber((thaiYear - 1).toString()),
|
||||
currentYear: Extension.ToThaiNumber(thaiYear.toString()),
|
||||
};
|
||||
let _orgNoNewLine = (org ? org : "-").replace(/\n/g, " ");
|
||||
let _orgNoNewLine = (evaluation.oc ? evaluation.oc : "-").replace(/\n/g, " ");
|
||||
let topic10 = evaluation.type == "EXPERT" || evaluation.type == "EXPERTISE" ? "หน่วยงาน" : evaluation.type == "SPECIAL_EXPERT" ? "กรุงเทพมหานคร" : "หน่วยงาน";
|
||||
let footer10 = evaluation.type == "EXPERT" || evaluation.type == "EXPERTISE" ? "หัวหน้าหน่วยงาน" : evaluation.type == "SPECIAL_EXPERT" ? "ปลัดกรุงเทพมหานคร" : "หัวหน้าหน่วยงาน";
|
||||
let typeTh = evaluation.type == "EXPERT" ? "ชำนาญการ" : evaluation.type == "EXPERTISE" ? "เชียวชาญ" : evaluation.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ":"";
|
||||
|
|
@ -335,16 +338,25 @@ export class ReoportController {
|
|||
prefix: evaluation.prefix,
|
||||
fullName: evaluation.fullName ? `${evaluation.fullName}` : "",
|
||||
position: evaluation.position ? evaluation.position : "",
|
||||
// ตำแหน่งเดิม,
|
||||
posAndPosLevel: (evaluation.position ? `${evaluation.position}` : "") + (evaluation.positionLevel ? `${evaluation.positionLevel}` : ""),
|
||||
posAndTypeTh: (evaluation.position ? `${evaluation.position}` : "" ) + (typeTh ? `${typeTh}` : ""),
|
||||
// ตำแหน่งใหม่
|
||||
posAndTypeTh: (evaluation.assignedPosition ? `${evaluation.assignedPosition}` : "" ) + (evaluation.assignedPosLevel ? `${evaluation.assignedPosLevel}` : `${typeTh??""}`),
|
||||
posLevel: evaluation.assignedPosLevel ?? "-", //ระดับที่ขอประเมิน
|
||||
posNo: evaluation.posNo ? Extension.ToThaiNumber(evaluation.posNo) : "",
|
||||
posNoWithSym: evaluation.posNo ? `(${Extension.ToThaiNumber(evaluation.posNo)})` : "",
|
||||
oc: evaluation.oc ? evaluation.oc : "-",
|
||||
oc: evaluation.oc ? evaluation.oc.replace(/\n/g, " ") : "-",
|
||||
org: org ? org : "-", //สังกัด
|
||||
orgNoNewLine: _orgNoNewLine ? _orgNoNewLine : "-", //สังกัดแบบไม่เว้นวรรค
|
||||
root: root ? root : "-", //หน่วยงาน
|
||||
salary: evaluation.salary ? Extension.ToThaiNumber(evaluation.salary) : "-",
|
||||
salaryWithPrefix: evaluation.salary ? "อัตราเงินเดือนปัจจุบัน" +" "+ Extension.ToThaiNumber(evaluation.salary) : "-",
|
||||
root: evaluation.salaries.length > 0 ? evaluation.salaries[0].orgRoot : "-", //หน่วยงาน
|
||||
child1: evaluation.salaries.length > 0 // กอง / ศูนย์ / ส่วน
|
||||
? evaluation.salaries[0].orgChild1
|
||||
: "-",
|
||||
child432: evaluation.salaries.length > 0 // งาน / ฝ่าย / กลุ่ม
|
||||
? `${evaluation.salaries[0].orgChild4 ?? ""} ${evaluation.salaries[0].orgChild3 ?? ""} ${evaluation.salaries[0].orgChild2 ?? ""}`.trim()
|
||||
: "-",
|
||||
salary: evaluation.salary ? Extension.ToThaiNumber(Number(evaluation.salary).toLocaleString()) : "-",
|
||||
salaryWithPrefix: evaluation.salary ? "อัตราเงินเดือนปัจจุบัน" +" "+ Extension.ToThaiNumber(Number(evaluation.salary).toLocaleString()) : "-",
|
||||
positionLevel: evaluation.positionLevel ? evaluation.positionLevel : "",
|
||||
detailAnnounceStep5Body: evaluation.detailAnnounceStep5Body,
|
||||
detailAnnounceStep5Footer: evaluation.detailAnnounceStep5Footer,
|
||||
|
|
@ -521,9 +533,9 @@ export class ReoportController {
|
|||
commanderAboveOrg: evaluation.commanderAboveOrg ? evaluation.commanderAboveOrg : "-",
|
||||
commanderAboveOrgOld: evaluation.commanderAboveOrgOld ? evaluation.commanderAboveOrgOld : "-",
|
||||
commanderPositionSign: (evaluation.commanderPosition ? evaluation.commanderPosition : "") + (evaluation.commanderOrg ? " " + evaluation.commanderOrg : "")
|
||||
+ (evaluation.commanderPosition || evaluation.commanderOrg ? `\n` + "ขณะดำรงตำแหน่ง" : "") + (evaluation.commanderPositionOld ? " " + evaluation.commanderPositionOld:"") + (evaluation.commanderOrgOld ? " " + evaluation.commanderOrgOld : ""),
|
||||
+ (evaluation.commanderPosition || evaluation.commanderOrg ? `\n` : "") + (evaluation.commanderPositionOld ? `ขณะดำรงตำแหน่ง ${evaluation.commanderPositionOld}` : "") + (evaluation.commanderOrgOld ? " " + evaluation.commanderOrgOld : ""),
|
||||
commanderAbovePositionSign: (evaluation.commanderAbovePosition ? evaluation.commanderAbovePosition : "") + (evaluation.commanderAboveOrg ? " " + evaluation.commanderAboveOrg : "")
|
||||
+ (evaluation.commanderAbovePosition || evaluation.commanderAboveOrg ? `\n` + "ขณะดำรงตำแหน่ง" : "") + (evaluation.commanderAbovePositionOld ? " " + evaluation.commanderAbovePositionOld: "") + (evaluation.commanderAboveOrgOld ? " " + evaluation.commanderAboveOrgOld : ""),
|
||||
+ (evaluation.commanderAbovePosition || evaluation.commanderAboveOrg ? `\n`: "") + (evaluation.commanderAbovePositionOld ? `ขณะดำรงตำแหน่ง ${evaluation.commanderAbovePositionOld}` : "") + (evaluation.commanderAboveOrgOld ? " " + evaluation.commanderAboveOrgOld : ""),
|
||||
years: years,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
import {
|
||||
Entity,
|
||||
Column,
|
||||
ManyToMany,
|
||||
} from "typeorm";
|
||||
import { Entity, Column, ManyToMany, OneToMany, JoinTable } from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
import { Evaluation } from "./Evaluation";
|
||||
import { evaluation_directors_director } from "./evaluation_directors_director";
|
||||
@Entity("director")
|
||||
export class Director extends EntityBase {
|
||||
@Column({ nullable: true, comment: "คำนำหน้าชื่อ" })
|
||||
|
|
@ -25,11 +22,18 @@ export class Director extends EntityBase {
|
|||
@Column({ nullable: true, comment: "ตำแหน่ง" })
|
||||
position: string;
|
||||
|
||||
@Column({ nullable: true, comment: "หน้าที่" })
|
||||
duty: string;
|
||||
// @Column({ nullable: true, comment: "หน้าที่" })
|
||||
// duty: string;
|
||||
|
||||
@ManyToMany(() => Evaluation, (evaluation) => evaluation.directors)
|
||||
evaluations: Evaluation[];
|
||||
// @ManyToMany(() => Evaluation, (evaluation) => evaluation.directors)
|
||||
// evaluations: Evaluation[];
|
||||
|
||||
@OneToMany(
|
||||
() => evaluation_directors_director,
|
||||
(evaluation_directors_director) => evaluation_directors_director.director,
|
||||
)
|
||||
@JoinTable()
|
||||
evaluation_directors_director: evaluation_directors_director[];
|
||||
}
|
||||
|
||||
export class CreateDirector {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { Director } from "./Director";
|
|||
import { Meeting } from "./Meeting";
|
||||
import { Portfolio } from "./Portfolio";
|
||||
import { Performance } from "./Performance";
|
||||
import { evaluation_directors_director } from "./evaluation_directors_director";
|
||||
|
||||
@Entity("evaluation")
|
||||
export class Evaluation extends EntityBase {
|
||||
|
|
@ -201,7 +202,6 @@ export class Evaluation extends EntityBase {
|
|||
@Column({ nullable: true, comment: "ตำแหน่ง ผู้บังคับบัญชาชั้นต้น (จัดเตรียมเอกสารเล่ม 2)" })
|
||||
commanderPositionDoc2: string;
|
||||
|
||||
|
||||
@Column({ nullable: true, comment: "สังกัดปัจุบัน ผู้บังคับบัญชาชั้นต้น" })
|
||||
commanderOrg: string;
|
||||
@Column({ nullable: true, comment: "สังกัดเดิม ผู้บังคับบัญชาชั้นต้น" })
|
||||
|
|
@ -256,32 +256,33 @@ export class Evaluation extends EntityBase {
|
|||
@Column({ nullable: true, comment: "ชื่อเจ้าของผลงาน" })
|
||||
author: string;
|
||||
|
||||
@Column({ type: 'json', nullable: true, comment: 'ชื่อผลงาน' })
|
||||
@Column({ type: "json", nullable: true, comment: "ชื่อผลงาน" })
|
||||
subject: string[];
|
||||
|
||||
@Column({ nullable: true, comment: "ชื่อเจ้าของผลงาน2" })
|
||||
authorDoc2: string;
|
||||
|
||||
@Column({ type: 'json', nullable: true, comment: "ชื่อผลงาน2" })
|
||||
@Column({ type: "json", nullable: true, comment: "ชื่อผลงาน2" })
|
||||
subjectDoc2: string[];
|
||||
|
||||
@Column({ nullable: true, comment: "ตำแหน่งที่ได้รับมอบหมาย" })
|
||||
assignedPosition: string;
|
||||
|
||||
@Column({ nullable: true, comment: "ระดับที่ได้รับมอบหมาย" })
|
||||
assignedPosLevel: string;
|
||||
|
||||
@Column({ nullable: true, comment: "ผลการประเมิน", default: "PENDING" }) //PENDING,PASS,NOTPASS
|
||||
evaluationResult: string;
|
||||
|
||||
@Column({ type: 'text', nullable: true, comment: 'รายละเอียดประกาศ(STEP5)'})
|
||||
@Column({ type: "text", nullable: true, comment: "รายละเอียดประกาศ(STEP5)" })
|
||||
detailAnnounceStep5Body: string;
|
||||
|
||||
@Column({ type: 'text', nullable: true, comment: 'รายละเอียดส่วนท้าย(STEP5)'})
|
||||
@Column({ type: "text", nullable: true, comment: "รายละเอียดส่วนท้าย(STEP5)" })
|
||||
detailAnnounceStep5Footer: string;
|
||||
|
||||
@Column({ default: false, comment: 'สถานะเช็คการอัพเดทชื่อผลงาน (STEP6)'})
|
||||
@Column({ default: false, comment: "สถานะเช็คการอัพเดทชื่อผลงาน (STEP6)" })
|
||||
isUpdated: boolean;
|
||||
|
||||
|
||||
|
||||
@OneToMany(() => EvaluationLogs, (evaluationLogs) => evaluationLogs.evaluation)
|
||||
evaluationLogs: EvaluationLogs[];
|
||||
|
||||
|
|
@ -306,15 +307,20 @@ export class Evaluation extends EntityBase {
|
|||
@OneToMany(() => Performance, (performance) => performance.evaluation)
|
||||
performances: Performance[];
|
||||
|
||||
@ManyToMany(() => Director, (director) => director.evaluations)
|
||||
@JoinTable()
|
||||
directors: Director[];
|
||||
// @ManyToMany(() => Director, (director) => director.evaluations)
|
||||
// @JoinTable()
|
||||
// directors: Director[];
|
||||
|
||||
@ManyToMany(() => Meeting, (meeting) => meeting.evaluations)
|
||||
@JoinTable()
|
||||
meetings: Meeting[];
|
||||
|
||||
|
||||
@OneToMany(
|
||||
() => evaluation_directors_director,
|
||||
(evaluation_directors_director) => evaluation_directors_director.evaluation,
|
||||
)
|
||||
@JoinTable()
|
||||
evaluation_directors_director: evaluation_directors_director[];
|
||||
}
|
||||
|
||||
export class CreateEvaluation {
|
||||
|
|
@ -612,7 +618,7 @@ export class CreateEvaluationExpertise {
|
|||
|
||||
@Column()
|
||||
oc?: string | null;
|
||||
|
||||
|
||||
@Column()
|
||||
citizenId?: string | null;
|
||||
|
||||
|
|
@ -639,7 +645,6 @@ export class CreateEvaluationExpertise {
|
|||
|
||||
@Column()
|
||||
govAge?: string | null;
|
||||
|
||||
}
|
||||
|
||||
export type UpdateEvaluation = Partial<Evaluation>;
|
||||
|
|
|
|||
35
src/entities/evaluation_directors_director.ts
Normal file
35
src/entities/evaluation_directors_director.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import { Entity, Column, ManyToMany, ManyToOne, JoinColumn } from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
import { Evaluation } from "./Evaluation";
|
||||
import { Director } from "./Director";
|
||||
@Entity("evaluation_directors_director")
|
||||
export class evaluation_directors_director extends EntityBase {
|
||||
@Column({
|
||||
comment: "Id การทำรายการระบบประเมิน",
|
||||
length: 40,
|
||||
default: "00000000-0000-0000-0000-000000000000",
|
||||
})
|
||||
directorId: string;
|
||||
|
||||
@Column({
|
||||
comment: "Id การทำรายการระบบประเมิน",
|
||||
length: 40,
|
||||
default: "00000000-0000-0000-0000-000000000000",
|
||||
})
|
||||
evaluationId: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "หน้าที่",
|
||||
default: null,
|
||||
})
|
||||
duty: string;
|
||||
|
||||
@ManyToOne(() => Director, (Director) => Director.evaluation_directors_director)
|
||||
@JoinColumn({ name: "directorId" })
|
||||
director: Director;
|
||||
|
||||
@ManyToOne(() => Evaluation, (Evaluation) => Evaluation.evaluation_directors_director)
|
||||
@JoinColumn({ name: "evaluationId" })
|
||||
evaluation: Evaluation;
|
||||
}
|
||||
20
src/migration/1749798550561-update30062025603.ts
Normal file
20
src/migration/1749798550561-update30062025603.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class Update300620256031749798550561 implements MigrationInterface {
|
||||
name = 'Update300620256031749798550561'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE TABLE \`evaluation_directors_director\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`directorId\` varchar(40) NOT NULL COMMENT 'Id การทำรายการระบบประเมิน' DEFAULT '00000000-0000-0000-0000-000000000000', \`evaluationId\` varchar(40) NOT NULL COMMENT 'Id การทำรายการระบบประเมิน' DEFAULT '00000000-0000-0000-0000-000000000000', \`duty\` varchar(255) NULL COMMENT 'หน้าที่', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`ALTER TABLE \`director\` DROP COLUMN \`duty\``);
|
||||
await queryRunner.query(`ALTER TABLE \`evaluation_directors_director\` ADD CONSTRAINT \`FK_a1b902762a4a2410a10b6728065\` FOREIGN KEY (\`directorId\`) REFERENCES \`director\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`evaluation_directors_director\` ADD CONSTRAINT \`FK_aee4e7f5076bf5ff10190ddb79b\` FOREIGN KEY (\`evaluationId\`) REFERENCES \`evaluation\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`evaluation_directors_director\` DROP FOREIGN KEY \`FK_aee4e7f5076bf5ff10190ddb79b\``);
|
||||
await queryRunner.query(`ALTER TABLE \`evaluation_directors_director\` DROP FOREIGN KEY \`FK_a1b902762a4a2410a10b6728065\``);
|
||||
await queryRunner.query(`ALTER TABLE \`director\` ADD \`duty\` varchar(255) NULL COMMENT 'หน้าที่'`);
|
||||
await queryRunner.query(`DROP TABLE \`evaluation_directors_director\``);
|
||||
}
|
||||
|
||||
}
|
||||
14
src/migration/1749811430532-add_field_assignedPosLevel.ts
Normal file
14
src/migration/1749811430532-add_field_assignedPosLevel.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddFieldAssignedPosLevel1749811430532 implements MigrationInterface {
|
||||
name = 'AddFieldAssignedPosLevel1749811430532'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`assignedPosLevel\` varchar(255) NULL COMMENT 'ระดับที่ได้รับมอบหมาย'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`assignedPosLevel\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue