import { Injectable, Inject } from '@nestjs/common'; import { IPaginator } from '@devstroupe/devkit-core'; import { IRoleRepository } from '../domain/role.repository'; import { Role } from '../domain/role'; @Injectable() export class RoleService { constructor( @Inject('IRoleRepository') private readonly roleRepo: IRoleRepository, ) {} async create(role: Omit): Promise { const existing = await this.roleRepo.findByName(role.name); if (existing) { throw new Error('Role name already exists'); } return this.roleRepo.create(role); } async update(id: number, role: Partial): Promise { return this.roleRepo.update(id, role); } async findById(id: number): Promise { return this.roleRepo.findById(id); } async findByName(name: string): Promise { return this.roleRepo.findByName(name); } async findAll(): Promise { return this.roleRepo.findAll(); } async findMany(query: any): Promise> { return this.roleRepo.findMany(query); } async delete(id: number): Promise { await this.roleRepo.delete(id); } }