user_model.dart 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import 'package:flutter_provider_demo/model/base_model.dart';
  2. /// Description:
  3. /// Time : 09/03/2023 Sunday
  4. /// Author : liuyuqi.gov@msn.cn
  5. class UserModel extends BaseModel {
  6. String name = "";
  7. int age = 18;
  8. String email = "";
  9. String password = "";
  10. String phone = "";
  11. String address = "";
  12. String avator = "";
  13. String token = "";
  14. String createdAt = "";
  15. UserModel({
  16. required this.name,
  17. required this.age,
  18. required this.email,
  19. required this.password,
  20. required this.phone,
  21. required this.address,
  22. required this.avator,
  23. required this.token,
  24. required this.createdAt,
  25. });
  26. UserModel.fromJson(Map<String, dynamic> json) {
  27. id = json['id'];
  28. name = json['name'];
  29. age = json['age'];
  30. email = json['email'];
  31. password = json['password'];
  32. phone = json['phone'];
  33. address = json['address'];
  34. avator = json['avator'];
  35. token = json['token'];
  36. createdAt = json['createdAt'];
  37. }
  38. Map<String, dynamic> toJson() {
  39. return {
  40. 'id': id,
  41. 'name': name,
  42. 'age': age,
  43. 'email': email,
  44. 'password': password,
  45. 'phone': phone,
  46. 'address': address,
  47. 'avator': avator,
  48. 'token': token,
  49. 'createdAt': createdAt,
  50. };
  51. }
  52. }
  53. class UserEntity extends BaseEntity {
  54. UserEntity({required int code, required String msg, UserModel? data})
  55. : super(code: code, msg: msg, data: data);
  56. UserEntity.fromJson(Map<String, dynamic> json)
  57. : super(
  58. code: int.parse(json["code"]),
  59. msg: json["msg"],
  60. ) {
  61. if (json['data'] != null) {
  62. data = UserModel.fromJson(json['data']);
  63. }
  64. }
  65. }