แก้ไขสิทธิ์
This commit is contained in:
parent
4641362b95
commit
0024ed9414
9 changed files with 154 additions and 27 deletions
|
|
@ -81,6 +81,7 @@ export class OrgChild1Controller {
|
|||
orgChild1PhoneIn: orgChild1.orgChild1PhoneIn,
|
||||
orgChild1Fax: orgChild1.orgChild1Fax,
|
||||
orgRevisionId: orgChild1.orgRevisionId,
|
||||
isOfficer: orgChild1.isOfficer,
|
||||
orgCode: orgChild1.orgRoot.orgRootCode + orgChild1.orgChild1Code,
|
||||
};
|
||||
return new HttpSuccess(getOrgChild1);
|
||||
|
|
@ -97,10 +98,23 @@ export class OrgChild1Controller {
|
|||
await new permission().PermissionCreate(request, "SYS_ORG");
|
||||
const rootIdExits = await this.orgRootRepository.findOne({
|
||||
where: { id: requestBody.orgRootId },
|
||||
relations: ["orgChild1s"],
|
||||
});
|
||||
if (!rootIdExits) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. orgRootId");
|
||||
}
|
||||
|
||||
if (requestBody.isOfficer == true) {
|
||||
await Promise.all(
|
||||
rootIdExits.orgChild1s
|
||||
.filter((x: OrgChild1) => x.isOfficer == true)
|
||||
.map(async (item: OrgChild1) => {
|
||||
item.isOfficer = false;
|
||||
await this.child1Repository.save(item);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const revisionIdExits = await this.orgRevisionRepository.findOne({
|
||||
where: { id: rootIdExits.orgRevisionId },
|
||||
});
|
||||
|
|
@ -193,10 +207,23 @@ export class OrgChild1Controller {
|
|||
await new permission().PermissionUpdate(request, "SYS_ORG");
|
||||
const rootIdExits = await this.orgRootRepository.findOne({
|
||||
where: { id: requestBody.orgRootId },
|
||||
relations: ["orgChild1s"],
|
||||
});
|
||||
if (!rootIdExits) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. RootId");
|
||||
}
|
||||
|
||||
if (requestBody.isOfficer == true) {
|
||||
await Promise.all(
|
||||
rootIdExits.orgChild1s
|
||||
.filter((x: OrgChild1) => x.isOfficer == true)
|
||||
.map(async (item: OrgChild1) => {
|
||||
item.isOfficer = false;
|
||||
await this.child1Repository.save(item);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const revisionIdExits = await this.orgRevisionRepository.findOne({
|
||||
where: { id: rootIdExits.orgRevisionId },
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue