base_model_entity.dart 710 B

1234567891011121314151617181920212223242526272829
  1. import 'package:hengyi/generated/json/base/json_field.dart';
  2. import 'package:hengyi/generated/json/base_model_entity.g.dart';
  3. import 'dart:convert';
  4. @JsonSerializable()
  5. class BaseModelEntity<T> {
  6. late int code;
  7. late String msg;
  8. late T data;
  9. BaseModelEntity();
  10. factory BaseModelEntity.fromJson(Map<String, dynamic> json) =>
  11. $BaseModelEntityFromJson(json);
  12. Map<String, dynamic> toJson() => $BaseModelEntityToJson(this);
  13. BaseModelEntity copyWith({int? code, String? msg, String? data}) {
  14. return BaseModelEntity()
  15. ..code = code ?? this.code
  16. ..msg = msg ?? this.msg
  17. ..data = data ?? this.data;
  18. }
  19. @override
  20. String toString() {
  21. return jsonEncode(this);
  22. }
  23. }