import 'Network/HttpManager.dart';
import 'UserModel.dart';

/// 所有接口类
class LoginApi {
  ///示例请求
  static loginRequest(Map<String, dynamic> param, OnResult onResult) {
    return HttpManager.getInstance().request('auth/oauth/token', parameters: param, onResult: (data,errorMsg){
      UserModel userModel = UserModel.fromJson(data.data);
      UserModel.saveModel(userModel);
      print(UserModel.getModel().token);
      if(onResult != null){
        onResult(data, errorMsg);
      }
    });
  }

  ///上传头像
  static uploadAvatarRequest(List images, OnResult onResult) {
    return HttpManager.getInstance().request('file/upload', parameters: null,method: "POST", images: images,onResult: (data,errorMsg){
      if(onResult != null){
        onResult(data, errorMsg);
      }
    });
  }

  ///请求列表数据
  static requestListData(Map<String, dynamic> param, OnResult onResult) {
    return HttpManager.getInstance().request('exam/user/0', parameters: param,onResult: (data,errorMsg){
      if(onResult != null){
        onResult(data, errorMsg);
      }
    });
  }
}
