fix
This commit is contained in:
parent
ea2566395e
commit
a4b29e0a1b
1 changed files with 39 additions and 20 deletions
|
|
@ -115,31 +115,50 @@ export class AuthRoleController extends Controller {
|
|||
where: { authRoleId: roleId },
|
||||
});
|
||||
|
||||
const updatedRoleAttrData = roleAttrData.map((attr) => {
|
||||
const updatedAttr = body.authRoleAttrs.find((a) => a.authSysId === attr.authSysId);
|
||||
if (updatedAttr) {
|
||||
return Object.assign(attr, updatedAttr, { lastUpdateFullName: req.user.name });
|
||||
}
|
||||
return attr;
|
||||
});
|
||||
// const updatedRoleAttrData = roleAttrData.map((attr) => {
|
||||
// const updatedAttr = body.authRoleAttrs.find((a) => a.authSysId === attr.authSysId);
|
||||
// if (updatedAttr) {
|
||||
// return Object.assign(attr, updatedAttr, { lastUpdateFullName: req.user.name });
|
||||
// }
|
||||
// return attr;
|
||||
// });
|
||||
|
||||
const newAttrs = body.authRoleAttrs
|
||||
.filter((a) => !roleAttrData.some((attr) => attr.authSysId === a.authSysId))
|
||||
.map((attr) => {
|
||||
const newAttr = new AuthRoleAttr();
|
||||
Object.assign(newAttr, attr, {
|
||||
authRoleId: roleId,
|
||||
createdUserId: req.user.sub,
|
||||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
});
|
||||
return newAttr;
|
||||
// const newAttrs = body.authRoleAttrs
|
||||
// .filter((a) => !roleAttrData.some((attr) => attr.authSysId === a.authSysId))
|
||||
// .map((attr) => {
|
||||
// const newAttr = new AuthRoleAttr();
|
||||
// Object.assign(newAttr, attr, {
|
||||
// authRoleId: roleId,
|
||||
// createdUserId: req.user.sub,
|
||||
// createdFullName: req.user.name,
|
||||
// lastUpdateUserId: req.user.sub,
|
||||
// lastUpdateFullName: req.user.name,
|
||||
// });
|
||||
// return newAttr;
|
||||
// });
|
||||
|
||||
// await Promise.all([
|
||||
// this.authRoleRepo.save(record),
|
||||
// ...updatedRoleAttrData.map((attr) => this.authRoleAttrRepo.save(attr)),
|
||||
// ...newAttrs.map((attr) => this.authRoleAttrRepo.save(attr)),
|
||||
// ]);
|
||||
|
||||
await this.authRoleAttrRepo.remove(roleAttrData);
|
||||
|
||||
const newAttrs = body.authRoleAttrs.map((attr) => {
|
||||
const newAttr = new AuthRoleAttr();
|
||||
Object.assign(newAttr, attr, {
|
||||
authRoleId: roleId,
|
||||
createdUserId: req.user.sub,
|
||||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
});
|
||||
return newAttr;
|
||||
});
|
||||
|
||||
await Promise.all([
|
||||
this.authRoleRepo.save(record),
|
||||
...updatedRoleAttrData.map((attr) => this.authRoleAttrRepo.save(attr)),
|
||||
...newAttrs.map((attr) => this.authRoleAttrRepo.save(attr)),
|
||||
]);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue