/*
 * @Author: XianKaiQun
 * @Date: 2020-09-18 11:33:35
 * @LastEditors: XianKaiQun
 * @LastEditTime: 2020-09-18 15:29:08
 * @Description: 
 */
import 'package:app_package/app_package.dart';
import 'package:qrcode_package/src/models/cheat_setting.dart';
import 'package:qrcode_package/src/service/qr_service.dart';

class QrServiceImpl implements QrService {
  QrServiceImpl._();
  static QrServiceImpl? _instance;
  static QrServiceImpl? get instance {
    _instance ??= QrServiceImpl._();
    return _instance;
  }

  @override
  Future<ResModel<List<CheatSettingModel>?>> getCheatSetting(data) async {
    var res = await HttpUtil.instance.get(
      '/app/admin/qrcodeManagement/cheat/setting',
      queryParameters: data,
    );

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