Merge branch 'develop' into adiDev

This commit is contained in:
AdisakKanthawilang 2024-02-14 17:43:16 +07:00
commit 763bc5e372
3 changed files with 238 additions and 5 deletions

View file

@ -111,6 +111,55 @@ export class PositionController extends Controller {
}
}
const chk_posDictName = await this.posDictRepository.findOne({
where: { posDictName: posDict.posDictName }
})
if(chk_posDictName){
throw new HttpError(HttpStatusCode.NOT_FOUND, "ตำแหน่งในสายงาน: " + chk_posDictName.posDictName + " มีอยู่ในระบบแล้ว");
}
const chk_posDictField = await this.posDictRepository.findOne({
where: { posDictField: posDict.posDictField }
})
if(chk_posDictField){
throw new HttpError(HttpStatusCode.NOT_FOUND, "สายงาน: " + chk_posDictField.posDictField + " มีอยู่ในระบบแล้ว");
}
const chk_posTypeId = await this.posDictRepository.findOne({
where: { posTypeId: posDict.posTypeId }
})
if(chk_posTypeId){
throw new HttpError(HttpStatusCode.NOT_FOUND, "ตำแหน่งประเภท: " + chk_posTypeId.posTypeId + " มีอยู่ในระบบแล้ว");
}
const chk_posLevelId = await this.posDictRepository.findOne({
where: { posLevelId: posDict.posLevelId }
})
if(chk_posLevelId){
throw new HttpError(HttpStatusCode.NOT_FOUND, "ระดับตำแหน่ง: " + chk_posLevelId.posLevelId + " มีอยู่ในระบบแล้ว");
}
const chk_posExecutiveId = await this.posDictRepository.findOne({
where: { posExecutiveId: String(posDict.posExecutiveId) }
})
if(chk_posExecutiveId){
throw new HttpError(HttpStatusCode.NOT_FOUND, "ตำแหน่งทางการบริหาร: " + chk_posExecutiveId.posExecutiveId + " มีอยู่ในระบบแล้ว");
}
const chk_posDictExecutiveField = await this.posDictRepository.findOne({
where: { posDictExecutiveField: posDict.posDictExecutiveField }
})
if(chk_posDictExecutiveField){
throw new HttpError(HttpStatusCode.NOT_FOUND, "ด้านทางการบริหาร: " + chk_posDictExecutiveField.posDictExecutiveField + " มีอยู่ในระบบแล้ว");
}
const chk_posDictArea= await this.posDictRepository.findOne({
where: { posDictArea: posDict.posDictArea }
})
if(chk_posDictArea){
throw new HttpError(HttpStatusCode.NOT_FOUND, "ด้าน/สาขา: " + chk_posDictArea.posDictArea + " มีอยู่ในระบบแล้ว");
}
try {
posDict.createdUserId = request.user.sub;
posDict.createdFullName = request.user.name;