FEAT: Users roles id = seqid

This commit is contained in:
Gabriel Rosa
2022-07-18 14:04:35 -03:00
parent 52f9d06ad0
commit 82310c6314
11 changed files with 193 additions and 54 deletions
+48 -1
View File
@@ -10,6 +10,11 @@ import {
UnassignRoleFromUserRequest,
} from 'protospack-v2/dist/lib/Duc/interfaces/messages';
import { lastValueFrom } from 'rxjs';
import {
BatchCreateUserReq,
CreateUserReq,
UpdateUserReq,
} from './dtos/entities';
@Injectable()
export class UsersService implements OnModuleInit {
@@ -30,12 +35,54 @@ export class UsersService implements OnModuleInit {
);
}
async findAllUsersByCustomerId(customerId, searchQuery) {
async findAllUsersByCustomerId(customerId: string) {
return lastValueFrom(
this.usersService.UserFindAllByCustomerId({ customerId }),
);
}
async findOneById(id: string) {
return lastValueFrom(this.usersService.UserFindOneById({ id }));
}
async createUser(user: CreateUserReq) {
const { email, department, hierarchy, jobTitle, name, roles } = user;
return lastValueFrom(
this.usersService.UserCreate({
email,
hierarchy,
name,
roleIds: roles,
department,
jobTitle,
}),
);
}
async updateUser(user: UpdateUserReq, id: string) {
const { department, hierarchy, jobTitle, name, roles } = user;
return lastValueFrom(
this.usersService.UserUpdate({
name,
customerId: '',
id,
}),
);
}
async batchCreateUser({ users }: BatchCreateUserReq) {
const usersToCreate = users.map((u) => ({
...u,
roleIds: u.roles,
name: u.name || '',
hierarchy: u.hierarchy || null,
}));
return lastValueFrom(
this.usersService.UserBatchCreate({
users: usersToCreate,
}),
);
}
async assignRoleToUser(body: AssignRoleToUserRequest) {
return lastValueFrom(this.usersService.AssignRoleToUser(body));
}