import 'package:dartz/dartz.dart';
import 'package:injectable/injectable.dart';
import '../../../core/constants/app_constants.dart';
import '../../../models/user_model.dart';
import '../../../core/errors/failures.dart';
import '../../repositories/user_repository.dart';
import '../../../data/models/common/paginated_response.dart';
import '../base_usecase.dart';

/// 사용자 목록 조회 파라미터 (UI 호환 파라미터 포함)
class GetUsersParams {
  final int page;
  final int perPage;
  final UserRole? role;
  final bool? isActive;

  const GetUsersParams({
    this.page = 1,
    this.perPage = AppConstants.userPageSize,
    this.role,
    this.isActive,
  });
}

/// 사용자 목록 조회 UseCase (Clean Architecture Domain Layer)
/// 페이지네이션과 필터링을 지원하는 사용자 목록 조회
@injectable
class GetUsersUseCase extends UseCase<PaginatedResponse<User>, GetUsersParams> {
  final UserRepository _userRepository;

  GetUsersUseCase(this._userRepository);

  @override
  Future<Either<Failure, PaginatedResponse<User>>> call(GetUsersParams params) async {
    return await _userRepository.getUsers(
      page: params.page,
      perPage: params.perPage,
      role: params.role,
      isActive: params.isActive,
    );
  }
}