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) => {
|
||||
|
|
|
|||
|
|
@ -217,16 +217,16 @@ export class CreateOrgChild1 {
|
|||
orgChild1RankSub?: string;
|
||||
|
||||
@Column()
|
||||
DEPARTMENT_CODE?: string;
|
||||
DEPARTMENT_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
DIVISION_CODE?: string;
|
||||
DIVISION_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
SECTION_CODE?: string;
|
||||
SECTION_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
JOB_CODE?: string;
|
||||
JOB_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
orgChild1PhoneEx?: string;
|
||||
|
|
@ -253,4 +253,57 @@ export class CreateOrgChild1 {
|
|||
misId?: string;
|
||||
}
|
||||
|
||||
export type UpdateOrgChild1 = Partial<CreateOrgChild1> & { orgChild1Rank?: OrgChild1Rank };
|
||||
// export type UpdateOrgChild1 = Partial<CreateOrgChild1> & { orgChild1Rank?: OrgChild1Rank }; //ทำให้ส่ง null มาเก็บไม่ได้
|
||||
|
||||
export class UpdateOrgChild1 {
|
||||
@Column()
|
||||
orgChild1Name: string;
|
||||
|
||||
@Column()
|
||||
orgChild1ShortName: string;
|
||||
|
||||
@Column()
|
||||
orgChild1Code?: string;
|
||||
|
||||
@Column()
|
||||
orgChild1Rank: string;
|
||||
|
||||
@Column()
|
||||
orgChild1RankSub?: string;
|
||||
|
||||
@Column()
|
||||
DEPARTMENT_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
DIVISION_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
SECTION_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
JOB_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
orgChild1PhoneEx?: string;
|
||||
|
||||
@Column()
|
||||
orgChild1PhoneIn?: string;
|
||||
|
||||
@Column()
|
||||
orgChild1Fax?: string;
|
||||
|
||||
@Column("uuid")
|
||||
orgRootId: string;
|
||||
|
||||
@Column()
|
||||
responsibility?: string;
|
||||
|
||||
@Column()
|
||||
isOfficer: boolean;
|
||||
|
||||
@Column()
|
||||
isInformation: boolean;
|
||||
|
||||
@Column()
|
||||
misId?: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -240,4 +240,50 @@ export class CreateOrgChild2 {
|
|||
@Column()
|
||||
misId?: string;
|
||||
}
|
||||
export type UpdateOrgChild2 = Partial<CreateOrgChild2> & { orgChild2Rank?: OrgChild2Rank };
|
||||
// export type UpdateOrgChild2 = Partial<CreateOrgChild2> & { orgChild2Rank?: OrgChild2Rank };
|
||||
export class UpdateOrgChild2 {
|
||||
@Column()
|
||||
orgChild2Name: string;
|
||||
|
||||
@Column()
|
||||
orgChild2ShortName: string;
|
||||
|
||||
@Column()
|
||||
orgChild2Code: string;
|
||||
|
||||
@Column()
|
||||
orgChild2Rank: string;
|
||||
|
||||
@Column()
|
||||
orgChild2RankSub?: string;
|
||||
|
||||
@Column()
|
||||
DEPARTMENT_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
DIVISION_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
SECTION_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
JOB_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
orgChild2PhoneEx?: string;
|
||||
|
||||
@Column()
|
||||
orgChild2PhoneIn?: string;
|
||||
|
||||
@Column()
|
||||
orgChild2Fax?: string;
|
||||
|
||||
@Column("uuid")
|
||||
orgChild1Id: string;
|
||||
|
||||
@Column()
|
||||
responsibility?: string;
|
||||
|
||||
@Column()
|
||||
misId?: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,4 +249,51 @@ export class CreateOrgChild3 {
|
|||
misId?: string;
|
||||
}
|
||||
|
||||
export type UpdateOrgChild3 = Partial<CreateOrgChild3> & { orgChild3Rank?: OrgChild3Rank };
|
||||
// export type UpdateOrgChild3 = Partial<CreateOrgChild3> & { orgChild3Rank?: OrgChild3Rank };
|
||||
|
||||
export class UpdateOrgChild3 {
|
||||
@Column()
|
||||
orgChild3Name: string;
|
||||
|
||||
@Column()
|
||||
orgChild3ShortName: string;
|
||||
|
||||
@Column()
|
||||
orgChild3Code: string;
|
||||
|
||||
@Column()
|
||||
orgChild3Rank: string;
|
||||
|
||||
@Column()
|
||||
orgChild3RankSub?: string;
|
||||
|
||||
@Column()
|
||||
DEPARTMENT_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
DIVISION_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
SECTION_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
JOB_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
orgChild3PhoneEx?: string;
|
||||
|
||||
@Column()
|
||||
orgChild3PhoneIn?: string;
|
||||
|
||||
@Column()
|
||||
orgChild3Fax?: string;
|
||||
|
||||
@Column("uuid")
|
||||
orgChild2Id: string;
|
||||
|
||||
@Column()
|
||||
responsibility?: string;
|
||||
|
||||
@Column()
|
||||
misId?: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -254,4 +254,50 @@ export class CreateOrgChild4 {
|
|||
@Column()
|
||||
misId?: string;
|
||||
}
|
||||
export type UpdateOrgChild4 = Partial<OrgChild4>;
|
||||
// export type UpdateOrgChild4 = Partial<OrgChild4>;
|
||||
export class UpdateOrgChild4 {
|
||||
@Column()
|
||||
orgChild4Name: string;
|
||||
|
||||
@Column()
|
||||
orgChild4ShortName: string;
|
||||
|
||||
@Column()
|
||||
orgChild4Code: string;
|
||||
|
||||
@Column()
|
||||
orgChild4Rank: string;
|
||||
|
||||
@Column()
|
||||
orgChild4RankSub?: string;
|
||||
|
||||
@Column()
|
||||
DEPARTMENT_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
DIVISION_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
SECTION_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
JOB_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
orgChild4PhoneEx?: string;
|
||||
|
||||
@Column()
|
||||
orgChild4PhoneIn?: string;
|
||||
|
||||
@Column()
|
||||
orgChild4Fax?: string;
|
||||
|
||||
@Column("uuid")
|
||||
orgChild3Id: string;
|
||||
|
||||
@Column()
|
||||
responsibility?: string;
|
||||
|
||||
@Column()
|
||||
misId?: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -247,4 +247,57 @@ export class CreateOrgRoot {
|
|||
misId?: string;
|
||||
}
|
||||
|
||||
export type UpdateOrgRoot = Partial<CreateOrgRoot> & { orgRootRank?: OrgRootRank };
|
||||
// export type UpdateOrgRoot = Partial<CreateOrgRoot> & { orgRootRank?: OrgRootRank };
|
||||
|
||||
export class UpdateOrgRoot {
|
||||
@Column()
|
||||
orgRootName: string;
|
||||
|
||||
@Column()
|
||||
orgRootShortName: string;
|
||||
|
||||
@Column()
|
||||
orgRootCode: string;
|
||||
|
||||
@Column()
|
||||
orgRootRank: OrgRootRank;
|
||||
|
||||
@Column()
|
||||
orgRootRankSub?: string;
|
||||
|
||||
@Column()
|
||||
DEPARTMENT_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
DIVISION_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
SECTION_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
JOB_CODE?: string | null;
|
||||
|
||||
@Column()
|
||||
orgRootPhoneEx?: string;
|
||||
|
||||
@Column()
|
||||
orgRootPhoneIn?: string;
|
||||
|
||||
@Column()
|
||||
orgRootFax?: string;
|
||||
|
||||
@Column()
|
||||
responsibility?: string;
|
||||
|
||||
@Column("uuid")
|
||||
orgRevisionId: string;
|
||||
|
||||
@Column()
|
||||
isDeputy: boolean;
|
||||
|
||||
@Column()
|
||||
isCommission: boolean;
|
||||
|
||||
@Column()
|
||||
misId?: string;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue