updated api after test connect frontend
This commit is contained in:
parent
4b55b8cf20
commit
b48df26505
10 changed files with 275 additions and 73 deletions
|
|
@ -68,29 +68,70 @@ export class EvaluateResultController extends Controller {
|
|||
|
||||
const directorData = await this.assignDirectorRepository.find({
|
||||
where: { assign_id },
|
||||
order: { ordering: "ASC" },
|
||||
});
|
||||
|
||||
if (!directorData) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
|
||||
}
|
||||
|
||||
let mentors = "";
|
||||
let mentors = [];
|
||||
const mentorList = await directorData.filter((x) => x.role == "mentor");
|
||||
if (mentorList.length > 0) {
|
||||
for (let index = 0; index < mentorList.length; index++) {
|
||||
const e = await mentorList[index];
|
||||
mentors += e.fullname;
|
||||
if (index < mentorList.length - 1) {
|
||||
mentors += ", ";
|
||||
}
|
||||
|
||||
mentors.push({
|
||||
personal_id: e.personal_id,
|
||||
dated: e.dated,
|
||||
name: e.fullname,
|
||||
label:
|
||||
e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
||||
position: e.position,
|
||||
posType: e.posType,
|
||||
posLevel: e.posLevel,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const commanderData = await (directorData.find((x) => x.role == "commander") ?? null);
|
||||
const commander = commanderData ? commanderData.fullname : null;
|
||||
|
||||
const commander =
|
||||
commanderData != null
|
||||
? {
|
||||
personal_id: commanderData.personal_id,
|
||||
dated: commanderData.dated,
|
||||
name: commanderData.fullname,
|
||||
label:
|
||||
commanderData.fullname +
|
||||
" " +
|
||||
(commanderData.position
|
||||
? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`
|
||||
: ""),
|
||||
position: commanderData.position,
|
||||
posType: commanderData.posType,
|
||||
posLevel: commanderData.posLevel,
|
||||
}
|
||||
: null;
|
||||
|
||||
const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null);
|
||||
const chairman = chairmanData ? chairmanData.fullname : null;
|
||||
const chairman =
|
||||
chairmanData != null
|
||||
? {
|
||||
personal_id: chairmanData.personal_id,
|
||||
dated: chairmanData.dated,
|
||||
name: chairmanData.fullname,
|
||||
label:
|
||||
chairmanData.fullname +
|
||||
" " +
|
||||
(chairmanData.position
|
||||
? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})`
|
||||
: ""),
|
||||
position: chairmanData.position,
|
||||
posType: chairmanData.posType,
|
||||
posLevel: chairmanData.posLevel,
|
||||
}
|
||||
: null;
|
||||
|
||||
const resultData = await this.evaluateChairmanRepository.findOne({
|
||||
select: [
|
||||
|
|
@ -152,7 +193,7 @@ export class EvaluateResultController extends Controller {
|
|||
}
|
||||
const director_id = director.personal_id;
|
||||
|
||||
const evaluate = await this.evaluateChairmanRepository.findOne({
|
||||
const evaluate = await this.evaluateResultRepository.findOne({
|
||||
where: {
|
||||
director_id,
|
||||
assign_id,
|
||||
|
|
@ -160,7 +201,7 @@ export class EvaluateResultController extends Controller {
|
|||
});
|
||||
|
||||
if (!evaluate) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน");
|
||||
return new HttpSuccess(null);
|
||||
}
|
||||
|
||||
const assign = await this.assignRepository.findOne({
|
||||
|
|
@ -191,29 +232,70 @@ export class EvaluateResultController extends Controller {
|
|||
|
||||
const directorData = await this.assignDirectorRepository.find({
|
||||
where: { assign_id },
|
||||
order: { ordering: "ASC" },
|
||||
});
|
||||
|
||||
if (!directorData) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
|
||||
}
|
||||
|
||||
let mentors = "";
|
||||
let mentors = [];
|
||||
const mentorList = await directorData.filter((x) => x.role == "mentor");
|
||||
if (mentorList.length > 0) {
|
||||
for (let index = 0; index < mentorList.length; index++) {
|
||||
const e = await mentorList[index];
|
||||
mentors += e.fullname;
|
||||
if (index < mentorList.length - 1) {
|
||||
mentors += ", ";
|
||||
}
|
||||
|
||||
mentors.push({
|
||||
personal_id: e.personal_id,
|
||||
dated: e.dated,
|
||||
name: e.fullname,
|
||||
label:
|
||||
e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
||||
position: e.position,
|
||||
posType: e.posType,
|
||||
posLevel: e.posLevel,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const commanderData = await (directorData.find((x) => x.role == "commander") ?? null);
|
||||
const commander = commanderData ? commanderData.fullname : null;
|
||||
|
||||
const commander =
|
||||
commanderData != null
|
||||
? {
|
||||
personal_id: commanderData.personal_id,
|
||||
dated: commanderData.dated,
|
||||
name: commanderData.fullname,
|
||||
label:
|
||||
commanderData.fullname +
|
||||
" " +
|
||||
(commanderData.position
|
||||
? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`
|
||||
: ""),
|
||||
position: commanderData.position,
|
||||
posType: commanderData.posType,
|
||||
posLevel: commanderData.posLevel,
|
||||
}
|
||||
: null;
|
||||
|
||||
const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null);
|
||||
const chairman = chairmanData ? chairmanData.fullname : null;
|
||||
const chairman =
|
||||
chairmanData != null
|
||||
? {
|
||||
personal_id: chairmanData.personal_id,
|
||||
dated: chairmanData.dated,
|
||||
name: chairmanData.fullname,
|
||||
label:
|
||||
chairmanData.fullname +
|
||||
" " +
|
||||
(chairmanData.position
|
||||
? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})`
|
||||
: ""),
|
||||
position: chairmanData.position,
|
||||
posType: chairmanData.posType,
|
||||
posLevel: chairmanData.posLevel,
|
||||
}
|
||||
: null;
|
||||
|
||||
return new HttpSuccess({
|
||||
commander,
|
||||
|
|
@ -342,7 +424,10 @@ export class EvaluateResultController extends Controller {
|
|||
evaluate.date_finish = requestBody.date_finish;
|
||||
evaluate.develop_complete = requestBody.develop_complete;
|
||||
evaluate.pass_result = requestBody.pass_result;
|
||||
evaluate.expand_month = requestBody.pass_result == 3 ? requestBody.expand_month : 0;
|
||||
evaluate.expand_month =
|
||||
requestBody.pass_result && requestBody.pass_result == 3
|
||||
? Number(requestBody.expand_month)
|
||||
: 0;
|
||||
evaluate.reson = requestBody.reson;
|
||||
evaluate.chairman_dated = requestBody.chairman_dated;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue