/*
 * @Author       : WuWei
 * @LastEditors  : WuWei
 * @Date         : 2022-10-10 10:46:15
 * @LastEditTime : 2023-05-15 15:39:07
 * @Description  : Do not edit
 */

import 'package:app_package/app_package.dart';
import 'package:statistics_package/src/models/charge_model.dart';
import 'package:statistics_package/src/models/company_community.dart';
import 'package:statistics_package/src/models/release_model.dart';
import 'package:statistics_package/src/models/serve_model.dart';
import 'package:statistics_package/src/models/work_model.dart';

import '../statistics_service.dart';

class StatisticsServiceImpl implements StatisticsService {
  static StatisticsServiceImpl? get instance => _getInstance();
  static StatisticsServiceImpl? _instance;
  StatisticsServiceImpl._internal() {
    // 初始化
  }
  static StatisticsServiceImpl? _getInstance() {
    if (_instance == null) {
      _instance = new StatisticsServiceImpl._internal();
    }
    return _instance;
  }

  Future<ResModel<List<CompanyCommunityModel>>>
      getCompanyCommunityList() async {
    var res = await HttpUtil.instance.get(
      '/app/admin/statistics/sift',
    );

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

  /// 物业服务
  Future<ResModel<List<ServeModel>>> getServe(data) async {
    var res = await HttpUtil.instance.post(
      '/app/admin/statistics/property/serve',
      data: data,
    );

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

  /// 物业收费
  Future<ResModel<ChargeModel>> getFee(data) async {
    var res = await HttpUtil.instance.post(
      '/app/admin/statistics/property/charge',
      data: data,
    );

    return ResModel<ChargeModel>(
      json: res.data,
      to: (v) => v.toJson(),
      from: (v) => ChargeModel.fromJson(v),
    );
  }

  /// 物业工作
  Future<ResModel<WorkModel>> getWork(data) async {
    var res = await HttpUtil.instance.post(
      '/app/admin/statistics/property/work',
      data: data,
    );

    return ResModel<WorkModel>(
      json: res.data,
      to: (v) => v.toJson(),
      from: (v) => WorkModel.fromJson(v),
    );
  }

  /// 信息发布
  Future<ResModel<List<ReleaseModel>>> getRelease(data) async {
    var res = await HttpUtil.instance.post(
      '/app/admin/statistics/info/release',
      data: data,
    );

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

  /// 信息公示
  Future<ResModel<List<ReleaseModel>>> getAnnouncement(data) async {
    var res = await HttpUtil.instance.post(
      '/app/admin/statistics/info/release',
      data: data,
    );

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

  /// 设施设备
  Future<ResModel<List<ReleaseModel>>> getFacility(data) async {
    var res = await HttpUtil.instance.post(
      '/app/admin/statistics/file/facility',
      data: data,
    );

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

  ///供电设施
  Future<ResModel<List<ReleaseModel>>> getPower(data) async {
    var res = await HttpUtil.instance.post(
      '/app/admin/statistics/file/power',
      data: data,
    );

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

  /// 绿化情况
  Future<ResModel<List<ReleaseModel>>> getGreen(data) async {
    var res = await HttpUtil.instance.post(
      '/app/admin/statistics/file/green',
      data: data,
    );

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

  /// 卫生设施
  Future<ResModel<List<ReleaseModel>>> getHealth(data) async {
    var res = await HttpUtil.instance.post(
      '/app/admin/statistics/file/green',
      data: data,
    );

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

  /// 安防设施
  Future<ResModel<List<ReleaseModel>>> getSecurity(data) async {
    var res = await HttpUtil.instance.post(
      '/app/admin/statistics/file/security',
      data: data,
    );

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

  /// 消防设施
  Future<ResModel<List<ReleaseModel>>> getFire(data) async {
    var res = await HttpUtil.instance.post(
      '/app/admin/statistics/file/fire',
      data: data,
    );

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

  /// 资产档案
  Future<ResModel<List<ReleaseModel>>> getAsset(data) async {
    var res = await HttpUtil.instance.post(
      '/app/admin/statistics/file/asset',
      data: data,
    );

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