เพิ่มตำแหน่งลูกจ้าง

This commit is contained in:
Kittapath 2024-03-18 17:29:51 +07:00
parent 9b0a5e9194
commit e6cfe03a6b

View file

@ -159,7 +159,8 @@ export class PositionController extends Controller {
requestBody: CreatePosDictExe, requestBody: CreatePosDictExe,
@Request() request: { user: Record<string, any> }, @Request() request: { user: Record<string, any> },
) { ) {
let posDict: any; // let posDict: PosDict;
let posDict: any = new PosDict();
posDict.posDictName = requestBody.posDictName; posDict.posDictName = requestBody.posDictName;
posDict.posDictField = requestBody.posDictField; posDict.posDictField = requestBody.posDictField;
posDict.posTypeId = requestBody.posTypeId; posDict.posTypeId = requestBody.posTypeId;
@ -182,7 +183,7 @@ export class PositionController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล PosLevelId"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล PosLevelId");
} }
let posExecutive: any = null; let posExecutive: any = new PosExecutive();
if (requestBody.posExecutive != null && requestBody.posExecutive != "") { if (requestBody.posExecutive != null && requestBody.posExecutive != "") {
const checkName = await this.posExecutiveRepository.findOne({ const checkName = await this.posExecutiveRepository.findOne({
where: { posExecutiveName: requestBody.posExecutive }, where: { posExecutiveName: requestBody.posExecutive },
@ -192,8 +193,11 @@ export class PositionController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
} }
posExecutive.posExecutiveName = requestBody.posExecutive; posExecutive.posExecutiveName = requestBody.posExecutive;
const checkPriority = await this.posExecutiveRepository.findOne({ const checkPriority = await this.posExecutiveRepository.findOne({
select: ["posExecutivePriority"],
where: {
posExecutivePriority: Not(IsNull()),
},
order: { posExecutivePriority: "DESC" }, order: { posExecutivePriority: "DESC" },
}); });
if (checkPriority == null) { if (checkPriority == null) {