login.m.dart 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. enum LoginType {
  2. UserNameAndPwd,
  3. MobileNumber,
  4. }
  5. enum RegisterType {
  6. MobileNumber,
  7. Email,
  8. }
  9. class LoginRequest {
  10. final LoginType loginType;
  11. final ProcessorInfo processorInfo;
  12. final ClientInfo? clientInfo;
  13. LoginRequest({
  14. required this.loginType,
  15. required this.processorInfo,
  16. this.clientInfo,
  17. });
  18. Map<String, dynamic> toJson() {
  19. final map = Map<String, dynamic>();
  20. map['LoginType'] = loginType.index;
  21. map['ProcessorInfo'] = processorInfo;
  22. if (clientInfo != null) map['ClientInfo'] = clientInfo;
  23. return map;
  24. }
  25. }
  26. class ProcessorInfo {
  27. final String? userName;
  28. final String? password;
  29. ProcessorInfo({
  30. this.userName,
  31. this.password,
  32. });
  33. factory ProcessorInfo.fromJson(Map<String, dynamic> map) {
  34. return ProcessorInfo(
  35. userName: map['UserName'],
  36. password: map['Password'],
  37. );
  38. }
  39. Map<String, dynamic> toJson() {
  40. final map = Map<String, dynamic>();
  41. if (userName != null && userName!.isNotEmpty) map['UserName'] = userName;
  42. if (password != null && password!.isNotEmpty) map['Password'] = password;
  43. return map;
  44. }
  45. }
  46. class ClientInfo {
  47. final String? clientSource;
  48. ClientInfo({
  49. this.clientSource,
  50. });
  51. factory ClientInfo.fromJson(Map<String, dynamic> map) {
  52. return ClientInfo(
  53. clientSource: map['ClientSource'],
  54. );
  55. }
  56. Map<String, dynamic> toJson() {
  57. final map = Map<String, dynamic>();
  58. if (clientSource != null && clientSource!.isNotEmpty)
  59. map['ClientSource'] = clientSource;
  60. return map;
  61. }
  62. }
  63. class LoginResult {
  64. final String userCode;
  65. final String sessionId;
  66. final String? deviceId;
  67. LoginResult({
  68. required this.userCode,
  69. required this.sessionId,
  70. this.deviceId,
  71. });
  72. factory LoginResult.fromJson(Map<String, dynamic> map) {
  73. return LoginResult(
  74. userCode: map['UserCode'],
  75. sessionId: map['SessionId'],
  76. deviceId: map['DeviceId'],
  77. );
  78. }
  79. }
  80. class SignInRequest {
  81. final String userName;
  82. final String secretPassword;
  83. final String? phone;
  84. final String? email;
  85. final String? nickName;
  86. final String? fullName;
  87. final String? headImageToken;
  88. final String? lastIp;
  89. SignInRequest({
  90. required this.userName,
  91. required this.secretPassword,
  92. this.phone,
  93. this.email,
  94. this.nickName,
  95. this.fullName,
  96. this.headImageToken,
  97. this.lastIp,
  98. });
  99. Map<String, dynamic> toJson() {
  100. final map = Map<String, dynamic>();
  101. map['UserName'] = userName;
  102. map['SecretPassword'] = secretPassword;
  103. if (phone != null && phone!.isNotEmpty) map['Phone'] = phone;
  104. if (email != null && email!.isNotEmpty) map['Email'] = email;
  105. if (nickName != null && nickName!.isNotEmpty) map['NickName'] = nickName;
  106. if (fullName != null && fullName!.isNotEmpty) map['FullName'] = fullName;
  107. if (headImageToken != null && headImageToken!.isNotEmpty)
  108. map['HeadImageToken'] = headImageToken;
  109. if (lastIp != null && lastIp!.isNotEmpty) map['LastIp'] = lastIp;
  110. return map;
  111. }
  112. }