refactor: user relation
This commit is contained in:
parent
a74d8b63b1
commit
2bd30b735d
21 changed files with 607 additions and 185 deletions
|
|
@ -24,7 +24,7 @@ import {
|
|||
createUser,
|
||||
deleteUser,
|
||||
editUser,
|
||||
getRoles,
|
||||
listRole,
|
||||
getUserRoles,
|
||||
removeUserRoles,
|
||||
} from "../services/keycloak";
|
||||
|
|
@ -256,7 +256,7 @@ export class UserController extends Controller {
|
|||
|
||||
const { provinceId, districtId, subDistrictId, username, ...rest } = body;
|
||||
|
||||
let list = await getRoles();
|
||||
let list = await listRole();
|
||||
|
||||
if (!Array.isArray(list)) throw new Error("Failed. Cannot get role(s) data from the server.");
|
||||
if (Array.isArray(list)) {
|
||||
|
|
@ -297,8 +297,8 @@ export class UserController extends Controller {
|
|||
province: { connect: provinceId ? { id: provinceId } : undefined },
|
||||
district: { connect: districtId ? { id: districtId } : undefined },
|
||||
subDistrict: { connect: subDistrictId ? { id: subDistrictId } : undefined },
|
||||
createdBy: req.user.name,
|
||||
updatedBy: req.user.name,
|
||||
createdBy: { connect: { id: req.user.sub } },
|
||||
updatedBy: { connect: { id: req.user.sub } },
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -355,7 +355,7 @@ export class UserController extends Controller {
|
|||
let userRole: string | undefined;
|
||||
|
||||
if (body.userRole) {
|
||||
let list = await getRoles();
|
||||
let list = await listRole();
|
||||
|
||||
if (!Array.isArray(list)) throw new Error("Failed. Cannot get role(s) data from the server.");
|
||||
if (Array.isArray(list)) {
|
||||
|
|
@ -438,7 +438,7 @@ export class UserController extends Controller {
|
|||
connect: subDistrictId ? { id: subDistrictId } : undefined,
|
||||
disconnect: subDistrictId === null || undefined,
|
||||
},
|
||||
updatedBy: req.user.name,
|
||||
updatedBy: { connect: { id: req.user.sub } },
|
||||
},
|
||||
where: { id: userId },
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue