mapData
This commit is contained in:
parent
7fdd950c85
commit
ef4d34d333
2 changed files with 40 additions and 2 deletions
|
|
@ -28,6 +28,7 @@ import {
|
|||
removeUserGroup,
|
||||
removeUserRoles,
|
||||
getRoleMappings,
|
||||
getUserCount
|
||||
} from "../keycloak";
|
||||
// import * as io from "../lib/websocket";
|
||||
// import elasticsearch from "../elasticsearch";
|
||||
|
|
@ -199,10 +200,28 @@ export class KeycloakController extends Controller {
|
|||
|
||||
@Get("user")
|
||||
async getUserList(@Query() first = "", @Query() max = "" ,@Query() search = "") {
|
||||
const total = await getUserCount();
|
||||
const result = await getUserList(first, max, search);
|
||||
|
||||
if (Array.isArray(result)) {
|
||||
return result;
|
||||
const mappedData = await Promise.all(result.map(async (x) => {
|
||||
const roles = await getRoleMappings(x.id);
|
||||
return {
|
||||
id: x.id,
|
||||
username: x.username,
|
||||
firstname: x.firstName,
|
||||
lastname: x.lastName,
|
||||
email: x.email,
|
||||
roles: roles
|
||||
};
|
||||
}));
|
||||
|
||||
const _mapData = {
|
||||
data: mappedData,
|
||||
total: total
|
||||
};
|
||||
|
||||
return _mapData;
|
||||
}
|
||||
throw new Error("Failed. Cannot get user list.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue