90 lines
2.4 KiB
TypeScript
90 lines
2.4 KiB
TypeScript
/**
|
|
* UsersService - Gestión de usuarios
|
|
*
|
|
* CRUD de usuarios con soporte multi-tenant y RBAC.
|
|
*
|
|
* @module Users
|
|
*/
|
|
import { Repository } from 'typeorm';
|
|
import { User } from '../../core/entities/user.entity';
|
|
import { Role } from '../../auth/entities/role.entity';
|
|
import { UserRole } from '../../auth/entities/user-role.entity';
|
|
export interface CreateUserDto {
|
|
email: string;
|
|
password: string;
|
|
firstName: string;
|
|
lastName: string;
|
|
tenantId: string;
|
|
roles?: string[];
|
|
}
|
|
export interface UpdateUserDto {
|
|
firstName?: string;
|
|
lastName?: string;
|
|
isActive?: boolean;
|
|
}
|
|
export interface AssignRoleDto {
|
|
userId: string;
|
|
roleCode: string;
|
|
tenantId: string;
|
|
}
|
|
export interface UserListOptions {
|
|
tenantId: string;
|
|
page?: number;
|
|
limit?: number;
|
|
search?: string;
|
|
isActive?: boolean;
|
|
}
|
|
export declare class UsersService {
|
|
private readonly userRepository;
|
|
private readonly roleRepository;
|
|
private readonly userRoleRepository;
|
|
constructor(userRepository: Repository<User>, roleRepository: Repository<Role>, userRoleRepository: Repository<UserRole>);
|
|
/**
|
|
* Listar usuarios de un tenant
|
|
*/
|
|
findAll(options: UserListOptions): Promise<{
|
|
users: User[];
|
|
total: number;
|
|
}>;
|
|
/**
|
|
* Obtener usuario por ID
|
|
*/
|
|
findById(id: string, tenantId: string): Promise<User | null>;
|
|
/**
|
|
* Obtener usuario por email
|
|
*/
|
|
findByEmail(email: string, tenantId: string): Promise<User | null>;
|
|
/**
|
|
* Crear usuario
|
|
*/
|
|
create(dto: CreateUserDto, createdBy?: string): Promise<User>;
|
|
/**
|
|
* Actualizar usuario
|
|
*/
|
|
update(id: string, tenantId: string, dto: UpdateUserDto): Promise<User>;
|
|
/**
|
|
* Soft delete de usuario
|
|
*/
|
|
delete(id: string, tenantId: string, _deletedBy?: string): Promise<void>;
|
|
/**
|
|
* Activar/Desactivar usuario
|
|
*/
|
|
setActive(id: string, tenantId: string, isActive: boolean): Promise<User>;
|
|
/**
|
|
* Asignar rol a usuario
|
|
*/
|
|
assignRole(dto: AssignRoleDto, assignedBy?: string): Promise<UserRole>;
|
|
/**
|
|
* Remover rol de usuario
|
|
*/
|
|
removeRole(userId: string, roleCode: string, tenantId: string): Promise<void>;
|
|
/**
|
|
* Obtener roles de usuario
|
|
*/
|
|
getUserRoles(userId: string, tenantId: string): Promise<Role[]>;
|
|
/**
|
|
* Listar todos los roles disponibles
|
|
*/
|
|
listRoles(): Promise<Role[]>;
|
|
}
|
|
//# sourceMappingURL=users.service.d.ts.map
|