import 'package:json_annotation/json_annotation.dart';
part 'BaseHttpModel.g.dart';

@JsonSerializable()
class BaseHttpModel{
  final data;
  int code;
  String msg;

  BaseHttpModel(this.data, this.code, this.msg);

  factory BaseHttpModel.fromJson(Map<String, dynamic> json) => _$BaseHttpModelFromJson(json);
  Map<String, dynamic> toJson() => _$BaseHttpModelToJson(this);

  bool isSuccess(){
    return this.code == 0;
  }

  String errorMsg() {
    return this.msg.length > 0 ? this.msg : '网络有误，请稍后再试';
  }
}
