fixing response option skill & knowlage
This commit is contained in:
parent
fd76c6ee09
commit
78be6d81b2
1 changed files with 111 additions and 69 deletions
|
|
@ -50,13 +50,11 @@ export class DataOptionController extends Controller {
|
||||||
where: { personal_id },
|
where: { personal_id },
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(person);
|
|
||||||
|
|
||||||
if (!person) {
|
if (!person) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await this.mapKnowledgeSkillRepository.findOne({
|
let result = await this.mapKnowledgeSkillRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
positionName: person.positionName,
|
positionName: person.positionName,
|
||||||
positionLevelName: person.positionLevelName,
|
positionLevelName: person.positionLevelName,
|
||||||
|
|
@ -65,7 +63,17 @@ export class DataOptionController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
// ถ้าตำแหน่งไม่ตรงหาจากระดับตำแหน่งแทนเพื่อให้ฟอร์มสามารถกรอกต่อได้
|
||||||
|
result = await this.mapKnowledgeSkillRepository.findOne({
|
||||||
|
where: {
|
||||||
|
positionLevelName: person.positionLevelName,
|
||||||
|
active: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลความรู้ที่ตรงกับตำแหน่ง");
|
||||||
}
|
}
|
||||||
|
|
||||||
const knowledges = await this.knowledgeRepository.find({
|
const knowledges = await this.knowledgeRepository.find({
|
||||||
|
|
@ -107,7 +115,7 @@ export class DataOptionController extends Controller {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await this.mapKnowledgeSkillRepository.findOne({
|
let result = await this.mapKnowledgeSkillRepository.findOne({
|
||||||
select: [
|
select: [
|
||||||
"skill_computer_level",
|
"skill_computer_level",
|
||||||
"skill_english_level",
|
"skill_english_level",
|
||||||
|
|
@ -122,90 +130,124 @@ export class DataOptionController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
// ถ้าตำแหน่งไม่ตรงหาจากระดับตำแหน่งแทนเพื่อให้ฟอร์มสามารถกรอกต่อได้
|
||||||
|
result = await this.mapKnowledgeSkillRepository.findOne({
|
||||||
|
select: [
|
||||||
|
"skill_computer_level",
|
||||||
|
"skill_english_level",
|
||||||
|
"skill_information_level",
|
||||||
|
"skill_resourse_level",
|
||||||
|
],
|
||||||
|
where: {
|
||||||
|
positionLevelName: person.positionLevelName,
|
||||||
|
active: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะที่ตรงกับตำแหน่ง");
|
||||||
|
}
|
||||||
|
|
||||||
|
const computerData = await this.skillRepository.findOne({
|
||||||
|
where: { type: TypeSkill.COMPUTER, active: 1 },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!computerData) {
|
||||||
|
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะคอมพิวเตอร์");
|
||||||
|
}
|
||||||
|
const computer = await {
|
||||||
|
id: computerData.id,
|
||||||
|
title: computerData.title,
|
||||||
|
level_description:
|
||||||
|
result.skill_computer_level == 1
|
||||||
|
? computerData.level1
|
||||||
|
: result.skill_computer_level == 2
|
||||||
|
? computerData.level2
|
||||||
|
: result.skill_computer_level == 3
|
||||||
|
? computerData.level3
|
||||||
|
: result.skill_computer_level == 4
|
||||||
|
? computerData.level4
|
||||||
|
: computerData.level5,
|
||||||
|
level: result.skill_computer_level,
|
||||||
|
};
|
||||||
|
|
||||||
|
const englishData = await this.skillRepository.findOne({
|
||||||
|
where: { type: TypeSkill.ENG, active: 1 },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!englishData) {
|
||||||
|
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะภาษาอังกฤษ");
|
||||||
|
}
|
||||||
|
|
||||||
|
const english = await {
|
||||||
|
id: englishData.id,
|
||||||
|
title: englishData.title,
|
||||||
|
level_description:
|
||||||
|
result.skill_english_level == 1
|
||||||
|
? englishData.level1
|
||||||
|
: result.skill_english_level == 2
|
||||||
|
? englishData.level2
|
||||||
|
: result.skill_english_level == 3
|
||||||
|
? englishData.level3
|
||||||
|
: result.skill_english_level == 4
|
||||||
|
? englishData.level4
|
||||||
|
: englishData.level5,
|
||||||
|
level: result.skill_english_level,
|
||||||
|
};
|
||||||
|
|
||||||
|
const informationData = await this.skillRepository.findOne({
|
||||||
|
where: { type: TypeSkill.INFORMATION, active: 1 },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!informationData) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const skills = await this.skillRepository.find({
|
const information = await {
|
||||||
where: { type: TypeSkill.COMPUTER, active: 1 },
|
id: informationData.id,
|
||||||
});
|
title: informationData.title,
|
||||||
const skill = await skills.map((v) => ({
|
|
||||||
id: v.id,
|
|
||||||
title: v.title,
|
|
||||||
level_description:
|
|
||||||
result.skill_english_level == 1
|
|
||||||
? v.level1
|
|
||||||
: result.skill_english_level == 2
|
|
||||||
? v.level2
|
|
||||||
: result.skill_english_level == 3
|
|
||||||
? v.level3
|
|
||||||
: result.skill_english_level == 4
|
|
||||||
? v.level4
|
|
||||||
: v.level5,
|
|
||||||
level: result.skill_english_level,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const englishs = await this.skillRepository.find({
|
|
||||||
where: { type: TypeSkill.ENG, active: 1 },
|
|
||||||
});
|
|
||||||
const english = await englishs.map((v) => ({
|
|
||||||
id: v.id,
|
|
||||||
title: v.title,
|
|
||||||
level_description:
|
|
||||||
result.skill_english_level == 1
|
|
||||||
? v.level1
|
|
||||||
: result.skill_english_level == 2
|
|
||||||
? v.level2
|
|
||||||
: result.skill_english_level == 3
|
|
||||||
? v.level3
|
|
||||||
: result.skill_english_level == 4
|
|
||||||
? v.level4
|
|
||||||
: v.level5,
|
|
||||||
level: result.skill_english_level,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const informations = await this.skillRepository.find({
|
|
||||||
where: { type: TypeSkill.INFORMATION, active: 1 },
|
|
||||||
});
|
|
||||||
const information = await informations.map((v) => ({
|
|
||||||
id: v.id,
|
|
||||||
title: v.title,
|
|
||||||
level_description:
|
level_description:
|
||||||
result.skill_information_level == 1
|
result.skill_information_level == 1
|
||||||
? v.level1
|
? informationData.level1
|
||||||
: result.skill_information_level == 2
|
: result.skill_information_level == 2
|
||||||
? v.level2
|
? informationData.level2
|
||||||
: result.skill_information_level == 3
|
: result.skill_information_level == 3
|
||||||
? v.level3
|
? informationData.level3
|
||||||
: result.skill_information_level == 4
|
: result.skill_information_level == 4
|
||||||
? v.level4
|
? informationData.level4
|
||||||
: v.level5,
|
: informationData.level5,
|
||||||
level: result.skill_information_level,
|
level: result.skill_information_level,
|
||||||
}));
|
};
|
||||||
|
|
||||||
const resourses = await this.skillRepository.find({
|
const resourseData = await this.skillRepository.findOne({
|
||||||
where: { type: TypeSkill.RESOURSE, active: 1 },
|
where: { type: TypeSkill.RESOURSE, active: 1 },
|
||||||
});
|
});
|
||||||
const resourse = await resourses.map((v) => ({
|
if (!resourseData) {
|
||||||
id: v.id,
|
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
title: v.title,
|
}
|
||||||
|
|
||||||
|
const resourse = await {
|
||||||
|
id: resourseData.id,
|
||||||
|
title: resourseData.title,
|
||||||
level_description:
|
level_description:
|
||||||
result.skill_resourse_level == 1
|
result.skill_resourse_level == 1
|
||||||
? v.level1
|
? resourseData.level1
|
||||||
: result.skill_resourse_level == 2
|
: result.skill_resourse_level == 2
|
||||||
? v.level2
|
? resourseData.level2
|
||||||
: result.skill_resourse_level == 3
|
: result.skill_resourse_level == 3
|
||||||
? v.level3
|
? resourseData.level3
|
||||||
: result.skill_resourse_level == 4
|
: result.skill_resourse_level == 4
|
||||||
? v.level4
|
? resourseData.level4
|
||||||
: v.level5,
|
: resourseData.level5,
|
||||||
level: result.skill_resourse_level,
|
level: result.skill_resourse_level,
|
||||||
}));
|
};
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
computer: skill,
|
computer,
|
||||||
english: english,
|
english,
|
||||||
information: information,
|
information,
|
||||||
resourse: resourse,
|
resourse,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue