mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-11 17:19:08 +00:00
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import { OnModuleInit, Inject, Injectable } from '@nestjs/common';
|
|
import { ClientGrpc } from '@nestjs/microservices';
|
|
import { DadosferaLogger } from 'dadosfera-logs';
|
|
|
|
import { ProtoServices } from 'protospack-v2/dist/lib/Duc';
|
|
import { UsersProtoService } from 'protospack-v2/dist/lib/Duc/interfaces/write-service';
|
|
import {
|
|
AssignRoleToUserRequest,
|
|
IdRequest,
|
|
UnassignRoleFromUserRequest,
|
|
} from 'protospack-v2/dist/lib/Duc/interfaces/messages';
|
|
import { lastValueFrom } from 'rxjs';
|
|
|
|
@Injectable()
|
|
export class UsersService implements OnModuleInit {
|
|
logger: any;
|
|
|
|
private usersService: UsersProtoService;
|
|
constructor(
|
|
@Inject(DadosferaLogger)
|
|
dadosferaLogger: DadosferaLogger,
|
|
@Inject('DUC_PACKAGE') private readonly grpcClient: ClientGrpc,
|
|
) {
|
|
this.logger = dadosferaLogger.logger;
|
|
}
|
|
|
|
onModuleInit() {
|
|
this.usersService = this.grpcClient.getService<UsersProtoService>(
|
|
ProtoServices.UsersProtoService,
|
|
);
|
|
}
|
|
|
|
async findAllUsersByCustomerId(customerId, searchQuery) {
|
|
return lastValueFrom(
|
|
this.usersService.UserFindAllByCustomerId({ customerId }),
|
|
);
|
|
}
|
|
|
|
async assignRoleToUser(body: AssignRoleToUserRequest) {
|
|
return lastValueFrom(this.usersService.AssignRoleToUser(body));
|
|
}
|
|
|
|
async unassignRoleToUser(body: UnassignRoleFromUserRequest) {
|
|
return lastValueFrom(this.usersService.UnassignRoleFromUser(body));
|
|
}
|
|
|
|
async deleteUser(id: IdRequest) {
|
|
return lastValueFrom(this.usersService.UserRemove(id));
|
|
}
|
|
}
|