/*
 * @Author: XianKaiQun
 * @Date: 2020-09-02 11:01:31
 * @LastEditors: ChenYaJin
 * @LastEditTime: 2022-12-12 11:36:45
 * @Description: 
 */
import 'package:app_package/app_package.dart';
import '../models/cascade_house.dart';

class RequestApi {
  ///获取楼栋
  Future<ResModel<List<CascadeHouseModel>>> getBuildInfo(data) async {
    var res = await HttpUtil.instance.get(
      '/app/admin/assets/getBuildInfo',
      queryParameters: data,
    );

    return ResModel<List<CascadeHouseModel>>(
      json: res.data,
      to: (v) => (v).map((f) => f.toJson()).toList(),
      from: (v) => (v ?? [])
          .map<CascadeHouseModel>(
            (f) => CascadeHouseModel.fromJson(f),
          )
          .toList(),
    );
  }

  ///获取单元
  Future<ResModel<List<CascadeHouseModel>>> getUnitInfo(data) async {
    var res = await HttpUtil.instance.get(
      '/app/admin/assets/getUnitInfo',
      queryParameters: data,
    );

    return ResModel<List<CascadeHouseModel>>(
      json: res.data,
      to: (v) => (v).map((f) => f.toJson()).toList(),
      from: (v) => (v ?? [])
          .map<CascadeHouseModel>(
            (f) => CascadeHouseModel.fromJson(f),
          )
          .toList(),
    );
  }

  ///获取楼层
  Future<ResModel<List<CascadeHouseModel>>> getFloorInfo(data) async {
    var res = await HttpUtil.instance.get(
      '/app/admin/assets/getFloorInfo',
      queryParameters: data,
    );

    return ResModel<List<CascadeHouseModel>>(
      json: res.data,
      to: (v) => (v).map((f) => f.toJson()).toList(),
      from: (v) => (v ?? [])
          .map<CascadeHouseModel>(
            (f) => CascadeHouseModel.fromJson(f),
          )
          .toList(),
    );
  }

  ///获取房屋
  Future<ResModel<List<CascadeHouseModel>>> getHouseInfo(data) async {
    var res = await HttpUtil.instance.get(
      '/app/admin/assets/getHouseInfo',
      queryParameters: data,
    );

    return ResModel<List<CascadeHouseModel>>(
      json: res.data,
      to: (v) => (v).map((f) => f.toJson()).toList(),
      from: (v) => (v ?? [])
          .map<CascadeHouseModel>(
            (f) => CascadeHouseModel.fromJson(f),
          )
          .toList(),
    );
  }
}
