This commit is contained in:
parent
7d572b18d2
commit
f31ecf1c2b
11 changed files with 349 additions and 19 deletions
|
|
@ -323,14 +323,30 @@ export class OrgChild1Controller {
|
|||
// if(requestBody.orgChild1ShortName == rootIdExits.orgRootShortName){
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "อักษรย่อนี้ซ้ำกับอักษรย่อหน่วยงาน");
|
||||
// }
|
||||
const _null:any = null;
|
||||
const before = structuredClone(child1);
|
||||
|
||||
child1.lastUpdateUserId = request.user.sub;
|
||||
child1.lastUpdateFullName = request.user.name;
|
||||
child1.lastUpdatedAt = new Date();
|
||||
child1.orgRevisionId = String(rootIdExits?.orgRevisionId);
|
||||
child1.orgRootId = String(rootIdExits?.id);
|
||||
child1.responsibility = child1.responsibility || "";
|
||||
this.child1Repository.merge(child1, requestBody);
|
||||
this.child1Repository.merge(child1,{
|
||||
orgChild1Name: requestBody.orgChild1Name,
|
||||
orgChild1ShortName: requestBody.orgChild1ShortName,
|
||||
orgChild1Code: requestBody.orgChild1Code,
|
||||
DEPARTMENT_CODE: requestBody.DEPARTMENT_CODE != null ? requestBody.DEPARTMENT_CODE : _null,
|
||||
DIVISION_CODE: requestBody.DIVISION_CODE != null ? requestBody.DIVISION_CODE : _null,
|
||||
SECTION_CODE: requestBody.SECTION_CODE != null ? requestBody.SECTION_CODE : _null,
|
||||
JOB_CODE: requestBody.JOB_CODE != null ? requestBody.JOB_CODE : _null,
|
||||
isOfficer: requestBody.isOfficer,
|
||||
isInformation: requestBody.isInformation,
|
||||
orgChild1PhoneEx: requestBody.orgChild1PhoneEx,
|
||||
orgChild1PhoneIn: requestBody.orgChild1PhoneIn,
|
||||
orgChild1Fax: requestBody.orgChild1Fax,
|
||||
misId: requestBody.misId,
|
||||
});
|
||||
await this.child1Repository.save(child1, { data: request });
|
||||
setLogDataDiff(request, { before, after: child1 });
|
||||
|
||||
|
|
|
|||
|
|
@ -230,6 +230,7 @@ export class OrgChild2Controller extends Controller {
|
|||
if (!child2) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
}
|
||||
const _null:any = null;
|
||||
const before = structuredClone(child2);
|
||||
child2.lastUpdateUserId = request.user.sub;
|
||||
child2.lastUpdateFullName = request.user.name;
|
||||
|
|
@ -237,7 +238,22 @@ export class OrgChild2Controller extends Controller {
|
|||
child2.orgRootId = String(child1IdExits?.orgRootId);
|
||||
child2.orgRevisionId = String(child1IdExits?.orgRevisionId);
|
||||
child2.orgChild1Id = String(child1IdExits?.id);
|
||||
this.child2Repository.merge(child2, requestBody);
|
||||
this.child2Repository.merge(child2, {
|
||||
orgChild2Name: requestBody.orgChild2Name,
|
||||
orgChild2ShortName: requestBody.orgChild2ShortName,
|
||||
orgChild2Code: requestBody.orgChild2Code,
|
||||
orgChild2Rank: requestBody.orgChild2Rank != null ? requestBody.orgChild2Rank : _null,
|
||||
orgChild2RankSub: requestBody.orgChild2RankSub,
|
||||
DEPARTMENT_CODE: requestBody.DEPARTMENT_CODE != null ? requestBody.DEPARTMENT_CODE : _null,
|
||||
DIVISION_CODE: requestBody.DIVISION_CODE != null ? requestBody.DIVISION_CODE : _null,
|
||||
SECTION_CODE: requestBody.SECTION_CODE != null ? requestBody.SECTION_CODE : _null,
|
||||
JOB_CODE: requestBody.JOB_CODE != null ? requestBody.JOB_CODE : _null,
|
||||
orgChild2PhoneEx: requestBody.orgChild2PhoneEx,
|
||||
orgChild2PhoneIn: requestBody.orgChild2PhoneIn,
|
||||
orgChild2Fax: requestBody.orgChild2Fax,
|
||||
responsibility: requestBody.responsibility ?? "",
|
||||
misId: requestBody.misId,
|
||||
});
|
||||
await this.child2Repository.save(child2, { data: request });
|
||||
setLogDataDiff(request, { before, after: child2 });
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
|
|
@ -184,6 +184,7 @@ export class OrgChild3Controller {
|
|||
if (!child3) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
}
|
||||
const _null:any = null;
|
||||
const before = structuredClone(child3);
|
||||
child3.lastUpdateUserId = request.user.sub;
|
||||
child3.lastUpdateFullName = request.user.name;
|
||||
|
|
@ -192,7 +193,22 @@ export class OrgChild3Controller {
|
|||
child3.orgChild1Id = String(child2IdExits?.orgChild1Id);
|
||||
child3.orgRevisionId = String(child2IdExits?.orgRevisionId);
|
||||
child3.orgChild2Id = String(child2IdExits?.id);
|
||||
this.child3Repository.merge(child3, requestBody);
|
||||
this.child3Repository.merge(child3, {
|
||||
orgChild3Name: requestBody.orgChild3Name,
|
||||
orgChild3ShortName: requestBody.orgChild3ShortName,
|
||||
orgChild3Code: requestBody.orgChild3Code,
|
||||
orgChild3Rank: requestBody.orgChild3Rank != null ? requestBody.orgChild3Rank : _null,
|
||||
orgChild3RankSub: requestBody.orgChild3RankSub,
|
||||
DEPARTMENT_CODE: requestBody.DEPARTMENT_CODE != null ? requestBody.DEPARTMENT_CODE : _null,
|
||||
DIVISION_CODE: requestBody.DIVISION_CODE != null ? requestBody.DIVISION_CODE : _null,
|
||||
SECTION_CODE: requestBody.SECTION_CODE != null ? requestBody.SECTION_CODE : _null,
|
||||
JOB_CODE: requestBody.JOB_CODE != null ? requestBody.JOB_CODE : _null,
|
||||
orgChild3PhoneEx: requestBody.orgChild3PhoneEx,
|
||||
orgChild3PhoneIn: requestBody.orgChild3PhoneIn,
|
||||
orgChild3Fax: requestBody.orgChild3Fax,
|
||||
responsibility: requestBody.responsibility ?? "",
|
||||
misId: requestBody.misId,
|
||||
});
|
||||
await this.child3Repository.save(child3, { data: request });
|
||||
setLogDataDiff(request, { before, after: child3 });
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
|
|
@ -230,6 +230,7 @@ export class OrgChild4Controller extends Controller {
|
|||
if (!child4) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
}
|
||||
const _null:any = null;
|
||||
const before = structuredClone(child4);
|
||||
child4.lastUpdateUserId = request.user.sub;
|
||||
child4.lastUpdateFullName = request.user.name;
|
||||
|
|
@ -239,7 +240,22 @@ export class OrgChild4Controller extends Controller {
|
|||
child4.orgChild2Id = String(child3IdExits?.orgChild2Id);
|
||||
child4.orgRevisionId = String(child3IdExits?.orgRevisionId);
|
||||
child4.orgChild3Id = String(child3IdExits?.id);
|
||||
this.child4Repository.merge(child4, requestBody);
|
||||
this.child4Repository.merge(child4, {
|
||||
orgChild4Name: requestBody.orgChild4Name,
|
||||
orgChild4ShortName: requestBody.orgChild4ShortName,
|
||||
orgChild4Code: requestBody.orgChild4Code,
|
||||
orgChild4Rank: requestBody.orgChild4Rank != null ? requestBody.orgChild4Rank : _null,
|
||||
orgChild4RankSub: requestBody.orgChild4RankSub,
|
||||
DEPARTMENT_CODE: requestBody.DEPARTMENT_CODE != null ? requestBody.DEPARTMENT_CODE : _null,
|
||||
DIVISION_CODE: requestBody.DIVISION_CODE != null ? requestBody.DIVISION_CODE : _null,
|
||||
SECTION_CODE: requestBody.SECTION_CODE != null ? requestBody.SECTION_CODE : _null,
|
||||
JOB_CODE: requestBody.JOB_CODE != null ? requestBody.JOB_CODE : _null,
|
||||
orgChild4PhoneEx: requestBody.orgChild4PhoneEx,
|
||||
orgChild4PhoneIn: requestBody.orgChild4PhoneIn,
|
||||
orgChild4Fax: requestBody.orgChild4Fax,
|
||||
responsibility: requestBody.responsibility ?? "",
|
||||
misId: requestBody.misId,
|
||||
});
|
||||
await this.child4Repository.save(child4, { data: request });
|
||||
setLogDataDiff(request, { before, after: child4 });
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import {
|
|||
Request,
|
||||
Example,
|
||||
} from "tsoa";
|
||||
import { CreateOrgRoot, OrgRoot } from "../entities/OrgRoot";
|
||||
import { CreateOrgRoot, OrgRoot, UpdateOrgRoot } from "../entities/OrgRoot";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import { OrgChild1 } from "../entities/OrgChild1";
|
||||
|
|
@ -226,7 +226,7 @@ export class OrgRootController extends Controller {
|
|||
async update(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: CreateOrgRoot,
|
||||
requestBody: UpdateOrgRoot,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_ORG");
|
||||
|
|
@ -332,11 +332,18 @@ export class OrgRootController extends Controller {
|
|||
// if(chkShortChild1 != null){
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "อักษรย่อนี้ซ้ำกับอักษรย่อส่วนราชการ");
|
||||
// }
|
||||
const _null:any = null;
|
||||
const before = structuredClone(orgRoot);
|
||||
orgRoot.lastUpdateUserId = request.user.sub;
|
||||
orgRoot.lastUpdateFullName = request.user.name;
|
||||
orgRoot.lastUpdatedAt = new Date();
|
||||
this.orgRootRepository.merge(orgRoot, requestBody);
|
||||
this.orgRootRepository.merge(orgRoot, {
|
||||
...requestBody,
|
||||
DEPARTMENT_CODE: requestBody.DEPARTMENT_CODE != null ? requestBody.DEPARTMENT_CODE : _null,
|
||||
DIVISION_CODE: requestBody.DIVISION_CODE != null ? requestBody.DIVISION_CODE : _null,
|
||||
SECTION_CODE: requestBody.SECTION_CODE != null ? requestBody.SECTION_CODE : _null,
|
||||
JOB_CODE: requestBody.JOB_CODE != null ? requestBody.JOB_CODE : _null,
|
||||
});
|
||||
await this.orgRootRepository.save(orgRoot, { data: request });
|
||||
setLogDataDiff(request, { before, after: orgRoot });
|
||||
|
||||
|
|
|
|||
|
|
@ -3229,6 +3229,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
nodeId: string;
|
||||
isAll: boolean;
|
||||
isRetirement?: boolean;
|
||||
revisionId?: string;
|
||||
},
|
||||
) {
|
||||
let typeCondition: any = {};
|
||||
|
|
@ -3314,11 +3315,17 @@ export class OrganizationDotnetController extends Controller {
|
|||
],
|
||||
});
|
||||
}
|
||||
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
let findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
|
||||
if(body.revisionId){
|
||||
findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { id: body.revisionId },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const profile_ = await Promise.all(
|
||||
profile.map((item: Profile) => {
|
||||
const shortName =
|
||||
|
|
@ -3393,6 +3400,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
node: number;
|
||||
nodeId: string;
|
||||
isAll: boolean;
|
||||
revisionId?: string;
|
||||
},
|
||||
) {
|
||||
let typeCondition: any = {};
|
||||
|
|
@ -3459,9 +3467,15 @@ export class OrganizationDotnetController extends Controller {
|
|||
],
|
||||
});
|
||||
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
let findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
|
||||
if(body.revisionId){
|
||||
findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { id: body.revisionId },
|
||||
});
|
||||
}
|
||||
|
||||
const profile_ = await Promise.all(
|
||||
profile.map((item: ProfileEmployee) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue