mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-15 12:39:09 +00:00
FIX: get all hierarchies
This commit is contained in:
Generated
+7
-7
@@ -36,7 +36,7 @@
|
||||
"passport-hubspot-oauth2": "^1.0.3",
|
||||
"passport-mailchimp": "^1.1.0",
|
||||
"protospack": "2.5.2",
|
||||
"protospack-v2": "3.6.0",
|
||||
"protospack-v2": "3.6.1",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^7.5.5",
|
||||
@@ -9015,9 +9015,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/protospack-v2": {
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.6.0.tgz",
|
||||
"integrity": "sha512-5yDRmKokHcGflyldmwDB4dnQXUdbn8MhkYD4OPVt1mkS9Vonc/AY6LR2mn7KueAeIFniZRW0cBcIwZLFZEMaVA==",
|
||||
"version": "3.6.1",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.6.1.tgz",
|
||||
"integrity": "sha512-kiulN1JFVAXGcC1lLOeXrB8DvL9gPvujXWYM+iJfoRm/SGDwSnw1LTS3Ytwxg9z55c3LiN9uli6AYXeTU30HcA==",
|
||||
"dependencies": {
|
||||
"@grpc/grpc-js": "^1.6.7",
|
||||
"rxjs": "^7.5.5",
|
||||
@@ -17245,9 +17245,9 @@
|
||||
}
|
||||
},
|
||||
"protospack-v2": {
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.6.0.tgz",
|
||||
"integrity": "sha512-5yDRmKokHcGflyldmwDB4dnQXUdbn8MhkYD4OPVt1mkS9Vonc/AY6LR2mn7KueAeIFniZRW0cBcIwZLFZEMaVA==",
|
||||
"version": "3.6.1",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.6.1.tgz",
|
||||
"integrity": "sha512-kiulN1JFVAXGcC1lLOeXrB8DvL9gPvujXWYM+iJfoRm/SGDwSnw1LTS3Ytwxg9z55c3LiN9uli6AYXeTU30HcA==",
|
||||
"requires": {
|
||||
"@grpc/grpc-js": "^1.6.7",
|
||||
"rxjs": "^7.5.5",
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@
|
||||
"passport-hubspot-oauth2": "^1.0.3",
|
||||
"passport-mailchimp": "^1.1.0",
|
||||
"protospack": "2.5.2",
|
||||
"protospack-v2": "3.6.0",
|
||||
"protospack-v2": "3.6.1",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^7.5.5",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { ApiProperty, ApiPropertyOptional, OmitType } from '@nestjs/swagger';
|
||||
import { RoleDto, UserRole } from 'src/modules/roles/dto/entities';
|
||||
export class Hierarchy {
|
||||
@ApiProperty()
|
||||
id: number;
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
}
|
||||
export class Customer {
|
||||
@ApiProperty()
|
||||
id: string;
|
||||
@@ -149,3 +155,8 @@ export class SetUserRolesRes {
|
||||
}
|
||||
|
||||
export class SearchUserRes extends GetAllUsersByCustomerIdRes {}
|
||||
|
||||
export class GetAllHierarchiesRes {
|
||||
@ApiProperty({ type: [Hierarchy] })
|
||||
hierarchies: Hierarchy[];
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
CreateUserReq,
|
||||
CreateUserRes,
|
||||
DeleteUserRes,
|
||||
GetAllHierarchiesRes,
|
||||
GetAllUsersByCustomerIdRes,
|
||||
SetUserRolesReq,
|
||||
SetUserRolesRes,
|
||||
@@ -59,6 +60,25 @@ export class UsersController {
|
||||
this.logger.info('getAllUsersByCustomerId', { user });
|
||||
return await this.userService.findAllUsersByCustomerId(user.customer_id);
|
||||
}
|
||||
|
||||
@Get('hierarchies')
|
||||
@RequireAllPermissions(PERMISSIONS.USERS.permissions.ADMIN)
|
||||
@ApiOkResponse({ type: GetAllHierarchiesRes })
|
||||
async getAllHierarchies(@User() user: RequestUser) {
|
||||
this.logger.info('getAllHierarchies', { user });
|
||||
return await this.userService.getAllHierarchies();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@RequireAllPermissions(PERMISSIONS.USERS.permissions.ADMIN)
|
||||
@ApiOkResponse({
|
||||
type: UserByCustomer,
|
||||
})
|
||||
async findOneById(@User() user: RequestUser, @Param('id') id: string) {
|
||||
this.logger.info('findOneById', { user });
|
||||
return await this.userService.findOneById(id);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@RequireAllPermissions(PERMISSIONS.USERS.permissions.ADMIN)
|
||||
@ApiCreatedResponse({ type: CreateUserRes })
|
||||
@@ -114,16 +134,6 @@ export class UsersController {
|
||||
return await this.userService.unassignRoleToUser(request);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@RequireAllPermissions(PERMISSIONS.USERS.permissions.ADMIN)
|
||||
@ApiOkResponse({
|
||||
type: UserByCustomer,
|
||||
})
|
||||
async findOneById(@User() user: RequestUser, @Param('id') id: string) {
|
||||
this.logger.info('findOneById', { user });
|
||||
return await this.userService.findOneById(id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
@RequireAllPermissions(PERMISSIONS.USERS.permissions.ADMIN)
|
||||
@ApiOkResponse({ type: UpdateUserRes })
|
||||
@@ -132,7 +142,7 @@ export class UsersController {
|
||||
@Body() body: UpdateUserReq,
|
||||
@Param('id') id: string,
|
||||
) {
|
||||
this.logger.info('createUser', { user });
|
||||
this.logger.info('updateUser', { user });
|
||||
return await this.userService.updateUser(body, id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ export class UsersService implements OnModuleInit {
|
||||
const roles: any[] = this.rolesService.getRolesPermissionsName(u.roles);
|
||||
u.roles = roles;
|
||||
});
|
||||
return users;
|
||||
return { users };
|
||||
}
|
||||
|
||||
async findOneById(id: string) {
|
||||
@@ -60,7 +60,7 @@ export class UsersService implements OnModuleInit {
|
||||
);
|
||||
user.roles = roles;
|
||||
}
|
||||
return user;
|
||||
return { user };
|
||||
}
|
||||
|
||||
async createUser(req: CreateUserReq) {
|
||||
@@ -82,7 +82,7 @@ export class UsersService implements OnModuleInit {
|
||||
);
|
||||
user.roles = roles;
|
||||
}
|
||||
return user;
|
||||
return { user };
|
||||
}
|
||||
|
||||
async updateUser(req: UpdateUserReq, id: string) {
|
||||
@@ -103,7 +103,7 @@ export class UsersService implements OnModuleInit {
|
||||
);
|
||||
user.roles = roles;
|
||||
}
|
||||
return user;
|
||||
return { user };
|
||||
}
|
||||
|
||||
async setRoles(body: SetUserRolesReq) {
|
||||
@@ -123,7 +123,7 @@ export class UsersService implements OnModuleInit {
|
||||
);
|
||||
user.roles = roles;
|
||||
}
|
||||
return user;
|
||||
return { user };
|
||||
}
|
||||
async batchCreateUser({ users }: BatchCreateUserReq) {
|
||||
const usersToCreate: UserCreateRequest[] = users.map((u) => ({
|
||||
@@ -155,4 +155,7 @@ export class UsersService implements OnModuleInit {
|
||||
async deleteUser(id: IdRequest) {
|
||||
return lastValueFrom(this.usersClientService.UserRemove(id));
|
||||
}
|
||||
async getAllHierarchies() {
|
||||
return lastValueFrom(this.usersClientService.UserFindAllHierarchies({}));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user