login.m.dart 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. import 'package:fis_jsonrpc/utils.dart';
  2. class UserTokenDTO {
  3. String? userCode;
  4. String? deviceId;
  5. String? token;
  6. UserTokenDTO({
  7. this.userCode,
  8. this.deviceId,
  9. this.token,
  10. });
  11. factory UserTokenDTO.fromJson(Map<String, dynamic> map) {
  12. return UserTokenDTO(
  13. userCode: map['UserCode'],
  14. deviceId: map['DeviceId'],
  15. token: map['Token'],
  16. );
  17. }
  18. Map<String, dynamic> toJson() {
  19. final map = Map<String, dynamic>();
  20. if(userCode != null)
  21. map['UserCode'] = userCode;
  22. if(deviceId != null)
  23. map['DeviceId'] = deviceId;
  24. if(token != null)
  25. map['Token'] = token;
  26. return map;
  27. }
  28. }
  29. enum EnumLoginProcessorType {
  30. Official,
  31. Wechat,
  32. Phone,
  33. Email,
  34. Unregistered,
  35. }
  36. class LoginProcessorDTO {
  37. String? userName;
  38. String? password;
  39. String? phone;
  40. String? email;
  41. String? verifyCode;
  42. String? wechatToken;
  43. LoginProcessorDTO({
  44. this.userName,
  45. this.password,
  46. this.phone,
  47. this.email,
  48. this.verifyCode,
  49. this.wechatToken,
  50. });
  51. factory LoginProcessorDTO.fromJson(Map<String, dynamic> map) {
  52. return LoginProcessorDTO(
  53. userName: map['UserName'],
  54. password: map['Password'],
  55. phone: map['Phone'],
  56. email: map['Email'],
  57. verifyCode: map['VerifyCode'],
  58. wechatToken: map['WechatToken'],
  59. );
  60. }
  61. Map<String, dynamic> toJson() {
  62. final map = Map<String, dynamic>();
  63. if(userName != null)
  64. map['UserName'] = userName;
  65. if(password != null)
  66. map['Password'] = password;
  67. if(phone != null)
  68. map['Phone'] = phone;
  69. if(email != null)
  70. map['Email'] = email;
  71. if(verifyCode != null)
  72. map['VerifyCode'] = verifyCode;
  73. if(wechatToken != null)
  74. map['WechatToken'] = wechatToken;
  75. return map;
  76. }
  77. }
  78. class ClientDTO {
  79. String? clientIpAndPort;
  80. String? clientDeviceId;
  81. String? clientSource;
  82. String? clientExtensionInfo;
  83. ClientDTO({
  84. this.clientIpAndPort,
  85. this.clientDeviceId,
  86. this.clientSource,
  87. this.clientExtensionInfo,
  88. });
  89. factory ClientDTO.fromJson(Map<String, dynamic> map) {
  90. return ClientDTO(
  91. clientIpAndPort: map['ClientIpAndPort'],
  92. clientDeviceId: map['ClientDeviceId'],
  93. clientSource: map['ClientSource'],
  94. clientExtensionInfo: map['ClientExtensionInfo'],
  95. );
  96. }
  97. Map<String, dynamic> toJson() {
  98. final map = Map<String, dynamic>();
  99. if(clientIpAndPort != null)
  100. map['ClientIpAndPort'] = clientIpAndPort;
  101. if(clientDeviceId != null)
  102. map['ClientDeviceId'] = clientDeviceId;
  103. if(clientSource != null)
  104. map['ClientSource'] = clientSource;
  105. if(clientExtensionInfo != null)
  106. map['ClientExtensionInfo'] = clientExtensionInfo;
  107. return map;
  108. }
  109. }
  110. class UserLoginDTO {
  111. EnumLoginProcessorType loginType;
  112. LoginProcessorDTO? processorInfo;
  113. ClientDTO? clientInfo;
  114. UserLoginDTO({
  115. this.loginType = EnumLoginProcessorType.Official,
  116. this.processorInfo,
  117. this.clientInfo,
  118. });
  119. factory UserLoginDTO.fromJson(Map<String, dynamic> map) {
  120. return UserLoginDTO(
  121. loginType: EnumLoginProcessorType.values.firstWhere((e) => e.index == map['LoginType']),
  122. processorInfo: map['ProcessorInfo'],
  123. clientInfo: map['ClientInfo'],
  124. );
  125. }
  126. Map<String, dynamic> toJson() {
  127. final map = Map<String, dynamic>();
  128. map['LoginType'] = loginType.index;
  129. if(processorInfo != null)
  130. map['ProcessorInfo'] = processorInfo;
  131. if(clientInfo != null)
  132. map['ClientInfo'] = clientInfo;
  133. return map;
  134. }
  135. }
  136. class ClientLoginRequest extends UserLoginDTO{
  137. ClientLoginRequest({
  138. EnumLoginProcessorType loginType = EnumLoginProcessorType.Official,
  139. LoginProcessorDTO? processorInfo,
  140. ClientDTO? clientInfo,
  141. }) : super(
  142. loginType: loginType,
  143. processorInfo: processorInfo,
  144. clientInfo: clientInfo,
  145. );
  146. factory ClientLoginRequest.fromJson(Map<String, dynamic> map) {
  147. return ClientLoginRequest(
  148. loginType: EnumLoginProcessorType.values.firstWhere((e) => e.index == map['LoginType']),
  149. processorInfo: map['ProcessorInfo'],
  150. clientInfo: map['ClientInfo'],
  151. );
  152. }
  153. Map<String, dynamic> toJson() {
  154. final map = super.toJson();
  155. return map;
  156. }
  157. }
  158. class CommonLoginRequest {
  159. String? anyAccount;
  160. String? anyCode;
  161. String? password;
  162. CommonLoginRequest({
  163. this.anyAccount,
  164. this.anyCode,
  165. this.password,
  166. });
  167. factory CommonLoginRequest.fromJson(Map<String, dynamic> map) {
  168. return CommonLoginRequest(
  169. anyAccount: map['AnyAccount'],
  170. anyCode: map['AnyCode'],
  171. password: map['Password'],
  172. );
  173. }
  174. Map<String, dynamic> toJson() {
  175. final map = Map<String, dynamic>();
  176. if(anyAccount != null)
  177. map['AnyAccount'] = anyAccount;
  178. if(anyCode != null)
  179. map['AnyCode'] = anyCode;
  180. if(password != null)
  181. map['Password'] = password;
  182. return map;
  183. }
  184. }
  185. class CheckLoginTypeRequest {
  186. String? anyAccount;
  187. CheckLoginTypeRequest({
  188. this.anyAccount,
  189. });
  190. factory CheckLoginTypeRequest.fromJson(Map<String, dynamic> map) {
  191. return CheckLoginTypeRequest(
  192. anyAccount: map['AnyAccount'],
  193. );
  194. }
  195. Map<String, dynamic> toJson() {
  196. final map = Map<String, dynamic>();
  197. if(anyAccount != null)
  198. map['AnyAccount'] = anyAccount;
  199. return map;
  200. }
  201. }
  202. class CommonSignUpRequest {
  203. String? anyAccount;
  204. String? anyCode;
  205. String? password;
  206. CommonSignUpRequest({
  207. this.anyAccount,
  208. this.anyCode,
  209. this.password,
  210. });
  211. factory CommonSignUpRequest.fromJson(Map<String, dynamic> map) {
  212. return CommonSignUpRequest(
  213. anyAccount: map['AnyAccount'],
  214. anyCode: map['AnyCode'],
  215. password: map['Password'],
  216. );
  217. }
  218. Map<String, dynamic> toJson() {
  219. final map = Map<String, dynamic>();
  220. if(anyAccount != null)
  221. map['AnyAccount'] = anyAccount;
  222. if(anyCode != null)
  223. map['AnyCode'] = anyCode;
  224. if(password != null)
  225. map['Password'] = password;
  226. return map;
  227. }
  228. }
  229. class BaseDTO {
  230. DateTime? createTime;
  231. DateTime? updateTime;
  232. BaseDTO({
  233. this.createTime,
  234. this.updateTime,
  235. });
  236. factory BaseDTO.fromJson(Map<String, dynamic> map) {
  237. return BaseDTO(
  238. createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null,
  239. updateTime: map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null,
  240. );
  241. }
  242. Map<String, dynamic> toJson() {
  243. final map = Map<String, dynamic>();
  244. if(createTime != null)
  245. map['CreateTime'] = JsonRpcUtils.dateFormat(createTime!);
  246. if(updateTime != null)
  247. map['UpdateTime'] = JsonRpcUtils.dateFormat(updateTime!);
  248. return map;
  249. }
  250. }
  251. enum UserInfoStateEnum {
  252. Nonactivated,
  253. Activated,
  254. }
  255. enum ApplyStateEnum {
  256. NotApply,
  257. Applying,
  258. Refused,
  259. Passed,
  260. }
  261. class UserDTO extends BaseDTO{
  262. String? userCode;
  263. String? userName;
  264. String? phone;
  265. String? email;
  266. String? nickName;
  267. String? fullName;
  268. String? headImageUrl;
  269. String? organizationCode;
  270. String? rootOrganizationCode;
  271. List<String>? authorityGroups;
  272. List<String>? bindDevices;
  273. String? lastIP;
  274. int logintimes;
  275. UserInfoStateEnum userState;
  276. List<String>? roleCodes;
  277. List<String>? rankCodes;
  278. List<String>? positionCodes;
  279. ApplyStateEnum applyState;
  280. UserDTO({
  281. this.userCode,
  282. this.userName,
  283. this.phone,
  284. this.email,
  285. this.nickName,
  286. this.fullName,
  287. this.headImageUrl,
  288. this.organizationCode,
  289. this.rootOrganizationCode,
  290. this.authorityGroups,
  291. this.bindDevices,
  292. this.lastIP,
  293. this.logintimes = 0,
  294. this.userState = UserInfoStateEnum.Nonactivated,
  295. this.roleCodes,
  296. this.rankCodes,
  297. this.positionCodes,
  298. this.applyState = ApplyStateEnum.NotApply,
  299. DateTime? createTime,
  300. DateTime? updateTime,
  301. }) : super(
  302. createTime: createTime,
  303. updateTime: updateTime,
  304. );
  305. factory UserDTO.fromJson(Map<String, dynamic> map) {
  306. return UserDTO(
  307. userCode: map['UserCode'],
  308. userName: map['UserName'],
  309. phone: map['Phone'],
  310. email: map['Email'],
  311. nickName: map['NickName'],
  312. fullName: map['FullName'],
  313. headImageUrl: map['HeadImageUrl'],
  314. organizationCode: map['OrganizationCode'],
  315. rootOrganizationCode: map['RootOrganizationCode'],
  316. authorityGroups: map['AuthorityGroups'].cast<String>().toList(),
  317. bindDevices: map['BindDevices'].cast<String>().toList(),
  318. lastIP: map['LastIP'],
  319. logintimes: map['Logintimes'],
  320. userState: UserInfoStateEnum.values.firstWhere((e) => e.index == map['UserState']),
  321. roleCodes: map['RoleCodes'].cast<String>().toList(),
  322. rankCodes: map['RankCodes'].cast<String>().toList(),
  323. positionCodes: map['PositionCodes'].cast<String>().toList(),
  324. applyState: ApplyStateEnum.values.firstWhere((e) => e.index == map['ApplyState']),
  325. createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null,
  326. updateTime: map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null,
  327. );
  328. }
  329. Map<String, dynamic> toJson() {
  330. final map = super.toJson();
  331. if(userCode != null)
  332. map['UserCode'] = userCode;
  333. if(userName != null)
  334. map['UserName'] = userName;
  335. if(phone != null)
  336. map['Phone'] = phone;
  337. if(email != null)
  338. map['Email'] = email;
  339. if(nickName != null)
  340. map['NickName'] = nickName;
  341. if(fullName != null)
  342. map['FullName'] = fullName;
  343. if(headImageUrl != null)
  344. map['HeadImageUrl'] = headImageUrl;
  345. if(organizationCode != null)
  346. map['OrganizationCode'] = organizationCode;
  347. if(rootOrganizationCode != null)
  348. map['RootOrganizationCode'] = rootOrganizationCode;
  349. if(authorityGroups != null)
  350. map['AuthorityGroups'] = authorityGroups;
  351. if(bindDevices != null)
  352. map['BindDevices'] = bindDevices;
  353. if(lastIP != null)
  354. map['LastIP'] = lastIP;
  355. map['Logintimes'] = logintimes;
  356. map['UserState'] = userState.index;
  357. if(roleCodes != null)
  358. map['RoleCodes'] = roleCodes;
  359. if(rankCodes != null)
  360. map['RankCodes'] = rankCodes;
  361. if(positionCodes != null)
  362. map['PositionCodes'] = positionCodes;
  363. map['ApplyState'] = applyState.index;
  364. return map;
  365. }
  366. }
  367. class SignUpRequest extends UserDTO{
  368. SignUpRequest({
  369. String? userCode,
  370. String? userName,
  371. String? phone,
  372. String? email,
  373. String? nickName,
  374. String? fullName,
  375. String? headImageUrl,
  376. String? organizationCode,
  377. String? rootOrganizationCode,
  378. List<String>? authorityGroups,
  379. List<String>? bindDevices,
  380. String? lastIP,
  381. int logintimes = 0,
  382. UserInfoStateEnum userState = UserInfoStateEnum.Nonactivated,
  383. List<String>? roleCodes,
  384. List<String>? rankCodes,
  385. List<String>? positionCodes,
  386. ApplyStateEnum applyState = ApplyStateEnum.NotApply,
  387. DateTime? createTime,
  388. DateTime? updateTime,
  389. }) : super(
  390. userCode: userCode,
  391. userName: userName,
  392. phone: phone,
  393. email: email,
  394. nickName: nickName,
  395. fullName: fullName,
  396. headImageUrl: headImageUrl,
  397. organizationCode: organizationCode,
  398. rootOrganizationCode: rootOrganizationCode,
  399. authorityGroups: authorityGroups,
  400. bindDevices: bindDevices,
  401. lastIP: lastIP,
  402. logintimes: logintimes,
  403. userState: userState,
  404. roleCodes: roleCodes,
  405. rankCodes: rankCodes,
  406. positionCodes: positionCodes,
  407. applyState: applyState,
  408. createTime: createTime,
  409. updateTime: updateTime,
  410. );
  411. factory SignUpRequest.fromJson(Map<String, dynamic> map) {
  412. return SignUpRequest(
  413. userCode: map['UserCode'],
  414. userName: map['UserName'],
  415. phone: map['Phone'],
  416. email: map['Email'],
  417. nickName: map['NickName'],
  418. fullName: map['FullName'],
  419. headImageUrl: map['HeadImageUrl'],
  420. organizationCode: map['OrganizationCode'],
  421. rootOrganizationCode: map['RootOrganizationCode'],
  422. authorityGroups: map['AuthorityGroups'].cast<String>().toList(),
  423. bindDevices: map['BindDevices'].cast<String>().toList(),
  424. lastIP: map['LastIP'],
  425. logintimes: map['Logintimes'],
  426. userState: UserInfoStateEnum.values.firstWhere((e) => e.index == map['UserState']),
  427. roleCodes: map['RoleCodes'].cast<String>().toList(),
  428. rankCodes: map['RankCodes'].cast<String>().toList(),
  429. positionCodes: map['PositionCodes'].cast<String>().toList(),
  430. applyState: ApplyStateEnum.values.firstWhere((e) => e.index == map['ApplyState']),
  431. createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null,
  432. updateTime: map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null,
  433. );
  434. }
  435. Map<String, dynamic> toJson() {
  436. final map = super.toJson();
  437. return map;
  438. }
  439. }
  440. class CheckSMSVerificationCodeRequest {
  441. String? userPhone;
  442. String? verifyCode;
  443. CheckSMSVerificationCodeRequest({
  444. this.userPhone,
  445. this.verifyCode,
  446. });
  447. factory CheckSMSVerificationCodeRequest.fromJson(Map<String, dynamic> map) {
  448. return CheckSMSVerificationCodeRequest(
  449. userPhone: map['UserPhone'],
  450. verifyCode: map['VerifyCode'],
  451. );
  452. }
  453. Map<String, dynamic> toJson() {
  454. final map = Map<String, dynamic>();
  455. if(userPhone != null)
  456. map['UserPhone'] = userPhone;
  457. if(verifyCode != null)
  458. map['VerifyCode'] = verifyCode;
  459. return map;
  460. }
  461. }
  462. class SendSMSVerificationCodeRequest {
  463. String? userPhone;
  464. SendSMSVerificationCodeRequest({
  465. this.userPhone,
  466. });
  467. factory SendSMSVerificationCodeRequest.fromJson(Map<String, dynamic> map) {
  468. return SendSMSVerificationCodeRequest(
  469. userPhone: map['UserPhone'],
  470. );
  471. }
  472. Map<String, dynamic> toJson() {
  473. final map = Map<String, dynamic>();
  474. if(userPhone != null)
  475. map['UserPhone'] = userPhone;
  476. return map;
  477. }
  478. }
  479. class SendEmailVerificationCodeRequest {
  480. String? emailAddress;
  481. SendEmailVerificationCodeRequest({
  482. this.emailAddress,
  483. });
  484. factory SendEmailVerificationCodeRequest.fromJson(Map<String, dynamic> map) {
  485. return SendEmailVerificationCodeRequest(
  486. emailAddress: map['EmailAddress'],
  487. );
  488. }
  489. Map<String, dynamic> toJson() {
  490. final map = Map<String, dynamic>();
  491. if(emailAddress != null)
  492. map['EmailAddress'] = emailAddress;
  493. return map;
  494. }
  495. }
  496. class CheckEmailVerificationCodeRequest {
  497. String? emailAddress;
  498. String? verifyCode;
  499. CheckEmailVerificationCodeRequest({
  500. this.emailAddress,
  501. this.verifyCode,
  502. });
  503. factory CheckEmailVerificationCodeRequest.fromJson(Map<String, dynamic> map) {
  504. return CheckEmailVerificationCodeRequest(
  505. emailAddress: map['EmailAddress'],
  506. verifyCode: map['VerifyCode'],
  507. );
  508. }
  509. Map<String, dynamic> toJson() {
  510. final map = Map<String, dynamic>();
  511. if(emailAddress != null)
  512. map['EmailAddress'] = emailAddress;
  513. if(verifyCode != null)
  514. map['VerifyCode'] = verifyCode;
  515. return map;
  516. }
  517. }
  518. class RetrievePasswordByPhoneRequest {
  519. String? phone;
  520. String? verifyCode;
  521. String? newPassword;
  522. RetrievePasswordByPhoneRequest({
  523. this.phone,
  524. this.verifyCode,
  525. this.newPassword,
  526. });
  527. factory RetrievePasswordByPhoneRequest.fromJson(Map<String, dynamic> map) {
  528. return RetrievePasswordByPhoneRequest(
  529. phone: map['Phone'],
  530. verifyCode: map['VerifyCode'],
  531. newPassword: map['NewPassword'],
  532. );
  533. }
  534. Map<String, dynamic> toJson() {
  535. final map = Map<String, dynamic>();
  536. if(phone != null)
  537. map['Phone'] = phone;
  538. if(verifyCode != null)
  539. map['VerifyCode'] = verifyCode;
  540. if(newPassword != null)
  541. map['NewPassword'] = newPassword;
  542. return map;
  543. }
  544. }
  545. class RetrievePasswordByEmailRequest {
  546. String? mail;
  547. String? verifyCode;
  548. String? newPassword;
  549. RetrievePasswordByEmailRequest({
  550. this.mail,
  551. this.verifyCode,
  552. this.newPassword,
  553. });
  554. factory RetrievePasswordByEmailRequest.fromJson(Map<String, dynamic> map) {
  555. return RetrievePasswordByEmailRequest(
  556. mail: map['Mail'],
  557. verifyCode: map['VerifyCode'],
  558. newPassword: map['NewPassword'],
  559. );
  560. }
  561. Map<String, dynamic> toJson() {
  562. final map = Map<String, dynamic>();
  563. if(mail != null)
  564. map['Mail'] = mail;
  565. if(verifyCode != null)
  566. map['VerifyCode'] = verifyCode;
  567. if(newPassword != null)
  568. map['NewPassword'] = newPassword;
  569. return map;
  570. }
  571. }
  572. class VerifyAccountRequest {
  573. String? userName;
  574. VerifyAccountRequest({
  575. this.userName,
  576. });
  577. factory VerifyAccountRequest.fromJson(Map<String, dynamic> map) {
  578. return VerifyAccountRequest(
  579. userName: map['UserName'],
  580. );
  581. }
  582. Map<String, dynamic> toJson() {
  583. final map = Map<String, dynamic>();
  584. if(userName != null)
  585. map['UserName'] = userName;
  586. return map;
  587. }
  588. }