mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-11 09:19:08 +00:00
FIX: get departments and jobTitles
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.8.0",
|
||||
"protospack-v2": "file:../protospack-v2/protospack-v2-0.0.0.tgz",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^7.5.5",
|
||||
@@ -9015,9 +9015,10 @@
|
||||
}
|
||||
},
|
||||
"node_modules/protospack-v2": {
|
||||
"version": "3.8.0",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.8.0.tgz",
|
||||
"integrity": "sha512-hQ6OUPOIKvkB4tYU5hzJFuNrtTKAzmcxmCDudGWUNTsdiophDB02Q8x/9g7Rm8QqkFBqoEIVvYkkWadGwIMjNA==",
|
||||
"version": "0.0.0",
|
||||
"resolved": "file:../protospack-v2/protospack-v2-0.0.0.tgz",
|
||||
"integrity": "sha512-vLg0JzxPz06NxbGAoFu41FfC3Pe8r4UVeybMM4aMvzeUB8QKMbMDLSiAnWXTrbJ9qqGOi3fa7dm9ZWgd+HgCxA==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@grpc/grpc-js": "^1.6.7",
|
||||
"rxjs": "^7.5.5",
|
||||
@@ -17245,9 +17246,8 @@
|
||||
}
|
||||
},
|
||||
"protospack-v2": {
|
||||
"version": "3.8.0",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.8.0.tgz",
|
||||
"integrity": "sha512-hQ6OUPOIKvkB4tYU5hzJFuNrtTKAzmcxmCDudGWUNTsdiophDB02Q8x/9g7Rm8QqkFBqoEIVvYkkWadGwIMjNA==",
|
||||
"version": "file:../protospack-v2/protospack-v2-0.0.0.tgz",
|
||||
"integrity": "sha512-vLg0JzxPz06NxbGAoFu41FfC3Pe8r4UVeybMM4aMvzeUB8QKMbMDLSiAnWXTrbJ9qqGOi3fa7dm9ZWgd+HgCxA==",
|
||||
"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.8.0",
|
||||
"protospack-v2": "file:../protospack-v2/protospack-v2-0.0.0.tgz",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^7.5.5",
|
||||
|
||||
@@ -103,14 +103,13 @@ export class UpdateUserRes {
|
||||
@ApiProperty()
|
||||
user: UserByCustomer;
|
||||
}
|
||||
|
||||
export class GetAllUsersByCustomerIdReq {
|
||||
@ApiPropertyOptional()
|
||||
s?: string;
|
||||
}
|
||||
export class GetAllUsersByCustomerIdRes {
|
||||
@ApiProperty({ type: [UserByCustomer] })
|
||||
users: UserByCustomer[];
|
||||
@ApiProperty()
|
||||
departments: string[];
|
||||
@ApiProperty()
|
||||
jobTitles: string[];
|
||||
}
|
||||
|
||||
export class AssignRoleToUserReq {
|
||||
@@ -153,3 +152,12 @@ export class GetAllHierarchiesRes {
|
||||
@ApiProperty({ type: [Hierarchy] })
|
||||
hierarchies: Hierarchy[];
|
||||
}
|
||||
|
||||
export class GetAllJobTitlesRes {
|
||||
@ApiProperty()
|
||||
jobTitles: string[];
|
||||
}
|
||||
export class GetAllDepartmentsRes {
|
||||
@ApiProperty()
|
||||
departments: string[];
|
||||
}
|
||||
|
||||
@@ -31,7 +31,9 @@ import {
|
||||
CreateUserReq,
|
||||
CreateUserRes,
|
||||
DeleteUserRes,
|
||||
GetAllDepartmentsRes,
|
||||
GetAllHierarchiesRes,
|
||||
GetAllJobTitlesRes,
|
||||
GetAllUsersByCustomerIdRes,
|
||||
SetUserRolesReq,
|
||||
SetUserRolesRes,
|
||||
@@ -72,7 +74,7 @@ export class UsersController {
|
||||
async getAllUsersByCustomerId(
|
||||
@User() user: RequestUser,
|
||||
@Headers('dadosfera-lang') language,
|
||||
) {
|
||||
): Promise<GetAllUsersByCustomerIdRes> {
|
||||
this.logger.info('getAllUsersByCustomerId', { user });
|
||||
this.userService.setLanguage(language);
|
||||
return await this.userService.findAllUsersByCustomerId(user.customer_id);
|
||||
@@ -90,6 +92,30 @@ export class UsersController {
|
||||
return await this.userService.getAllHierarchies();
|
||||
}
|
||||
|
||||
@Get('departments')
|
||||
@RequireAllPermissions(PERMISSIONS.USERS.permissions.ADMIN)
|
||||
@ApiOkResponse({ type: GetAllDepartmentsRes })
|
||||
async getAllDepartments(
|
||||
@User() user: RequestUser,
|
||||
@Headers('dadosfera-lang') language,
|
||||
): Promise<GetAllDepartmentsRes> {
|
||||
this.logger.info('getAllHierarchies', { user });
|
||||
this.userService.setLanguage(language);
|
||||
return await this.userService.getAllDepartments(user.customer_id);
|
||||
}
|
||||
|
||||
@Get('jobTitles')
|
||||
@RequireAllPermissions(PERMISSIONS.USERS.permissions.ADMIN)
|
||||
@ApiOkResponse({ type: GetAllDepartmentsRes })
|
||||
async getAllJobTitles(
|
||||
@User() user: RequestUser,
|
||||
@Headers('dadosfera-lang') language,
|
||||
): Promise<GetAllJobTitlesRes> {
|
||||
this.logger.info('getAllHierarchies', { user });
|
||||
this.userService.setLanguage(language);
|
||||
return await this.userService.getAllJobTitles(user.customer_id);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@RequireAllPermissions(PERMISSIONS.USERS.permissions.ADMIN)
|
||||
@ApiOkResponse({
|
||||
|
||||
@@ -54,7 +54,17 @@ export class UsersService implements OnModuleInit {
|
||||
this.usersClientService.UserFindAllByCustomerId({ customerId }),
|
||||
);
|
||||
this.adjustUsersPayload(users);
|
||||
return { users };
|
||||
const dintinctDepartments = [...new Set(users.map((u) => u.department))]
|
||||
.filter((value) => value != null)
|
||||
.sort();
|
||||
const dintinctJobTitles = [...new Set(users.map((u) => u.jobTitle))]
|
||||
.filter((value) => value != null)
|
||||
.sort();
|
||||
return {
|
||||
users,
|
||||
jobTitles: dintinctJobTitles,
|
||||
departments: dintinctDepartments,
|
||||
};
|
||||
}
|
||||
|
||||
async findOneById(id: string) {
|
||||
@@ -156,6 +166,18 @@ export class UsersService implements OnModuleInit {
|
||||
return { hierarchies };
|
||||
}
|
||||
|
||||
async getAllDepartments(customerId?: string) {
|
||||
return lastValueFrom(
|
||||
this.usersClientService.FindDistinctDepartments({ customerId }),
|
||||
);
|
||||
}
|
||||
|
||||
async getAllJobTitles(customerId?: string) {
|
||||
return lastValueFrom(
|
||||
this.usersClientService.FindDistinctJobTitles({ customerId }),
|
||||
);
|
||||
}
|
||||
|
||||
adjustUsersPayload(users: UserByCustomer[]) {
|
||||
users?.forEach((u) => {
|
||||
if (!u) return;
|
||||
|
||||
Reference in New Issue
Block a user