mirror of
https://github.com/dadosfera/maestro.git
synced 2026-12-04 15:50:04 +00:00
FEAT: Users roles id = seqid
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user