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