เพิ่มอัตราตำแหน่งลูกจ้าง
This commit is contained in:
parent
806fb21c61
commit
ee6b6f7cc2
11 changed files with 2226 additions and 106 deletions
|
|
@ -18,8 +18,12 @@ import HttpSuccess from "../interfaces/http-success";
|
|||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { Not } from "typeorm";
|
||||
import { EmployeePosType,} from "../entities/EmployeePosType";
|
||||
import { EmployeePosLevel, CreateEmployeePosLevel, UpdateEmployeePosLevel } from "../entities/EmployeePosLevel";
|
||||
import { EmployeePosType } from "../entities/EmployeePosType";
|
||||
import {
|
||||
EmployeePosLevel,
|
||||
CreateEmployeePosLevel,
|
||||
UpdateEmployeePosLevel,
|
||||
} from "../entities/EmployeePosLevel";
|
||||
import { EmployeePosDict } from "../entities/EmployeePosDict";
|
||||
|
||||
@Route("api/v1/org/employee/pos/level")
|
||||
|
|
@ -31,7 +35,6 @@ import { EmployeePosDict } from "../entities/EmployeePosDict";
|
|||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class EmployeePosLevelController extends Controller {
|
||||
|
||||
private employeePosDictRepository = AppDataSource.getRepository(EmployeePosDict);
|
||||
private employeePosTypeRepository = AppDataSource.getRepository(EmployeePosType);
|
||||
private employeePosLevelRepository = AppDataSource.getRepository(EmployeePosLevel);
|
||||
|
|
@ -52,9 +55,9 @@ export class EmployeePosLevelController extends Controller {
|
|||
if (!EmpPosLevel) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
const EmpPosType = await this.employeePosTypeRepository.findOne({
|
||||
where: { id: requestBody.employeePosTypeId }
|
||||
|
||||
const EmpPosType = await this.employeePosTypeRepository.findOne({
|
||||
where: { id: requestBody.posTypeId },
|
||||
});
|
||||
if (!EmpPosType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานลูกจ้างประจำนี้");
|
||||
|
|
@ -98,8 +101,8 @@ export class EmployeePosLevelController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงานลูกจ้างประจำนี้");
|
||||
}
|
||||
|
||||
const EmpPosType = await this.employeePosTypeRepository.findOne({
|
||||
where: { id: requestBody.employeePosTypeId }
|
||||
const EmpPosType = await this.employeePosTypeRepository.findOne({
|
||||
where: { id: requestBody.posTypeId },
|
||||
});
|
||||
if (!EmpPosType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานลูกจ้างประจำนี้");
|
||||
|
|
@ -137,10 +140,10 @@ export class EmployeePosLevelController extends Controller {
|
|||
if (!delEmpPosLevel) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงานลูกจ้างประจำนี้");
|
||||
}
|
||||
|
||||
|
||||
//ตารางตำแหน่งลูกจ้างประจำ
|
||||
const EmpPosition = await this.employeePosDictRepository.find({
|
||||
where: { employeePosLevelId: id },
|
||||
where: { posLevelId: id },
|
||||
});
|
||||
if (EmpPosition.length > 0) {
|
||||
throw new HttpError(
|
||||
|
|
@ -163,8 +166,8 @@ export class EmployeePosLevelController extends Controller {
|
|||
@Get("{id}")
|
||||
async GetEmpLevelById(@Path() id: string) {
|
||||
const getEmpPosLevel = await this.employeePosLevelRepository.findOne({
|
||||
relations: ["employeePosType"],
|
||||
select: ["id", "posLevelName", "posLevelRank",],
|
||||
relations: ["posType"],
|
||||
select: ["id", "posLevelName", "posLevelRank"],
|
||||
where: { id: id },
|
||||
});
|
||||
if (!getEmpPosLevel) {
|
||||
|
|
@ -173,9 +176,9 @@ export class EmployeePosLevelController extends Controller {
|
|||
const mapEmpPosLevel = {
|
||||
id: getEmpPosLevel.id,
|
||||
posLevelName: getEmpPosLevel.posLevelName,
|
||||
posTypeName: getEmpPosLevel.employeePosType == null ? null : getEmpPosLevel.employeePosType.posTypeName, //กลุ่มงาน
|
||||
commander: null //ผู้มีอำนาจสั่งบรรจุ
|
||||
}
|
||||
posTypeName: getEmpPosLevel.posType == null ? null : getEmpPosLevel.posType.posTypeName, //กลุ่มงาน
|
||||
commander: null, //ผู้มีอำนาจสั่งบรรจุ
|
||||
};
|
||||
return new HttpSuccess(mapEmpPosLevel);
|
||||
}
|
||||
|
||||
|
|
@ -188,15 +191,15 @@ export class EmployeePosLevelController extends Controller {
|
|||
@Get()
|
||||
async GetEmpPosLevel() {
|
||||
const empPosLevel = await this.employeePosLevelRepository.find({
|
||||
relations: ["employeePosType"],
|
||||
select: ["id","posLevelName", "posLevelRank",],
|
||||
relations: ["posType"],
|
||||
select: ["id", "posLevelName", "posLevelRank"],
|
||||
});
|
||||
const mapEmpPosLevel = empPosLevel.map((item) => ({
|
||||
id: item.id,
|
||||
posLevelName: item.posLevelName,
|
||||
posTypeName: item.employeePosType == null ? null : item.employeePosType.posTypeName, //กลุ่มงาน
|
||||
commander: null //ผู้มีอำนาจสั่งบรรจุ
|
||||
posTypeName: item.posType == null ? null : item.posType.posTypeName, //กลุ่มงาน
|
||||
commander: null, //ผู้มีอำนาจสั่งบรรจุ
|
||||
}));
|
||||
return new HttpSuccess(mapEmpPosLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,11 @@ import HttpSuccess from "../interfaces/http-success";
|
|||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { Not } from "typeorm";
|
||||
import { EmployeePosType, CreateEmployeePosType, UpdateEmployeePosType } from "../entities/EmployeePosType";
|
||||
import {
|
||||
EmployeePosType,
|
||||
CreateEmployeePosType,
|
||||
UpdateEmployeePosType,
|
||||
} from "../entities/EmployeePosType";
|
||||
import { EmployeePosLevel } from "../entities/EmployeePosLevel";
|
||||
import { EmployeePosDict } from "../entities/EmployeePosDict";
|
||||
|
||||
|
|
@ -31,7 +35,6 @@ import { EmployeePosDict } from "../entities/EmployeePosDict";
|
|||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class EmployeePosTypeController extends Controller {
|
||||
|
||||
private employeePosDictRepository = AppDataSource.getRepository(EmployeePosDict);
|
||||
private employeePosTypeRepository = AppDataSource.getRepository(EmployeePosType);
|
||||
private employeePosLevelRepository = AppDataSource.getRepository(EmployeePosLevel);
|
||||
|
|
@ -59,10 +62,7 @@ export class EmployeePosTypeController extends Controller {
|
|||
},
|
||||
});
|
||||
if (chkEmpPosTypeName) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ชื่อกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว",
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
EmpPosType.createdUserId = request.user.sub;
|
||||
EmpPosType.createdFullName = request.user.name;
|
||||
|
|
@ -96,10 +96,7 @@ export class EmployeePosTypeController extends Controller {
|
|||
},
|
||||
});
|
||||
if (chkEmpPosType) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ชื่อกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว",
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
EmpPosType.lastUpdateUserId = request.user.sub;
|
||||
EmpPosType.lastUpdateFullName = request.user.name;
|
||||
|
|
@ -123,7 +120,7 @@ export class EmployeePosTypeController extends Controller {
|
|||
}
|
||||
//ตารางระดับชั้นงาน
|
||||
const EmpPosLevel = await this.employeePosLevelRepository.find({
|
||||
where: { employeePosTypeId: id },
|
||||
where: { posTypeId: id },
|
||||
});
|
||||
if (EmpPosLevel.length > 0) {
|
||||
throw new HttpError(
|
||||
|
|
@ -133,7 +130,7 @@ export class EmployeePosTypeController extends Controller {
|
|||
}
|
||||
//ตารางตำแหน่งลูกจ้างประจำ
|
||||
const EmpPosition = await this.employeePosDictRepository.find({
|
||||
where: { employeePosTypeId: id },
|
||||
where: { posTypeId: id },
|
||||
});
|
||||
if (EmpPosition.length > 0) {
|
||||
throw new HttpError(
|
||||
|
|
@ -156,8 +153,8 @@ export class EmployeePosTypeController extends Controller {
|
|||
@Get("{id}")
|
||||
async GetEmpTypeById(@Path() id: string) {
|
||||
const getEmpPosType = await this.employeePosTypeRepository.findOne({
|
||||
relations: ["posLevels"],
|
||||
select: ["id", "posTypeName", "posTypeRank"],
|
||||
relations: ["employeePosLevels"],
|
||||
where: { id: id },
|
||||
});
|
||||
if (!getEmpPosType) {
|
||||
|
|
@ -168,7 +165,7 @@ export class EmployeePosTypeController extends Controller {
|
|||
id: getEmpPosType.id,
|
||||
posTypeName: getEmpPosType.posTypeName,
|
||||
posTypeRank: getEmpPosType.posTypeRank,
|
||||
posLevels: getEmpPosType.employeePosLevels.map((empPosLevel) => ({
|
||||
posLevels: getEmpPosType.posLevels.map((empPosLevel) => ({
|
||||
id: empPosLevel.id,
|
||||
posLevelName: empPosLevel.posLevelName,
|
||||
posLevelRank: empPosLevel.posLevelRank,
|
||||
|
|
@ -187,15 +184,15 @@ export class EmployeePosTypeController extends Controller {
|
|||
@Get()
|
||||
async GetEmpPosType() {
|
||||
const empPosType = await this.employeePosTypeRepository.find({
|
||||
relations: ["posLevels"],
|
||||
select: ["id", "posTypeName", "posTypeRank"],
|
||||
relations: ["employeePosLevels"],
|
||||
});
|
||||
|
||||
const mapEmpPosType = empPosType.map((item) => ({
|
||||
id: item.id,
|
||||
posTypeName: item.posTypeName,
|
||||
posTypeRank: item.posTypeRank,
|
||||
posLevels: item.employeePosLevels.map((empPosLevel) => ({
|
||||
posLevels: item.posLevels.map((empPosLevel) => ({
|
||||
id: empPosLevel.id,
|
||||
posLevelName: empPosLevel.posLevelName,
|
||||
posLevelRank: empPosLevel.posLevelRank,
|
||||
|
|
@ -203,4 +200,4 @@ export class EmployeePosTypeController extends Controller {
|
|||
}));
|
||||
return new HttpSuccess(mapEmpPosType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -2097,7 +2097,7 @@ export class PositionController extends Controller {
|
|||
}
|
||||
|
||||
/**
|
||||
* API สร้างทะเบียนประวัติ
|
||||
* API ลบคนครองตำแหน่ง
|
||||
*
|
||||
* @summary ORG_066 - ลบคนครองตำแหน่ง (ADMIN) #71
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue