เช็คอักษรย่อและรหัสซ้ำ
This commit is contained in:
parent
b296c22fdf
commit
53c39c2311
2 changed files with 75 additions and 1 deletions
|
|
@ -116,6 +116,13 @@ export class OrgRootController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "รหัสหน่วยงานนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
|
||||
const chkShort = await this.orgRootRepository.findOne({
|
||||
where: { orgRevisionId: requestBody.orgRevisionId, orgRootShortName: requestBody.orgRootShortName },
|
||||
});
|
||||
if (chkShort != null) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "อักษรย่อนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
where: { id: requestBody.orgRevisionId },
|
||||
});
|
||||
|
|
@ -198,10 +205,39 @@ export class OrgRootController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "รหัสหน่วยงานนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
|
||||
const chkShort = await this.orgRootRepository.findOne({
|
||||
where: { orgRevisionId: requestBody.orgRevisionId, orgRootShortName: requestBody.orgRootShortName },
|
||||
});
|
||||
if (chkCode?.id != id && chkShort != null) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "อักษรย่อนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
|
||||
const orgRoot = await this.orgRootRepository.findOne({ where: { id } });
|
||||
if (!orgRoot) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้างระดับ Root นี้");
|
||||
}
|
||||
|
||||
const chkCodeChild1 = await this.orgChild1Repository.findOne({
|
||||
where:{
|
||||
orgRevisionId : requestBody.orgRevisionId,
|
||||
orgRootId: id,
|
||||
orgChild1Code: requestBody.orgRootCode,
|
||||
}
|
||||
});
|
||||
if(chkCodeChild1 != null){
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "รหัสหน่วยงานนี้ซ้ำกับรหัสส่วนราชการ");
|
||||
}
|
||||
const chkShortChild1 = await this.orgChild1Repository.findOne({
|
||||
where:{
|
||||
orgRevisionId : requestBody.orgRevisionId,
|
||||
orgRootId: id,
|
||||
orgChild1ShortName: requestBody.orgRootShortName,
|
||||
}
|
||||
});
|
||||
if(chkShortChild1 != null){
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "อักษรย่อนี้ซ้ำกับอักษรย่อส่วนราชการ");
|
||||
}
|
||||
|
||||
orgRoot.lastUpdateUserId = request.user.sub;
|
||||
orgRoot.lastUpdateFullName = request.user.name;
|
||||
orgRoot.lastUpdatedAt = new Date();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue