/*
 * @Author: XianKaiQun
 * @Date: 2020-04-21 10:15:35
 * @LastEditors  : WuWei
 * @LastEditTime : 2023-05-16 09:25:05
 * @Descripttion: 
 */
import 'package:app_package/app_package.dart';
import 'package:dio/dio.dart';

class AuthApi {
  ///登录
  ///
  static Future<ResModel<LoginModel>> postLogin(entCode, Map data) async {
    var res = await HttpUtil.instance.post(
      'auth/login',
      data: data,
      options: Options(headers: {'entcode': entCode}),
    );
    return ResModel<LoginModel>(
      json: res.data,
      to: (v) => v.toJson(),
      from: (v) => LoginModel.fromJson(v),
    );
  }

  ///修改密码
  static Future<bool?> putPswMotify(Map data) async {
    var res = await HttpUtil.instance.put(
      'auth/app/psw/alter',
      data: data,
    );
    if (res.data['data'] != null && res.data['data'] is bool) {
      return res.data['data'];
    } else {
      return null;
    }
  }

  ///退出登录
  static Future<ResModel<String?>> getLogout() async {
    var res = await HttpUtil.instance.get(
      'auth/logout',
    );
    return ResModel<String?>(
      json: res.data,
      to: (v) => v,
      from: (v) => v,
    );
  }
}
