/*
 * @Author: wangyang 1147192855@qq.com
 * @Date: 2022-07-13 18:30:11
 * @LastEditors: wangyang 1147192855@qq.com
 * @LastEditTime: 2022-07-14 10:20:21
 * @FilePath: \marking_app\lib\common\model\common\base_structure_result.dart
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import 'package:json_annotation/json_annotation.dart';
import 'package:wgshare/common/config/request_config.dart';

part 'base_structure_result.g.dart';

@JsonSerializable(genericArgumentFactories: true, fieldRename: FieldRename.snake,checked: true)
class BaseStructureResult<T> extends Object {
  @JsonKey(name: 'code')
  int code;

  @JsonKey(name: 'message')
  String? message;

  @JsonKey(name: 'data')
  T? data;

  @JsonKey(name: 'success')
  bool success;

  BaseStructureResult(this.code, this.message, this.data, {this.success = false}) {
    success = RequestConfig.resultCode.contains(code);
  }
  factory BaseStructureResult.fromJson(Map<String, dynamic> json, T Function(dynamic json) fromJsonT) =>
      _$BaseStructureResultFromJson(json, fromJsonT);
  Map<String, dynamic> toJson(Object Function(T value) toJsonT) => _$BaseStructureResultToJson(this, toJsonT);
}
