user.m.dart 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. enum UserInfoStateEnum {
  2. Nonactivated,
  3. Activated,
  4. }
  5. class UserInfo {
  6. String? userCode;
  7. String? userName;
  8. String? phone;
  9. String? email;
  10. String? nickName;
  11. String? fullName;
  12. String? headImageToken;
  13. String? organizationCode;
  14. List<String>? authorityGroups;
  15. List<String>? bindDevices;
  16. int score;
  17. String? lastIP;
  18. UserInfoStateEnum userState;
  19. String? securityQuestion;
  20. String? securityAnswers;
  21. DateTime? createTime;
  22. DateTime? updateTime;
  23. UserInfo({
  24. this.userCode,
  25. this.userName,
  26. this.phone,
  27. this.email,
  28. this.nickName,
  29. this.fullName,
  30. this.headImageToken,
  31. this.organizationCode,
  32. this.authorityGroups,
  33. this.bindDevices,
  34. this.score=0,
  35. this.lastIP,
  36. this.userState=UserInfoStateEnum.Nonactivated,
  37. this.securityQuestion,
  38. this.securityAnswers,
  39. this.createTime,
  40. this.updateTime,
  41. });
  42. factory UserInfo.fromJson(Map<String, dynamic> map) {
  43. return UserInfo(
  44. userCode: map['UserCode'],
  45. userName: map['UserName'],
  46. phone: map['Phone'],
  47. email: map['Email'],
  48. nickName: map['NickName'],
  49. fullName: map['FullName'],
  50. headImageToken: map['HeadImageToken'],
  51. organizationCode: map['OrganizationCode'],
  52. authorityGroups: map['AuthorityGroups'].cast<String>().toList(),
  53. bindDevices: map['BindDevices'].cast<String>().toList(),
  54. score: map['Score'],
  55. lastIP: map['LastIP'],
  56. userState: UserInfoStateEnum.values.firstWhere((e) => e.index == map['UserState']),
  57. securityQuestion: map['SecurityQuestion'],
  58. securityAnswers: map['SecurityAnswers'],
  59. createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null,
  60. updateTime: map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null,
  61. );
  62. }
  63. Map<String, dynamic> toJson() {
  64. final map = Map<String, dynamic>();
  65. if(userCode != null)
  66. map['UserCode'] = userCode;
  67. if(userName != null)
  68. map['UserName'] = userName;
  69. if(phone != null)
  70. map['Phone'] = phone;
  71. if(email != null)
  72. map['Email'] = email;
  73. if(nickName != null)
  74. map['NickName'] = nickName;
  75. if(fullName != null)
  76. map['FullName'] = fullName;
  77. if(headImageToken != null)
  78. map['HeadImageToken'] = headImageToken;
  79. if(organizationCode != null)
  80. map['OrganizationCode'] = organizationCode;
  81. if(authorityGroups != null)
  82. map['AuthorityGroups'] = authorityGroups;
  83. if(bindDevices != null)
  84. map['BindDevices'] = bindDevices;
  85. map['Score'] = score;
  86. if(lastIP != null)
  87. map['LastIP'] = lastIP;
  88. map['UserState'] = userState.index;
  89. if(securityQuestion != null)
  90. map['SecurityQuestion'] = securityQuestion;
  91. if(securityAnswers != null)
  92. map['SecurityAnswers'] = securityAnswers;
  93. if(createTime != null)
  94. map['CreateTime'] = createTime;
  95. if(updateTime != null)
  96. map['UpdateTime'] = updateTime;
  97. return map;
  98. }
  99. }