fixing throw HttpError

This commit is contained in:
Warunee Tamkoo 2024-09-06 09:37:29 +07:00
parent 78be6d81b2
commit 0e54b8b880
8 changed files with 90 additions and 90 deletions

View file

@ -72,7 +72,7 @@ export class AssignController extends Controller {
}); });
if (!person) { if (!person) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
} }
const roundNo = await this.assignRepository.count({ const roundNo = await this.assignRepository.count({
@ -231,7 +231,7 @@ export class AssignController extends Controller {
let before = assign; let before = assign;
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
} }
const person = await this.personalRepository.findOne({ const person = await this.personalRepository.findOne({
@ -241,7 +241,7 @@ export class AssignController extends Controller {
}); });
if (!person) { if (!person) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
} }
const data: any = { const data: any = {
@ -511,7 +511,7 @@ export class AssignController extends Controller {
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
} }
const profileData = await this.personalRepository.findOne({ const profileData = await this.personalRepository.findOne({
@ -532,7 +532,7 @@ export class AssignController extends Controller {
}); });
if (!profileData) { if (!profileData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
} }
const profile = { const profile = {

View file

@ -51,7 +51,7 @@ export class DataOptionController extends Controller {
}); });
if (!person) { if (!person) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
} }
let result = await this.mapKnowledgeSkillRepository.findOne({ let result = await this.mapKnowledgeSkillRepository.findOne({
@ -73,7 +73,7 @@ export class DataOptionController extends Controller {
} }
if (!result) { if (!result) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลความรู้ที่ตรงกับตำแหน่ง"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลความรู้ที่ตรงกับตำแหน่ง");
} }
const knowledges = await this.knowledgeRepository.find({ const knowledges = await this.knowledgeRepository.find({
@ -112,7 +112,7 @@ export class DataOptionController extends Controller {
}); });
if (!person) { if (!person) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
let result = await this.mapKnowledgeSkillRepository.findOne({ let result = await this.mapKnowledgeSkillRepository.findOne({
@ -146,7 +146,7 @@ export class DataOptionController extends Controller {
} }
if (!result) { if (!result) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะที่ตรงกับตำแหน่ง"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะที่ตรงกับตำแหน่ง");
} }
const computerData = await this.skillRepository.findOne({ const computerData = await this.skillRepository.findOne({
@ -154,7 +154,7 @@ export class DataOptionController extends Controller {
}); });
if (!computerData) { if (!computerData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะคอมพิวเตอร์"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะคอมพิวเตอร์");
} }
const computer = await { const computer = await {
id: computerData.id, id: computerData.id,
@ -177,7 +177,7 @@ export class DataOptionController extends Controller {
}); });
if (!englishData) { if (!englishData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะภาษาอังกฤษ"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะภาษาอังกฤษ");
} }
const english = await { const english = await {
@ -201,7 +201,7 @@ export class DataOptionController extends Controller {
}); });
if (!informationData) { if (!informationData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const information = await { const information = await {
@ -224,7 +224,7 @@ export class DataOptionController extends Controller {
where: { type: TypeSkill.RESOURSE, active: 1 }, where: { type: TypeSkill.RESOURSE, active: 1 },
}); });
if (!resourseData) { if (!resourseData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const resourse = await { const resourse = await {
@ -267,7 +267,7 @@ export class DataOptionController extends Controller {
}); });
if (!results) { if (!results) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const result = await results.map((v) => ({ const result = await results.map((v) => ({
@ -306,7 +306,7 @@ export class DataOptionController extends Controller {
}); });
if (!person) { if (!person) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const assign = await this.assignRepository.count({ const assign = await this.assignRepository.count({

View file

@ -54,7 +54,7 @@ export class EvaluateChairmanController extends Controller {
}, },
}); });
if (!director) { if (!director) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
} }
const director_id = director.personal_id; const director_id = director.personal_id;
@ -63,7 +63,7 @@ export class EvaluateChairmanController extends Controller {
where: { id: assign_id }, where: { id: assign_id },
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
} }
const profile = await (assign.profile const profile = await (assign.profile
@ -93,7 +93,7 @@ export class EvaluateChairmanController extends Controller {
}); });
if (!directorData) { if (!directorData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
} }
let mentors = ""; let mentors = "";
@ -143,7 +143,7 @@ export class EvaluateChairmanController extends Controller {
}, },
}); });
if (!director) { if (!director) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
} }
const director_id = director.personal_id; const director_id = director.personal_id;
let evaluate: any = null; let evaluate: any = null;
@ -165,14 +165,14 @@ export class EvaluateChairmanController extends Controller {
} }
if (!evaluate) { if (!evaluate) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน");
} }
const assign = await this.assignRepository.findOne({ const assign = await this.assignRepository.findOne({
where: { id: assign_id }, where: { id: assign_id },
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
} }
const experimenteeData = await this.personalRepository.find({ const experimenteeData = await this.personalRepository.find({
@ -199,7 +199,7 @@ export class EvaluateChairmanController extends Controller {
}); });
if (!directorData) { if (!directorData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
} }
let mentors = ""; let mentors = "";
@ -250,7 +250,7 @@ export class EvaluateChairmanController extends Controller {
}, },
}); });
if (!director) { if (!director) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
} }
const director_id = director.personal_id; const director_id = director.personal_id;
@ -260,7 +260,7 @@ export class EvaluateChairmanController extends Controller {
where: { id: assign_id }, where: { id: assign_id },
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
} }
const postData: any = await { const postData: any = await {
@ -335,7 +335,7 @@ export class EvaluateChairmanController extends Controller {
const before = evaluate; const before = evaluate;
if (!evaluate) { if (!evaluate) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
} }
evaluate.chairman_dated = requestBody.chairman_dated; evaluate.chairman_dated = requestBody.chairman_dated;

View file

@ -54,7 +54,7 @@ export class EvaluateController extends Controller {
}, },
}); });
if (!director) { if (!director) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
} }
const director_id = director.personal_id; const director_id = director.personal_id;
@ -63,7 +63,7 @@ export class EvaluateController extends Controller {
where: { id: assign_id }, where: { id: assign_id },
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
} }
const profile = await (assign.profile const profile = await (assign.profile
@ -126,7 +126,7 @@ export class EvaluateController extends Controller {
}, },
}); });
if (!director) { if (!director) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
} }
const director_id = director.personal_id; const director_id = director.personal_id;
let evaluate: any = null; let evaluate: any = null;
@ -148,14 +148,14 @@ export class EvaluateController extends Controller {
} }
if (!evaluate) { if (!evaluate) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน");
} }
const assign = await this.assignRepository.findOne({ const assign = await this.assignRepository.findOne({
where: { id: assign_id }, where: { id: assign_id },
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
} }
// const profile = await (assign.profile // const profile = await (assign.profile
@ -241,7 +241,7 @@ export class EvaluateController extends Controller {
}, },
}); });
if (!director) { if (!director) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
} }
const director_id = director.personal_id; const director_id = director.personal_id;
@ -251,7 +251,7 @@ export class EvaluateController extends Controller {
where: { id: assign_id }, where: { id: assign_id },
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
} }
const postData: any = await { const postData: any = await {
@ -326,7 +326,7 @@ export class EvaluateController extends Controller {
const before = evaluate; const before = evaluate;
if (!evaluate) { if (!evaluate) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
} }
evaluate.commander_dated = requestBody.commander_dated; evaluate.commander_dated = requestBody.commander_dated;

View file

@ -59,7 +59,7 @@ export class EvaluateRecordController extends Controller {
}); });
if (!directorData) { if (!directorData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const director = await { const director = await {
@ -77,7 +77,7 @@ export class EvaluateRecordController extends Controller {
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
} }
const profileData = await this.personalRepository.findOne({ const profileData = await this.personalRepository.findOne({
@ -95,7 +95,7 @@ export class EvaluateRecordController extends Controller {
}, },
}); });
if (!profileData) { if (!profileData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
} }
const profile = await { const profile = await {
@ -132,7 +132,7 @@ export class EvaluateRecordController extends Controller {
}); });
if (!commanderData) { if (!commanderData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้บังคับบัญชา"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้บังคับบัญชา");
} }
const commander = await { const commander = await {
@ -168,7 +168,7 @@ export class EvaluateRecordController extends Controller {
}, },
}); });
if (!director) { if (!director) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
} }
const director_id = director.personal_id; const director_id = director.personal_id;
@ -185,7 +185,7 @@ export class EvaluateRecordController extends Controller {
}); });
if (!evaluate) { if (!evaluate) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน");
} }
const achievementData = await this.evaluateAchievementRepository.find({ const achievementData = await this.evaluateAchievementRepository.find({
@ -196,7 +196,7 @@ export class EvaluateRecordController extends Controller {
order: { output_id: "ASC" }, order: { output_id: "ASC" },
}); });
if (!achievementData) { if (!achievementData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const achievements = await achievementData.map((achievement) => { const achievements = await achievementData.map((achievement) => {
@ -258,7 +258,7 @@ export class EvaluateRecordController extends Controller {
}); });
if (!evaluate) { if (!evaluate) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
await Promise.all( await Promise.all(
@ -336,7 +336,7 @@ export class EvaluateRecordController extends Controller {
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
} }
const experimenteeData = await this.personalRepository.find({ const experimenteeData = await this.personalRepository.find({
@ -397,7 +397,7 @@ export class EvaluateRecordController extends Controller {
}, },
}); });
if (!director) { if (!director) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
} }
const director_id = director.personal_id; const director_id = director.personal_id;
@ -407,7 +407,7 @@ export class EvaluateRecordController extends Controller {
where: { id: assign_id }, where: { id: assign_id },
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
} }
const postData: any = await { const postData: any = await {
@ -513,7 +513,7 @@ export class EvaluateRecordController extends Controller {
}, },
}); });
if (!director) { if (!director) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
} }
const director_id = director.personal_id; const director_id = director.personal_id;
@ -525,7 +525,7 @@ export class EvaluateRecordController extends Controller {
const before = evaluate; const before = evaluate;
if (!evaluate) { if (!evaluate) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
} }
evaluate.assessor_dated = requestBody.assessor_dated; evaluate.assessor_dated = requestBody.assessor_dated;
@ -618,7 +618,7 @@ export class EvaluateRecordController extends Controller {
}); });
if (!directorData) { if (!directorData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const director = await { const director = await {
@ -636,7 +636,7 @@ export class EvaluateRecordController extends Controller {
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
} }
const profileData = await this.personalRepository.findOne({ const profileData = await this.personalRepository.findOne({
@ -654,7 +654,7 @@ export class EvaluateRecordController extends Controller {
}, },
}); });
if (!profileData) { if (!profileData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
} }
const profile = await { const profile = await {
@ -712,7 +712,7 @@ export class EvaluateRecordController extends Controller {
}, },
}); });
if (!director) { if (!director) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
} }
const director_id = director.personal_id; const director_id = director.personal_id;
@ -729,7 +729,7 @@ export class EvaluateRecordController extends Controller {
}); });
if (!evaluate) { if (!evaluate) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน");
} }
const achievementData = await this.evaluateAchievementRepository.find({ const achievementData = await this.evaluateAchievementRepository.find({
@ -740,7 +740,7 @@ export class EvaluateRecordController extends Controller {
order: { output_id: "ASC" }, order: { output_id: "ASC" },
}); });
if (!achievementData) { if (!achievementData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const achievements = await achievementData.map((achievement) => { const achievements = await achievementData.map((achievement) => {
@ -802,7 +802,7 @@ export class EvaluateRecordController extends Controller {
}); });
if (!evaluate) { if (!evaluate) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
await Promise.all( await Promise.all(
@ -880,7 +880,7 @@ export class EvaluateRecordController extends Controller {
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
} }
const experimenteeData = await this.personalRepository.find({ const experimenteeData = await this.personalRepository.find({
@ -941,7 +941,7 @@ export class EvaluateRecordController extends Controller {
}, },
}); });
if (!director) { if (!director) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
} }
const director_id = director.personal_id; const director_id = director.personal_id;
@ -951,7 +951,7 @@ export class EvaluateRecordController extends Controller {
where: { id: assign_id }, where: { id: assign_id },
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
} }
const postData: any = await { const postData: any = await {
@ -1054,7 +1054,7 @@ export class EvaluateRecordController extends Controller {
}, },
}); });
if (!director) { if (!director) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
} }
const director_id = director.personal_id; const director_id = director.personal_id;
@ -1064,7 +1064,7 @@ export class EvaluateRecordController extends Controller {
}); });
if (!evaluate) { if (!evaluate) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
} }
const before = evaluate; const before = evaluate;

View file

@ -53,7 +53,7 @@ export class EvaluateResultController extends Controller {
where: { id: assign_id }, where: { id: assign_id },
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
} }
const profile = await (assign.profile const profile = await (assign.profile
@ -71,7 +71,7 @@ export class EvaluateResultController extends Controller {
}); });
if (!directorData) { if (!directorData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
} }
let mentors = ""; let mentors = "";
@ -105,7 +105,7 @@ export class EvaluateResultController extends Controller {
}); });
if (!resultData) { if (!resultData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมินผล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมินผล");
} }
const develop_complete = await (resultData.develop_orientation_score > 0 && const develop_complete = await (resultData.develop_orientation_score > 0 &&
@ -148,7 +148,7 @@ export class EvaluateResultController extends Controller {
}, },
}); });
if (!director) { if (!director) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
} }
const director_id = director.personal_id; const director_id = director.personal_id;
@ -160,14 +160,14 @@ export class EvaluateResultController extends Controller {
}); });
if (!evaluate) { if (!evaluate) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน");
} }
const assign = await this.assignRepository.findOne({ const assign = await this.assignRepository.findOne({
where: { id: assign_id }, where: { id: assign_id },
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
} }
const experimenteeData = await this.personalRepository.find({ const experimenteeData = await this.personalRepository.find({
@ -194,7 +194,7 @@ export class EvaluateResultController extends Controller {
}); });
if (!directorData) { if (!directorData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
} }
let mentors = ""; let mentors = "";
@ -245,7 +245,7 @@ export class EvaluateResultController extends Controller {
}, },
}); });
if (!director) { if (!director) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
} }
const director_id = director.personal_id; const director_id = director.personal_id;
@ -255,7 +255,7 @@ export class EvaluateResultController extends Controller {
where: { id: assign_id }, where: { id: assign_id },
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
} }
const postData: any = await { const postData: any = await {
@ -283,7 +283,7 @@ export class EvaluateResultController extends Controller {
}); });
if (!personal) { if (!personal) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
} }
personal.probation_status = personal.probation_status =
requestBody.pass_result == 1 requestBody.pass_result == 1
@ -335,7 +335,7 @@ export class EvaluateResultController extends Controller {
const before = evaluate; const before = evaluate;
if (!evaluate) { if (!evaluate) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
} }
evaluate.date_start = requestBody.start_date; evaluate.date_start = requestBody.start_date;
@ -359,14 +359,14 @@ export class EvaluateResultController extends Controller {
where: { id: assign_id }, where: { id: assign_id },
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
} }
const personal = await this.personalRepository.findOne({ const personal = await this.personalRepository.findOne({
where: { personal_id: assign.personal_id }, where: { personal_id: assign.personal_id },
}); });
if (!personal) { if (!personal) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
} }
personal.probation_status = personal.probation_status =
requestBody.pass_result == 1 requestBody.pass_result == 1

View file

@ -47,7 +47,7 @@ export class PersonalController extends Controller {
where: { personal_id: requestBody.id }, where: { personal_id: requestBody.id },
}); });
if (checkPersonal > 0) { if (checkPersonal > 0) {
return new HttpError(HttpStatusCode.BAD_REQUEST, "ผู้ทดลองปฏิบัติหน้าที่ราชการนี้มีอยู่แล้ว"); throw new HttpError(HttpStatusCode.BAD_REQUEST, "ผู้ทดลองปฏิบัติหน้าที่ราชการนี้มีอยู่แล้ว");
} }
let organization = await (requestBody.orgChild4Name ? requestBody.orgChild4Name + "/" : ""); let organization = await (requestBody.orgChild4Name ? requestBody.orgChild4Name + "/" : "");
@ -100,7 +100,7 @@ export class PersonalController extends Controller {
}); });
if (!lists) { if (!lists) {
return new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ไม่สามารถแสดงข้อมูลได้"); throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ไม่สามารถแสดงข้อมูลได้");
} }
let result: any = []; let result: any = [];
@ -143,7 +143,7 @@ export class PersonalController extends Controller {
}); });
if (!person) { if (!person) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
} }
const probation_no = await this.assignRepository.count({ const probation_no = await this.assignRepository.count({

View file

@ -61,7 +61,7 @@ export class ReportController extends Controller {
}); });
if (!evaluate || !result) { if (!evaluate || !result) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผลการทดลองปฏิบัติราชการ"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผลการทดลองปฏิบัติราชการ");
} }
const develop_total_score = await (Number(evaluate.develop_orientation_score) + const develop_total_score = await (Number(evaluate.develop_orientation_score) +
@ -205,7 +205,7 @@ export class ReportController extends Controller {
const before = personal; const before = personal;
if (!personal) { if (!personal) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
} }
personal.order_number = requestBody.command_no; personal.order_number = requestBody.command_no;
@ -256,7 +256,7 @@ export class ReportController extends Controller {
const before = personal; const before = personal;
if (!personal) { if (!personal) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
} }
personal.probation_status = await reqBody.status; personal.probation_status = await reqBody.status;
@ -282,7 +282,7 @@ export class ReportController extends Controller {
}); });
if (!evaluate) { if (!evaluate) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const directorData = await this.assignDirectorRepository.findOne({ const directorData = await this.assignDirectorRepository.findOne({
@ -291,7 +291,7 @@ export class ReportController extends Controller {
}); });
if (!directorData) { if (!directorData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const director = await { const director = await {
@ -306,7 +306,7 @@ export class ReportController extends Controller {
}); });
if (!achievements) { if (!achievements) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
let achievement: any = []; let achievement: any = [];
@ -516,7 +516,7 @@ export class ReportController extends Controller {
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const experimenteeData = await this.personalRepository.findOne({ const experimenteeData = await this.personalRepository.findOne({
@ -526,7 +526,7 @@ export class ReportController extends Controller {
}); });
if (!experimenteeData) { if (!experimenteeData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const experimentee = await { const experimentee = await {
@ -562,7 +562,7 @@ export class ReportController extends Controller {
}); });
if (!evaluate) { if (!evaluate) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const evaluateData = await { const evaluateData = await {
@ -747,7 +747,7 @@ export class ReportController extends Controller {
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const experimenteeData = await this.personalRepository.findOne({ const experimenteeData = await this.personalRepository.findOne({
@ -757,7 +757,7 @@ export class ReportController extends Controller {
}); });
if (!experimenteeData) { if (!experimenteeData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const experimentee = await { const experimentee = await {
@ -786,7 +786,7 @@ export class ReportController extends Controller {
}); });
if (!commanderData) { if (!commanderData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const commander = await { const commander = await {
@ -816,7 +816,7 @@ export class ReportController extends Controller {
}); });
if (!evaluate) { if (!evaluate) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const develop_total_score = await (Number(evaluate.develop_orientation_score) + const develop_total_score = await (Number(evaluate.develop_orientation_score) +
@ -1011,7 +1011,7 @@ export class ReportController extends Controller {
}); });
if (!assign) { if (!assign) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const experimenteeData = await this.personalRepository.findOne({ const experimenteeData = await this.personalRepository.findOne({
@ -1021,7 +1021,7 @@ export class ReportController extends Controller {
}); });
if (!experimenteeData) { if (!experimenteeData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const experimentee = await { const experimentee = await {
@ -1041,7 +1041,7 @@ export class ReportController extends Controller {
}); });
if (!directorData) { if (!directorData) {
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const director = await Promise.all( const director = await Promise.all(