Merge branch 'develop' into adiDev
This commit is contained in:
commit
e1d0ebf308
2 changed files with 75 additions and 1 deletions
|
|
@ -28,6 +28,7 @@ import { PosMaster } from "../entities/PosMaster";
|
||||||
import { Position } from "../entities/Position";
|
import { Position } from "../entities/Position";
|
||||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||||
import { EmployeePosition } from "../entities/EmployeePosition";
|
import { EmployeePosition } from "../entities/EmployeePosition";
|
||||||
|
import { Like } from "typeorm/browser";
|
||||||
@Route("api/v1/org/child1")
|
@Route("api/v1/org/child1")
|
||||||
@Tags("OrgChild1")
|
@Tags("OrgChild1")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -134,6 +135,24 @@ export class OrgChild1Controller {
|
||||||
"รหัสส่วนราชการนี้มีอยู่ในระบบแล้ว",
|
"รหัสส่วนราชการนี้มีอยู่ในระบบแล้ว",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const chkShort = await this.child1Repository.findOne({
|
||||||
|
where: {
|
||||||
|
orgRevisionId: rootIdExits.orgRevisionId,
|
||||||
|
orgRootId: requestBody.orgRootId,
|
||||||
|
orgChild1ShortName: requestBody.orgChild1ShortName
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (chkShort != null) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "อักษรย่อนี้มีอยู่ในระบบแล้ว");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(requestBody.orgChild1Code == rootIdExits.orgRootCode){
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "รหัสส่วนราชการนี้ซ้ำกับรหัสหน่วยงาน");
|
||||||
|
}
|
||||||
|
if(requestBody.orgChild1ShortName == rootIdExits.orgRootShortName){
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "อักษรย่อนี้ซ้ำกับอักษรย่อหน่วยงาน");
|
||||||
|
}
|
||||||
|
|
||||||
const order: any = await this.child1Repository.findOne({
|
const order: any = await this.child1Repository.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgRootId: requestBody.orgRootId,
|
orgRootId: requestBody.orgRootId,
|
||||||
|
|
@ -194,7 +213,7 @@ export class OrgChild1Controller {
|
||||||
requestBody.orgChild1Rank == null ||
|
requestBody.orgChild1Rank == null ||
|
||||||
!validOrgChild1Ranks.includes(requestBody.orgChild1Rank.toUpperCase())
|
!validOrgChild1Ranks.includes(requestBody.orgChild1Rank.toUpperCase())
|
||||||
) {
|
) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. orgChild2Rank");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. orgChild1Rank");
|
||||||
}
|
}
|
||||||
|
|
||||||
const child1 = await this.child1Repository.findOne({ where: { id } });
|
const child1 = await this.child1Repository.findOne({ where: { id } });
|
||||||
|
|
@ -212,6 +231,25 @@ export class OrgChild1Controller {
|
||||||
if (chkCode != null) {
|
if (chkCode != null) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "รหัสส่วนราชการนี้มีอยู่ในระบบแล้ว");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "รหัสส่วนราชการนี้มีอยู่ในระบบแล้ว");
|
||||||
}
|
}
|
||||||
|
const chkShort = await this.child1Repository.findOne({
|
||||||
|
where: {
|
||||||
|
id: Not(id),
|
||||||
|
orgRevisionId: rootIdExits.orgRevisionId,
|
||||||
|
orgRootId: requestBody.orgRootId,
|
||||||
|
orgChild1ShortName: requestBody.orgChild1ShortName
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (chkShort != null) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "อักษรย่อนี้มีอยู่ในระบบแล้ว");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(requestBody.orgChild1Code == rootIdExits.orgRootCode){
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "รหัสส่วนราชการนี้ซ้ำกับรหัสหน่วยงาน");
|
||||||
|
}
|
||||||
|
if(requestBody.orgChild1ShortName == rootIdExits.orgRootShortName){
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "อักษรย่อนี้ซ้ำกับอักษรย่อหน่วยงาน");
|
||||||
|
}
|
||||||
|
|
||||||
child1.lastUpdateUserId = request.user.sub;
|
child1.lastUpdateUserId = request.user.sub;
|
||||||
child1.lastUpdateFullName = request.user.name;
|
child1.lastUpdateFullName = request.user.name;
|
||||||
child1.lastUpdatedAt = new Date();
|
child1.lastUpdatedAt = new Date();
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,13 @@ export class OrgRootController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "รหัสหน่วยงานนี้มีอยู่ในระบบแล้ว");
|
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({
|
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||||
where: { id: requestBody.orgRevisionId },
|
where: { id: requestBody.orgRevisionId },
|
||||||
});
|
});
|
||||||
|
|
@ -198,10 +205,39 @@ export class OrgRootController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "รหัสหน่วยงานนี้มีอยู่ในระบบแล้ว");
|
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 } });
|
const orgRoot = await this.orgRootRepository.findOne({ where: { id } });
|
||||||
if (!orgRoot) {
|
if (!orgRoot) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้างระดับ Root นี้");
|
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.lastUpdateUserId = request.user.sub;
|
||||||
orgRoot.lastUpdateFullName = request.user.name;
|
orgRoot.lastUpdateFullName = request.user.name;
|
||||||
orgRoot.lastUpdatedAt = new Date();
|
orgRoot.lastUpdatedAt = new Date();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue