trycatch
This commit is contained in:
parent
a4dfb3c87c
commit
df74e0226e
13 changed files with 7057 additions and 5877 deletions
|
|
@ -1,356 +1,432 @@
|
|||
import { Controller, Route, Security, Tags, Request, SuccessResponse, Response, Get, Query } from "tsoa"
|
||||
import { AppDataSource } from "../database/data-source"
|
||||
import HttpSuccess from "../interfaces/http-success"
|
||||
import HttpStatusCode from "../interfaces/http-status"
|
||||
import HttpError from "../interfaces/http-error"
|
||||
import { RequestWithUser } from "../middlewares/user"
|
||||
import { Knowledge, TypeKnowledge } from "../entities/Knowledge"
|
||||
import { Skill, TypeSkill } from "../entities/Skill"
|
||||
import { MapKnowledgeSkill } from "../entities/MapKnowledgeSkill"
|
||||
import { Personal } from "../entities/Personal"
|
||||
import { Law } from "../entities/Law"
|
||||
import { Assign } from "../entities/Assign"
|
||||
import permission from "../interfaces/permission"
|
||||
import {
|
||||
Controller,
|
||||
Route,
|
||||
Security,
|
||||
Tags,
|
||||
Request,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Get,
|
||||
Query,
|
||||
} from "tsoa";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Knowledge, TypeKnowledge } from "../entities/Knowledge";
|
||||
import { Skill, TypeSkill } from "../entities/Skill";
|
||||
import { MapKnowledgeSkill } from "../entities/MapKnowledgeSkill";
|
||||
import { Personal } from "../entities/Personal";
|
||||
import { Law } from "../entities/Law";
|
||||
import { Assign } from "../entities/Assign";
|
||||
import permission from "../interfaces/permission";
|
||||
|
||||
@Route("api/v1/probation/data-options")
|
||||
@Tags("Data Options")
|
||||
@Security("bearerAuth")
|
||||
@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง"
|
||||
)
|
||||
export class DataOptionController extends Controller {
|
||||
private personalRepository = AppDataSource.getRepository(Personal)
|
||||
private knowledgeRepository = AppDataSource.getRepository(Knowledge)
|
||||
private mapKnowledgeSkillRepository = AppDataSource.getRepository(MapKnowledgeSkill)
|
||||
private skillRepository = AppDataSource.getRepository(Skill)
|
||||
private lawRepository = AppDataSource.getRepository(Law)
|
||||
private assignRepository = AppDataSource.getRepository(Assign)
|
||||
private personalRepository = AppDataSource.getRepository(Personal);
|
||||
private knowledgeRepository = AppDataSource.getRepository(Knowledge);
|
||||
private mapKnowledgeSkillRepository =
|
||||
AppDataSource.getRepository(MapKnowledgeSkill);
|
||||
private skillRepository = AppDataSource.getRepository(Skill);
|
||||
private lawRepository = AppDataSource.getRepository(Law);
|
||||
private assignRepository = AppDataSource.getRepository(Assign);
|
||||
|
||||
/**
|
||||
* API list รายการความรู้
|
||||
*
|
||||
* @summary options ความรู้
|
||||
*
|
||||
*/
|
||||
@Get("knowledge")
|
||||
async GetKnowledge(@Query() personal_id: string) {
|
||||
const person = await this.personalRepository.findOne({
|
||||
where: { personal_id },
|
||||
})
|
||||
/**
|
||||
* API list รายการความรู้
|
||||
*
|
||||
* @summary options ความรู้
|
||||
*
|
||||
*/
|
||||
@Get("knowledge")
|
||||
async GetKnowledge(@Query() personal_id: string) {
|
||||
try {
|
||||
const person = await this.personalRepository.findOne({
|
||||
where: { personal_id },
|
||||
});
|
||||
|
||||
if (!person) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล")
|
||||
}
|
||||
if (!person) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
||||
}
|
||||
|
||||
let result = await this.mapKnowledgeSkillRepository.findOne({
|
||||
where: {
|
||||
positionName: person.positionName,
|
||||
positionLevelName: person.positionLevelName,
|
||||
active: 1,
|
||||
},
|
||||
})
|
||||
let result = await this.mapKnowledgeSkillRepository.findOne({
|
||||
where: {
|
||||
positionName: person.positionName,
|
||||
positionLevelName: person.positionLevelName,
|
||||
active: 1,
|
||||
},
|
||||
});
|
||||
|
||||
if (!result) {
|
||||
// ถ้าตำแหน่งไม่ตรงหาจากระดับตำแหน่งแทนเพื่อให้ฟอร์มสามารถกรอกต่อได้
|
||||
result = await this.mapKnowledgeSkillRepository.findOne({
|
||||
where: {
|
||||
positionLevelName: person.positionLevelName,
|
||||
active: 1,
|
||||
},
|
||||
})
|
||||
}
|
||||
if (!result) {
|
||||
// ถ้าตำแหน่งไม่ตรงหาจากระดับตำแหน่งแทนเพื่อให้ฟอร์มสามารถกรอกต่อได้
|
||||
result = await this.mapKnowledgeSkillRepository.findOne({
|
||||
where: {
|
||||
positionLevelName: person.positionLevelName,
|
||||
active: 1,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลความรู้ที่ตรงกับตำแหน่ง")
|
||||
}
|
||||
if (!result) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลความรู้ที่ตรงกับตำแหน่ง"
|
||||
);
|
||||
}
|
||||
|
||||
const knowledges = await this.knowledgeRepository.find({
|
||||
where: { type: TypeKnowledge.PERFORMANCE, active: 1 },
|
||||
})
|
||||
const knowledges = await this.knowledgeRepository.find({
|
||||
where: { type: TypeKnowledge.PERFORMANCE, active: 1 },
|
||||
});
|
||||
|
||||
const knowledge = knowledges.map(knowledge => ({
|
||||
id: knowledge.id,
|
||||
title: knowledge.title,
|
||||
description:
|
||||
result.knowlage_performance_level == 1
|
||||
? knowledge.level1
|
||||
: result.knowlage_performance_level == 2
|
||||
? knowledge.level2
|
||||
: result.knowlage_performance_level == 3
|
||||
? knowledge.level3
|
||||
: result.knowlage_performance_level == 4
|
||||
? knowledge.level4
|
||||
: knowledge.level5,
|
||||
level: result.knowlage_performance_level,
|
||||
}))
|
||||
const knowledge = knowledges.map((knowledge) => ({
|
||||
id: knowledge.id,
|
||||
title: knowledge.title,
|
||||
description:
|
||||
result.knowlage_performance_level == 1
|
||||
? knowledge.level1
|
||||
: result.knowlage_performance_level == 2
|
||||
? knowledge.level2
|
||||
: result.knowlage_performance_level == 3
|
||||
? knowledge.level3
|
||||
: result.knowlage_performance_level == 4
|
||||
? knowledge.level4
|
||||
: knowledge.level5,
|
||||
level: result.knowlage_performance_level,
|
||||
}));
|
||||
return new HttpSuccess(knowledge);
|
||||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
}
|
||||
}
|
||||
|
||||
return new HttpSuccess(knowledge)
|
||||
}
|
||||
/**
|
||||
* API ข้อมูลทักษะ
|
||||
*
|
||||
* @summary options ทักษะ
|
||||
*
|
||||
*/
|
||||
@Get("skill")
|
||||
async GetSkill(@Query() personal_id: string) {
|
||||
try {
|
||||
const person = await this.personalRepository.findOne({
|
||||
where: { personal_id },
|
||||
});
|
||||
|
||||
/**
|
||||
* API ข้อมูลทักษะ
|
||||
*
|
||||
* @summary options ทักษะ
|
||||
*
|
||||
*/
|
||||
@Get("skill")
|
||||
async GetSkill(@Query() personal_id: string) {
|
||||
const person = await this.personalRepository.findOne({
|
||||
where: { personal_id },
|
||||
})
|
||||
if (!person) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
if (!person) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||
}
|
||||
let result = await this.mapKnowledgeSkillRepository.findOne({
|
||||
select: [
|
||||
"skill_computer_level",
|
||||
"skill_english_level",
|
||||
"skill_information_level",
|
||||
"skill_resourse_level",
|
||||
],
|
||||
where: {
|
||||
positionName: person.positionName,
|
||||
positionLevelName: person.positionLevelName,
|
||||
active: 1,
|
||||
},
|
||||
});
|
||||
|
||||
let result = await this.mapKnowledgeSkillRepository.findOne({
|
||||
select: ["skill_computer_level", "skill_english_level", "skill_information_level", "skill_resourse_level"],
|
||||
where: {
|
||||
positionName: person.positionName,
|
||||
positionLevelName: person.positionLevelName,
|
||||
active: 1,
|
||||
},
|
||||
})
|
||||
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) {
|
||||
// ถ้าตำแหน่งไม่ตรงหาจากระดับตำแหน่งแทนเพื่อให้ฟอร์มสามารถกรอกต่อได้
|
||||
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) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลทักษะที่ตรงกับตำแหน่ง"
|
||||
);
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะที่ตรงกับตำแหน่ง")
|
||||
}
|
||||
const computerData = await this.skillRepository.findOne({
|
||||
where: { type: TypeSkill.COMPUTER, active: 1 },
|
||||
});
|
||||
|
||||
const computerData = await this.skillRepository.findOne({
|
||||
where: { type: TypeSkill.COMPUTER, active: 1 },
|
||||
})
|
||||
if (!computerData) {
|
||||
throw 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,
|
||||
};
|
||||
|
||||
if (!computerData) {
|
||||
throw 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 },
|
||||
});
|
||||
|
||||
const englishData = await this.skillRepository.findOne({
|
||||
where: { type: TypeSkill.ENG, active: 1 },
|
||||
})
|
||||
if (!englishData) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลทักษะภาษาอังกฤษ"
|
||||
);
|
||||
}
|
||||
|
||||
if (!englishData) {
|
||||
throw 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 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 },
|
||||
});
|
||||
|
||||
const informationData = await this.skillRepository.findOne({
|
||||
where: { type: TypeSkill.INFORMATION, active: 1 },
|
||||
})
|
||||
if (!informationData) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
if (!informationData) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||
}
|
||||
const information = await {
|
||||
id: informationData.id,
|
||||
title: informationData.title,
|
||||
level_description:
|
||||
result.skill_information_level == 1
|
||||
? informationData.level1
|
||||
: result.skill_information_level == 2
|
||||
? informationData.level2
|
||||
: result.skill_information_level == 3
|
||||
? informationData.level3
|
||||
: result.skill_information_level == 4
|
||||
? informationData.level4
|
||||
: informationData.level5,
|
||||
level: result.skill_information_level,
|
||||
};
|
||||
|
||||
const information = await {
|
||||
id: informationData.id,
|
||||
title: informationData.title,
|
||||
level_description:
|
||||
result.skill_information_level == 1
|
||||
? informationData.level1
|
||||
: result.skill_information_level == 2
|
||||
? informationData.level2
|
||||
: result.skill_information_level == 3
|
||||
? informationData.level3
|
||||
: result.skill_information_level == 4
|
||||
? informationData.level4
|
||||
: informationData.level5,
|
||||
level: result.skill_information_level,
|
||||
}
|
||||
const resourseData = await this.skillRepository.findOne({
|
||||
where: { type: TypeSkill.RESOURSE, active: 1 },
|
||||
});
|
||||
if (!resourseData) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
const resourseData = await this.skillRepository.findOne({
|
||||
where: { type: TypeSkill.RESOURSE, active: 1 },
|
||||
})
|
||||
if (!resourseData) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||
}
|
||||
const resourse = await {
|
||||
id: resourseData.id,
|
||||
title: resourseData.title,
|
||||
level_description:
|
||||
result.skill_resourse_level == 1
|
||||
? resourseData.level1
|
||||
: result.skill_resourse_level == 2
|
||||
? resourseData.level2
|
||||
: result.skill_resourse_level == 3
|
||||
? resourseData.level3
|
||||
: result.skill_resourse_level == 4
|
||||
? resourseData.level4
|
||||
: resourseData.level5,
|
||||
level: result.skill_resourse_level,
|
||||
};
|
||||
|
||||
const resourse = await {
|
||||
id: resourseData.id,
|
||||
title: resourseData.title,
|
||||
level_description:
|
||||
result.skill_resourse_level == 1
|
||||
? resourseData.level1
|
||||
: result.skill_resourse_level == 2
|
||||
? resourseData.level2
|
||||
: result.skill_resourse_level == 3
|
||||
? resourseData.level3
|
||||
: result.skill_resourse_level == 4
|
||||
? resourseData.level4
|
||||
: resourseData.level5,
|
||||
level: result.skill_resourse_level,
|
||||
}
|
||||
return new HttpSuccess({
|
||||
computer,
|
||||
english,
|
||||
information,
|
||||
resourse,
|
||||
});
|
||||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
}
|
||||
}
|
||||
|
||||
return new HttpSuccess({
|
||||
computer,
|
||||
english,
|
||||
information,
|
||||
resourse,
|
||||
})
|
||||
}
|
||||
/**
|
||||
* API list รายการกฎหมาย
|
||||
*
|
||||
* @summary options กฎหมาย
|
||||
*
|
||||
*/
|
||||
@Get("law")
|
||||
async GetLaw(@Query() personal_id: string) {
|
||||
try {
|
||||
const results = await this.lawRepository.find({
|
||||
select: ["id", "parent_id", "description", "status_select"],
|
||||
where: {
|
||||
active: 1,
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* API list รายการกฎหมาย
|
||||
*
|
||||
* @summary options กฎหมาย
|
||||
*
|
||||
*/
|
||||
@Get("law")
|
||||
async GetLaw(@Query() personal_id: string) {
|
||||
const results = await this.lawRepository.find({
|
||||
select: ["id", "parent_id", "description", "status_select"],
|
||||
where: {
|
||||
active: 1,
|
||||
},
|
||||
})
|
||||
if (!results) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
if (!results) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||
}
|
||||
const result = await results.map((v) => ({
|
||||
...v,
|
||||
checked: 0,
|
||||
}));
|
||||
|
||||
const result = await results.map(v => ({
|
||||
...v,
|
||||
checked: 0,
|
||||
}))
|
||||
return new HttpSuccess(result);
|
||||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
}
|
||||
}
|
||||
|
||||
return new HttpSuccess(result)
|
||||
}
|
||||
/**
|
||||
* API ดึงข้อมูลจำนวนครั้งแบบมอบหมายงานและข้อมูลผู้ทดลอง
|
||||
*
|
||||
* @summary จำนวนครั้งแบบมอบหมายงานและข้อมูลผู้ทดลอง
|
||||
*
|
||||
*/
|
||||
@Get("new-assign")
|
||||
async NewAssign(
|
||||
@Query() personal_id: string,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
try {
|
||||
let _workflow = await new permission().Workflow(
|
||||
request,
|
||||
personal_id,
|
||||
"SYS_PROBATION"
|
||||
);
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
|
||||
/**
|
||||
* API ดึงข้อมูลจำนวนครั้งแบบมอบหมายงานและข้อมูลผู้ทดลอง
|
||||
*
|
||||
* @summary จำนวนครั้งแบบมอบหมายงานและข้อมูลผู้ทดลอง
|
||||
*
|
||||
*/
|
||||
@Get("new-assign")
|
||||
async NewAssign(@Query() personal_id: string, @Request() request: RequestWithUser) {
|
||||
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({
|
||||
select: [
|
||||
"personal_id",
|
||||
"prefixName",
|
||||
"firstName",
|
||||
"lastName",
|
||||
"posNo",
|
||||
"positionName",
|
||||
"positionLevelName",
|
||||
"positionLineName",
|
||||
"isProbation",
|
||||
"orgRootName",
|
||||
"organization",
|
||||
"createdAt",
|
||||
"updatedAt",
|
||||
],
|
||||
where: { personal_id },
|
||||
});
|
||||
|
||||
const person = await this.personalRepository.findOne({
|
||||
select: [
|
||||
"personal_id",
|
||||
"prefixName",
|
||||
"firstName",
|
||||
"lastName",
|
||||
"posNo",
|
||||
"positionName",
|
||||
"positionLevelName",
|
||||
"positionLineName",
|
||||
"isProbation",
|
||||
"orgRootName",
|
||||
"organization",
|
||||
"createdAt",
|
||||
"updatedAt",
|
||||
],
|
||||
where: { personal_id },
|
||||
})
|
||||
if (!person) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
if (!person) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||
}
|
||||
const assign = await this.assignRepository.count({
|
||||
where: {
|
||||
personal_id,
|
||||
},
|
||||
});
|
||||
|
||||
const assign = await this.assignRepository.count({
|
||||
where: {
|
||||
personal_id,
|
||||
},
|
||||
})
|
||||
const responsePerson = {
|
||||
id: person.personal_id,
|
||||
...person,
|
||||
};
|
||||
|
||||
const responsePerson = {
|
||||
id: person.personal_id,
|
||||
...person,
|
||||
}
|
||||
return new HttpSuccess({
|
||||
person: responsePerson,
|
||||
assign_no: assign + 1,
|
||||
assign_month: 6,
|
||||
});
|
||||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* API ดึงข้อมูลจำนวนครั้งแบบมอบหมายงานและข้อมูลผู้ทดลอง (USER)
|
||||
*
|
||||
* @summary จำนวนครั้งแบบมอบหมายงานและข้อมูลผู้ทดลอง (USER)
|
||||
*
|
||||
*/
|
||||
@Get("new-assign-user")
|
||||
async NewAssignUser(
|
||||
@Query() personal_id: string,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
try {
|
||||
const person = await this.personalRepository.findOne({
|
||||
select: [
|
||||
"personal_id",
|
||||
"prefixName",
|
||||
"firstName",
|
||||
"lastName",
|
||||
"posNo",
|
||||
"positionName",
|
||||
"positionLevelName",
|
||||
"positionLineName",
|
||||
"isProbation",
|
||||
"orgRootName",
|
||||
"organization",
|
||||
"createdAt",
|
||||
"updatedAt",
|
||||
],
|
||||
where: { personal_id },
|
||||
});
|
||||
|
||||
return new HttpSuccess({
|
||||
person: responsePerson,
|
||||
assign_no: assign + 1,
|
||||
assign_month: 6,
|
||||
})
|
||||
}
|
||||
/**
|
||||
* API ดึงข้อมูลจำนวนครั้งแบบมอบหมายงานและข้อมูลผู้ทดลอง (USER)
|
||||
*
|
||||
* @summary จำนวนครั้งแบบมอบหมายงานและข้อมูลผู้ทดลอง (USER)
|
||||
*
|
||||
*/
|
||||
@Get("new-assign-user")
|
||||
async NewAssignUser(@Query() personal_id: string, @Request() request: RequestWithUser) {
|
||||
const person = await this.personalRepository.findOne({
|
||||
select: [
|
||||
"personal_id",
|
||||
"prefixName",
|
||||
"firstName",
|
||||
"lastName",
|
||||
"posNo",
|
||||
"positionName",
|
||||
"positionLevelName",
|
||||
"positionLineName",
|
||||
"isProbation",
|
||||
"orgRootName",
|
||||
"organization",
|
||||
"createdAt",
|
||||
"updatedAt",
|
||||
],
|
||||
where: { personal_id },
|
||||
})
|
||||
if (!person) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
if (!person) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||
}
|
||||
const assign = await this.assignRepository.count({
|
||||
where: {
|
||||
personal_id,
|
||||
},
|
||||
});
|
||||
|
||||
const assign = await this.assignRepository.count({
|
||||
where: {
|
||||
personal_id,
|
||||
},
|
||||
})
|
||||
const responsePerson = {
|
||||
id: person.personal_id,
|
||||
...person,
|
||||
};
|
||||
|
||||
const responsePerson = {
|
||||
id: person.personal_id,
|
||||
...person,
|
||||
}
|
||||
|
||||
return new HttpSuccess({
|
||||
person: responsePerson,
|
||||
assign_no: assign + 1,
|
||||
assign_month: 6,
|
||||
})
|
||||
}
|
||||
return new HttpSuccess({
|
||||
person: responsePerson,
|
||||
assign_no: assign + 1,
|
||||
assign_month: 6,
|
||||
});
|
||||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue