Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop

This commit is contained in:
Kittapath 2024-03-13 13:38:08 +07:00
commit 47c40f9b5f
3 changed files with 37 additions and 25 deletions

View file

@ -57,7 +57,7 @@ export class EmployeePosLevelController extends Controller {
where: { id: requestBody.employeePosTypeId }
});
if (!EmpPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทกลุ่มงานลูกจ้างประจำนี้");
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานลูกจ้างประจำนี้");
}
const chkEmpPosLevelName = await this.employeePosLevelRepository.findOne({
@ -102,7 +102,7 @@ export class EmployeePosLevelController extends Controller {
where: { id: requestBody.employeePosTypeId }
});
if (!EmpPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทกลุ่มงานลูกจ้างประจำนี้");
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานลูกจ้างประจำนี้");
}
const chkEmpPosLevel = await this.employeePosLevelRepository.findOne({
@ -163,14 +163,20 @@ export class EmployeePosLevelController extends Controller {
@Get("{id}")
async GetEmpLevelById(@Path() id: string) {
const getEmpPosLevel = await this.employeePosLevelRepository.findOne({
relations: ["employeePosType"],
select: ["id", "posLevelName", "posLevelRank",],
where: { id: id },
});
if (!getEmpPosLevel) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงานลูกจ้างประจำนี้");
}
return new HttpSuccess(getEmpPosLevel);
const mapEmpPosLevel = {
id: getEmpPosLevel.id,
posLevelName: getEmpPosLevel.posLevelName,
posTypeName: getEmpPosLevel.employeePosType == null ? null : getEmpPosLevel.employeePosType.posTypeName, //กลุ่มงาน
commander: null //ผู้มีอำนาจสั่งบรรจุ
}
return new HttpSuccess(mapEmpPosLevel);
}
/**
@ -182,9 +188,15 @@ export class EmployeePosLevelController extends Controller {
@Get()
async GetEmpPosLevel() {
const empPosLevel = await this.employeePosLevelRepository.find({
relations: ["employeePosType"],
select: ["id","posLevelName", "posLevelRank",],
});
return new HttpSuccess(empPosLevel);
const mapEmpPosLevel = empPosLevel.map((item) => ({
id: item.id,
posLevelName: item.posLevelName,
posTypeName: item.employeePosType == null ? null : item.employeePosType.posTypeName, //กลุ่มงาน
commander: null //ผู้มีอำนาจสั่งบรรจุ
}));
return new HttpSuccess(mapEmpPosLevel);
}
}

View file

@ -37,9 +37,9 @@ export class EmployeePosTypeController extends Controller {
private employeePosLevelRepository = AppDataSource.getRepository(EmployeePosLevel);
/**
* API
* API
*
* @summary ORG_ - (ADMIN) #
* @summary ORG_ - (ADMIN) #
*
*/
@Post()
@ -61,7 +61,7 @@ export class EmployeePosTypeController extends Controller {
if (chkEmpPosTypeName) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ชื่อประเภทกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว",
"ชื่อกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว",
);
}
EmpPosType.createdUserId = request.user.sub;
@ -73,11 +73,11 @@ export class EmployeePosTypeController extends Controller {
}
/**
* API
* API
*
* @summary ORG_ - (ADMIN) #
* @summary ORG_ - (ADMIN) #
*
* @param {string} id Id
* @param {string} id Id
*/
@Put("{id}")
async EditEmpType(
@ -87,7 +87,7 @@ export class EmployeePosTypeController extends Controller {
) {
const EmpPosType = await this.employeePosTypeRepository.findOne({ where: { id } });
if (!EmpPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทกลุ่มงานลูกจ้างประจำนี้");
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานลูกจ้างประจำนี้");
}
const chkEmpPosType = await this.employeePosTypeRepository.findOne({
where: {
@ -98,7 +98,7 @@ export class EmployeePosTypeController extends Controller {
if (chkEmpPosType) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ชื่อประเภทกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว",
"ชื่อกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว",
);
}
EmpPosType.lastUpdateUserId = request.user.sub;
@ -109,17 +109,17 @@ export class EmployeePosTypeController extends Controller {
}
/**
* API
* API
*
* @summary ORG_ - (ADMIN) #
* @summary ORG_ - (ADMIN) #
*
* @param {string} id Id
* @param {string} id Id
*/
@Delete("{id}")
async deleteType(@Path() id: string) {
const delEmpPosType = await this.employeePosTypeRepository.findOne({ where: { id } });
if (!delEmpPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทกลุ่มงานลูกจ้างประจำนี้");
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานลูกจ้างประจำนี้");
}
//ตารางระดับชั้นงาน
const EmpPosLevel = await this.employeePosLevelRepository.find({
@ -147,11 +147,11 @@ export class EmployeePosTypeController extends Controller {
}
/**
* API
* API
*
* @summary ORG_ - (ADMIN) #
* @summary ORG_ - (ADMIN) #
*
* @param {string} id Id
* @param {string} id Id
*/
@Get("{id}")
async GetEmpTypeById(@Path() id: string) {
@ -161,7 +161,7 @@ export class EmployeePosTypeController extends Controller {
where: { id: id },
});
if (!getEmpPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทกลุ่มงานลูกจ้างประจำนี้");
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานลูกจ้างประจำนี้");
}
const mapGetEmpPosType = {
@ -179,9 +179,9 @@ export class EmployeePosTypeController extends Controller {
}
/**
* API
* API
*
* @summary ORG_ - (ADMIN) #
* @summary ORG_ - (ADMIN) #
*
*/
@Get()

View file

@ -84,7 +84,7 @@
"name": "Employee", "description": "ตำแหน่งลูกจ้างประจำ"
},
{
"name": "EmployeePosType", "description": "ประเภทกลุ่มงานลูกจ้างประจำ"
"name": "EmployeePosType", "description": "กลุ่มงานลูกจ้างประจำ"
},
{
"name": "EmployeePosLevel", "description": "ระดับชั้นงานลูกจ้างประจำ"