import '../utils/http/response_model.dart';
import '../utils/http/dio_request.dart';
import '../models/bo/device_list_bo.dart';

class DeviceListRepository {
  /// 获取全部设备列表（分页）
  /// GET /app/device/list
  Future<ResponseModel<DeviceListBO>> getList({
    required int pageSize,
    required int pageNum,
    String? deviceTypeId,
  }) {
    final params = <String, dynamic>{
      'pageSize': pageSize,
      'pageNum': pageNum,
    };
    if (deviceTypeId != null) {
      params['accessType'] = deviceTypeId;
    }

    return DioRequest.instance.get<DeviceListBO>(
      '/app/device/list',
      queryParameters: params,
      fromJsonT: (data) =>
          DeviceListBO.fromJson(data as Map<String, dynamic>),
    );
  }
}
