user_rsp.dart 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import 'package:json_annotation/json_annotation.dart';
  2. part 'user_rsp.g.dart';
  3. @JsonSerializable(genericArgumentFactories: true)
  4. class UserRsp {
  5. /*
  6. {
  7. "id": 1,
  8. "username": "admin",
  9. "nickname": "超级管理员",
  10. "email": "aoteman@126.com",
  11. "mobile": "15612345678",
  12. "sex": 1,
  13. "avatar": "http://127.0.0.1:48080/admin-api/infra/file/4/get/37e56010ecbee472cdd821ac4b608e151e62a74d9633f15d085aee026eedeb60.png",
  14. "loginIp": "210.12.51.197",
  15. "loginDate": 1708417207000,
  16. "createTime": 1609837427000,
  17. "roles": [
  18. {
  19. "id": 1,
  20. "name": "超级管理员"
  21. }
  22. ],
  23. "dept": {
  24. "id": 3010,
  25. "name": "国家局",
  26. "parentId": 0,
  27. "tyshxydm": null,
  28. "isRoot": null
  29. },
  30. "posts": [
  31. {
  32. "id": 1,
  33. "name": "董事长"
  34. }
  35. ],
  36. "socialUsers": []
  37. }
  38. */
  39. final num? id;
  40. final String? username;
  41. final String? nickname;
  42. final String? email;
  43. final String? mobile;
  44. final num? sex;
  45. final String? avatar;
  46. final String? loginIp;
  47. final num? loginDate;
  48. final num? createTime;
  49. final List<EnumRsp>? roles;
  50. final DepartmentRsp? dept;
  51. final List<EnumRsp>? posts;
  52. const UserRsp({
  53. this.id,
  54. this.username,
  55. this.nickname,
  56. this.email,
  57. this.mobile,
  58. this.sex,
  59. this.avatar,
  60. this.loginIp,
  61. this.loginDate,
  62. this.createTime,
  63. this.roles,
  64. this.dept,
  65. this.posts,
  66. });
  67. factory UserRsp.fromJson(Map<String, dynamic> json) => _$UserRspFromJson(json);
  68. Map<String, dynamic> toJson() => _$UserRspToJson(this);
  69. String? getMobile() {
  70. if (mobile == null) return null;
  71. var start = mobile!.substring(0, 3);
  72. var end = mobile!.substring(mobile!.length - 3);
  73. return '$start*****$end';
  74. }
  75. }
  76. @JsonSerializable(genericArgumentFactories: true)
  77. class DepartmentRsp {
  78. final num? id;
  79. final String? name;
  80. final num? parentId;
  81. const DepartmentRsp({
  82. this.id,
  83. this.name,
  84. this.parentId,
  85. });
  86. factory DepartmentRsp.fromJson(Map<String, dynamic> json) => _$DepartmentRspFromJson(json);
  87. Map<String, dynamic> toJson() => _$DepartmentRspToJson(this);
  88. }
  89. @JsonSerializable(genericArgumentFactories: true)
  90. class EnumRsp {
  91. final num? id;
  92. final String? name;
  93. const EnumRsp({
  94. this.id,
  95. this.name,
  96. });
  97. factory EnumRsp.fromJson(Map<String, dynamic> json) => _$EnumRspFromJson(json);
  98. Map<String, dynamic> toJson() => _$EnumRspToJson(this);
  99. }