mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-25 14:10:06 +00:00
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { Inject, Injectable } from '@nestjs/common';
|
|
import { ProtoServices } from 'protospack-v2/dist/lib/Duc';
|
|
import { RolesProtoService } from 'protospack-v2/dist/lib/Duc/interfaces/write-service';
|
|
import { GetRolesByCustomerReq } from './dto/entities';
|
|
import { DadosferaLogger } from 'dadosfera-logs';
|
|
import { ClientGrpc } from '@nestjs/microservices';
|
|
import { lastValueFrom } from 'rxjs';
|
|
|
|
@Injectable()
|
|
export class RolesService {
|
|
logger: any;
|
|
|
|
private rolesClientService: RolesProtoService;
|
|
constructor(
|
|
@Inject(DadosferaLogger)
|
|
dadosferaLogger: DadosferaLogger,
|
|
@Inject('DUC_PACKAGE') private readonly grpcClient: ClientGrpc,
|
|
) {
|
|
this.logger = dadosferaLogger.logger;
|
|
}
|
|
|
|
onModuleInit() {
|
|
this.rolesClientService = this.grpcClient.getService<RolesProtoService>(
|
|
ProtoServices.UsersProtoService,
|
|
);
|
|
}
|
|
async getRolesByCustomer(filters: GetRolesByCustomerReq) {
|
|
let { permission_id } = filters;
|
|
if (!Array.isArray(permission_id)) permission_id = [permission_id];
|
|
const { get_users } = filters;
|
|
const is_get_users = get_users === 'true';
|
|
}
|
|
async removeRole(id: string) {
|
|
return lastValueFrom(this.rolesClientService.RoleRemove({ id }));
|
|
}
|
|
}
|