เช็คเพิ่มตำแหน่งซ้ำ
This commit is contained in:
parent
b1f4a568a4
commit
5fbbd687fe
1 changed files with 49 additions and 0 deletions
|
|
@ -112,6 +112,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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue