login.m.dart 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. import 'authentication.m.dart';
  2. import 'notification.m.dart';
  3. import 'liveConsultation.m.dart';
  4. enum LoginStateEnum {
  5. Succeed,
  6. PasswordIncorrect,
  7. }
  8. class LoginResult {
  9. LoginStateEnum loginState;
  10. String? token;
  11. int? lockRemainingTimes;
  12. bool passwordExpired;
  13. String? accountName;
  14. LoginResult({
  15. this.loginState = LoginStateEnum.Succeed,
  16. this.token,
  17. this.lockRemainingTimes,
  18. this.passwordExpired = false,
  19. this.accountName,
  20. });
  21. factory LoginResult.fromJson(Map<String, dynamic> map) {
  22. return LoginResult(
  23. loginState: LoginStateEnum.values.firstWhere((e) => e.index == map['LoginState']),
  24. token: map['Token'],
  25. lockRemainingTimes: map['LockRemainingTimes'],
  26. passwordExpired: map['PasswordExpired'],
  27. accountName: map['AccountName'],
  28. );
  29. }
  30. Map<String, dynamic> toJson() {
  31. final map = Map<String, dynamic>();
  32. map['LoginState'] = loginState.index;
  33. if(token != null)
  34. map['Token'] = token;
  35. if(lockRemainingTimes != null)
  36. map['LockRemainingTimes'] = lockRemainingTimes;
  37. map['PasswordExpired'] = passwordExpired;
  38. if(accountName != null)
  39. map['AccountName'] = accountName;
  40. return map;
  41. }
  42. }
  43. class CommonLoginRequest {
  44. String? anyAccount;
  45. String? anyCode;
  46. String? password;
  47. Map<String,String>? headerMap;
  48. Platform platform;
  49. LoginSource loginSource;
  50. CommonLoginRequest({
  51. this.anyAccount,
  52. this.anyCode,
  53. this.password,
  54. this.headerMap,
  55. this.platform = Platform.Windows,
  56. this.loginSource = LoginSource.PC,
  57. });
  58. factory CommonLoginRequest.fromJson(Map<String, dynamic> map) {
  59. return CommonLoginRequest(
  60. anyAccount: map['AnyAccount'],
  61. anyCode: map['AnyCode'],
  62. password: map['Password'],
  63. headerMap: map['HeaderMap'] != null ? map['HeaderMap'].cast<String,String>() : null,
  64. platform: Platform.values.firstWhere((e) => e.index == map['Platform']),
  65. loginSource: LoginSource.values.firstWhere((e) => e.index == map['LoginSource']),
  66. );
  67. }
  68. Map<String, dynamic> toJson() {
  69. final map = Map<String, dynamic>();
  70. if(anyAccount != null)
  71. map['AnyAccount'] = anyAccount;
  72. if(anyCode != null)
  73. map['AnyCode'] = anyCode;
  74. if(password != null)
  75. map['Password'] = password;
  76. if(headerMap != null)
  77. map['HeaderMap'] = headerMap;
  78. map['Platform'] = platform.index;
  79. map['LoginSource'] = loginSource.index;
  80. return map;
  81. }
  82. }
  83. class CheckLoginTypeRequest {
  84. String? anyAccount;
  85. CheckLoginTypeRequest({
  86. this.anyAccount,
  87. });
  88. factory CheckLoginTypeRequest.fromJson(Map<String, dynamic> map) {
  89. return CheckLoginTypeRequest(
  90. anyAccount: map['AnyAccount'],
  91. );
  92. }
  93. Map<String, dynamic> toJson() {
  94. final map = Map<String, dynamic>();
  95. if(anyAccount != null)
  96. map['AnyAccount'] = anyAccount;
  97. return map;
  98. }
  99. }
  100. class CommonSignUpRequest {
  101. String? anyAccount;
  102. String? anyCode;
  103. String? password;
  104. Map<String,String>? headerMap;
  105. CommonSignUpRequest({
  106. this.anyAccount,
  107. this.anyCode,
  108. this.password,
  109. this.headerMap,
  110. });
  111. factory CommonSignUpRequest.fromJson(Map<String, dynamic> map) {
  112. return CommonSignUpRequest(
  113. anyAccount: map['AnyAccount'],
  114. anyCode: map['AnyCode'],
  115. password: map['Password'],
  116. headerMap: map['HeaderMap'] != null ? map['HeaderMap'].cast<String,String>() : null,
  117. );
  118. }
  119. Map<String, dynamic> toJson() {
  120. final map = Map<String, dynamic>();
  121. if(anyAccount != null)
  122. map['AnyAccount'] = anyAccount;
  123. if(anyCode != null)
  124. map['AnyCode'] = anyCode;
  125. if(password != null)
  126. map['Password'] = password;
  127. if(headerMap != null)
  128. map['HeaderMap'] = headerMap;
  129. return map;
  130. }
  131. }
  132. class CheckSMSVerificationCodeRequest {
  133. String? userPhone;
  134. String? verifyCode;
  135. CheckSMSVerificationCodeRequest({
  136. this.userPhone,
  137. this.verifyCode,
  138. });
  139. factory CheckSMSVerificationCodeRequest.fromJson(Map<String, dynamic> map) {
  140. return CheckSMSVerificationCodeRequest(
  141. userPhone: map['UserPhone'],
  142. verifyCode: map['VerifyCode'],
  143. );
  144. }
  145. Map<String, dynamic> toJson() {
  146. final map = Map<String, dynamic>();
  147. if(userPhone != null)
  148. map['UserPhone'] = userPhone;
  149. if(verifyCode != null)
  150. map['VerifyCode'] = verifyCode;
  151. return map;
  152. }
  153. }
  154. class SendSMSVerificationCodeRequest {
  155. String? userPhone;
  156. SendSMSVerificationCodeRequest({
  157. this.userPhone,
  158. });
  159. factory SendSMSVerificationCodeRequest.fromJson(Map<String, dynamic> map) {
  160. return SendSMSVerificationCodeRequest(
  161. userPhone: map['UserPhone'],
  162. );
  163. }
  164. Map<String, dynamic> toJson() {
  165. final map = Map<String, dynamic>();
  166. if(userPhone != null)
  167. map['UserPhone'] = userPhone;
  168. return map;
  169. }
  170. }
  171. class SendEmailVerificationCodeRequest {
  172. String? emailAddress;
  173. String? languageCode;
  174. SendEmailVerificationCodeRequest({
  175. this.emailAddress,
  176. this.languageCode,
  177. });
  178. factory SendEmailVerificationCodeRequest.fromJson(Map<String, dynamic> map) {
  179. return SendEmailVerificationCodeRequest(
  180. emailAddress: map['EmailAddress'],
  181. languageCode: map['LanguageCode'],
  182. );
  183. }
  184. Map<String, dynamic> toJson() {
  185. final map = Map<String, dynamic>();
  186. if(emailAddress != null)
  187. map['EmailAddress'] = emailAddress;
  188. if(languageCode != null)
  189. map['LanguageCode'] = languageCode;
  190. return map;
  191. }
  192. }
  193. class CheckEmailVerificationCodeRequest {
  194. String? emailAddress;
  195. String? verifyCode;
  196. CheckEmailVerificationCodeRequest({
  197. this.emailAddress,
  198. this.verifyCode,
  199. });
  200. factory CheckEmailVerificationCodeRequest.fromJson(Map<String, dynamic> map) {
  201. return CheckEmailVerificationCodeRequest(
  202. emailAddress: map['EmailAddress'],
  203. verifyCode: map['VerifyCode'],
  204. );
  205. }
  206. Map<String, dynamic> toJson() {
  207. final map = Map<String, dynamic>();
  208. if(emailAddress != null)
  209. map['EmailAddress'] = emailAddress;
  210. if(verifyCode != null)
  211. map['VerifyCode'] = verifyCode;
  212. return map;
  213. }
  214. }
  215. class RetrievePasswordByPhoneRequest {
  216. String? phone;
  217. String? verifyCode;
  218. String? newPassword;
  219. RetrievePasswordByPhoneRequest({
  220. this.phone,
  221. this.verifyCode,
  222. this.newPassword,
  223. });
  224. factory RetrievePasswordByPhoneRequest.fromJson(Map<String, dynamic> map) {
  225. return RetrievePasswordByPhoneRequest(
  226. phone: map['Phone'],
  227. verifyCode: map['VerifyCode'],
  228. newPassword: map['NewPassword'],
  229. );
  230. }
  231. Map<String, dynamic> toJson() {
  232. final map = Map<String, dynamic>();
  233. if(phone != null)
  234. map['Phone'] = phone;
  235. if(verifyCode != null)
  236. map['VerifyCode'] = verifyCode;
  237. if(newPassword != null)
  238. map['NewPassword'] = newPassword;
  239. return map;
  240. }
  241. }
  242. class RetrievePasswordByEmailRequest {
  243. String? mail;
  244. String? verifyCode;
  245. String? newPassword;
  246. RetrievePasswordByEmailRequest({
  247. this.mail,
  248. this.verifyCode,
  249. this.newPassword,
  250. });
  251. factory RetrievePasswordByEmailRequest.fromJson(Map<String, dynamic> map) {
  252. return RetrievePasswordByEmailRequest(
  253. mail: map['Mail'],
  254. verifyCode: map['VerifyCode'],
  255. newPassword: map['NewPassword'],
  256. );
  257. }
  258. Map<String, dynamic> toJson() {
  259. final map = Map<String, dynamic>();
  260. if(mail != null)
  261. map['Mail'] = mail;
  262. if(verifyCode != null)
  263. map['VerifyCode'] = verifyCode;
  264. if(newPassword != null)
  265. map['NewPassword'] = newPassword;
  266. return map;
  267. }
  268. }
  269. class VerifyAccountRequest {
  270. String? userName;
  271. VerifyAccountRequest({
  272. this.userName,
  273. });
  274. factory VerifyAccountRequest.fromJson(Map<String, dynamic> map) {
  275. return VerifyAccountRequest(
  276. userName: map['UserName'],
  277. );
  278. }
  279. Map<String, dynamic> toJson() {
  280. final map = Map<String, dynamic>();
  281. if(userName != null)
  282. map['UserName'] = userName;
  283. return map;
  284. }
  285. }
  286. class ModifyPasswordRequest extends CommonSignUpRequest{
  287. String? token;
  288. String? newPassword;
  289. ModifyPasswordRequest({
  290. this.token,
  291. this.newPassword,
  292. String? anyAccount,
  293. String? anyCode,
  294. String? password,
  295. Map<String,String>? headerMap,
  296. }) : super(
  297. anyAccount: anyAccount,
  298. anyCode: anyCode,
  299. password: password,
  300. headerMap: headerMap,
  301. );
  302. factory ModifyPasswordRequest.fromJson(Map<String, dynamic> map) {
  303. return ModifyPasswordRequest(
  304. token: map['Token'],
  305. newPassword: map['NewPassword'],
  306. anyAccount: map['AnyAccount'],
  307. anyCode: map['AnyCode'],
  308. password: map['Password'],
  309. headerMap: map['HeaderMap'] != null ? map['HeaderMap'].cast<String,String>() : null,
  310. );
  311. }
  312. Map<String, dynamic> toJson() {
  313. final map = super.toJson();
  314. if(token != null)
  315. map['Token'] = token;
  316. if(newPassword != null)
  317. map['NewPassword'] = newPassword;
  318. return map;
  319. }
  320. }
  321. class GenerateNewPasswordRequest extends TokenRequest{
  322. GenerateNewPasswordRequest({
  323. String? token,
  324. }) : super(
  325. token: token,
  326. );
  327. factory GenerateNewPasswordRequest.fromJson(Map<String, dynamic> map) {
  328. return GenerateNewPasswordRequest(
  329. token: map['Token'],
  330. );
  331. }
  332. Map<String, dynamic> toJson() {
  333. final map = super.toJson();
  334. return map;
  335. }
  336. }