user.m.dart 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. import 'package:fis_jsonrpc/utils.dart';
  2. class BaseDTO {
  3. DateTime? createTime;
  4. DateTime? updateTime;
  5. BaseDTO({
  6. this.createTime,
  7. this.updateTime,
  8. });
  9. factory BaseDTO.fromJson(Map<String, dynamic> map) {
  10. return BaseDTO(
  11. createTime:
  12. map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null,
  13. updateTime:
  14. map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null,
  15. );
  16. }
  17. Map<String, dynamic> toJson() {
  18. final map = Map<String, dynamic>();
  19. if (createTime != null)
  20. map['CreateTime'] = JsonRpcUtils.dateFormat(createTime!);
  21. if (updateTime != null)
  22. map['UpdateTime'] = JsonRpcUtils.dateFormat(updateTime!);
  23. return map;
  24. }
  25. }
  26. enum UserInfoStateEnum {
  27. Nonactivated,
  28. Activated,
  29. }
  30. enum ApplyStateEnum {
  31. NotApply,
  32. Applying,
  33. Refused,
  34. Passed,
  35. }
  36. class UserDTO extends BaseDTO {
  37. String? userCode;
  38. String? userName;
  39. String? phone;
  40. String? email;
  41. String? nickName;
  42. String? fullName;
  43. String? headImageUrl;
  44. String? organizationCode;
  45. String? rootOrganizationCode;
  46. List<String>? authorityGroups;
  47. List<String>? bindDevices;
  48. String? lastIP;
  49. int logintimes;
  50. UserInfoStateEnum userState;
  51. List<String>? roleCodes;
  52. List<String>? rankCodes;
  53. List<String>? positionCodes;
  54. ApplyStateEnum applyState;
  55. UserDTO({
  56. this.userCode,
  57. this.userName,
  58. this.phone,
  59. this.email,
  60. this.nickName,
  61. this.fullName,
  62. this.headImageUrl,
  63. this.organizationCode,
  64. this.rootOrganizationCode,
  65. this.authorityGroups,
  66. this.bindDevices,
  67. this.lastIP,
  68. this.logintimes = 0,
  69. this.userState = UserInfoStateEnum.Nonactivated,
  70. this.roleCodes,
  71. this.rankCodes,
  72. this.positionCodes,
  73. this.applyState = ApplyStateEnum.NotApply,
  74. DateTime? createTime,
  75. DateTime? updateTime,
  76. }) : super(
  77. createTime: createTime,
  78. updateTime: updateTime,
  79. );
  80. factory UserDTO.fromJson(Map<String, dynamic> map) {
  81. return UserDTO(
  82. userCode: map['UserCode'],
  83. userName: map['UserName'],
  84. phone: map['Phone'],
  85. email: map['Email'],
  86. nickName: map['NickName'],
  87. fullName: map['FullName'],
  88. headImageUrl: map['HeadImageUrl'],
  89. organizationCode: map['OrganizationCode'],
  90. rootOrganizationCode: map['RootOrganizationCode'],
  91. authorityGroups: map['AuthorityGroups'].cast<String>().toList(),
  92. bindDevices: map['BindDevices'].cast<String>().toList(),
  93. lastIP: map['LastIP'],
  94. logintimes: map['Logintimes'],
  95. userState: UserInfoStateEnum.values
  96. .firstWhere((e) => e.index == map['UserState']),
  97. roleCodes: map['RoleCodes'].cast<String>().toList(),
  98. rankCodes: map['RankCodes'].cast<String>().toList(),
  99. positionCodes: map['PositionCodes'].cast<String>().toList(),
  100. applyState:
  101. ApplyStateEnum.values.firstWhere((e) => e.index == map['ApplyState']),
  102. createTime:
  103. map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null,
  104. updateTime:
  105. map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null,
  106. );
  107. }
  108. Map<String, dynamic> toJson() {
  109. final map = super.toJson();
  110. if (userCode != null) map['UserCode'] = userCode;
  111. if (userName != null) map['UserName'] = userName;
  112. if (phone != null) map['Phone'] = phone;
  113. if (email != null) map['Email'] = email;
  114. if (nickName != null) map['NickName'] = nickName;
  115. if (fullName != null) map['FullName'] = fullName;
  116. if (headImageUrl != null) map['HeadImageUrl'] = headImageUrl;
  117. if (organizationCode != null) map['OrganizationCode'] = organizationCode;
  118. if (rootOrganizationCode != null)
  119. map['RootOrganizationCode'] = rootOrganizationCode;
  120. if (authorityGroups != null) map['AuthorityGroups'] = authorityGroups;
  121. if (bindDevices != null) map['BindDevices'] = bindDevices;
  122. if (lastIP != null) map['LastIP'] = lastIP;
  123. map['Logintimes'] = logintimes;
  124. map['UserState'] = userState.index;
  125. if (roleCodes != null) map['RoleCodes'] = roleCodes;
  126. if (rankCodes != null) map['RankCodes'] = rankCodes;
  127. if (positionCodes != null) map['PositionCodes'] = positionCodes;
  128. map['ApplyState'] = applyState.index;
  129. return map;
  130. }
  131. }
  132. class BaseRequest {
  133. BaseRequest();
  134. factory BaseRequest.fromJson(Map<String, dynamic> map) {
  135. return BaseRequest();
  136. }
  137. Map<String, dynamic> toJson() {
  138. final map = Map<String, dynamic>();
  139. return map;
  140. }
  141. }
  142. class TokenRequest extends BaseRequest {
  143. String? token;
  144. TokenRequest({
  145. this.token,
  146. }) : super();
  147. factory TokenRequest.fromJson(Map<String, dynamic> map) {
  148. return TokenRequest(
  149. token: map['Token'],
  150. );
  151. }
  152. Map<String, dynamic> toJson() {
  153. final map = super.toJson();
  154. if (token != null) map['Token'] = token;
  155. return map;
  156. }
  157. }
  158. class GetUserInfoRequest extends TokenRequest {
  159. GetUserInfoRequest({
  160. String? token,
  161. }) : super(
  162. token: token,
  163. );
  164. factory GetUserInfoRequest.fromJson(Map<String, dynamic> map) {
  165. return GetUserInfoRequest(
  166. token: map['Token'],
  167. );
  168. }
  169. Map<String, dynamic> toJson() {
  170. final map = super.toJson();
  171. return map;
  172. }
  173. }
  174. class AlterUserInfoRequest extends UserDTO {
  175. String? token;
  176. String? extensionData;
  177. AlterUserInfoRequest({
  178. this.token,
  179. this.extensionData,
  180. String? userCode,
  181. String? userName,
  182. String? phone,
  183. String? email,
  184. String? nickName,
  185. String? fullName,
  186. String? headImageUrl,
  187. String? organizationCode,
  188. String? rootOrganizationCode,
  189. List<String>? authorityGroups,
  190. List<String>? bindDevices,
  191. String? lastIP,
  192. int logintimes = 0,
  193. UserInfoStateEnum userState = UserInfoStateEnum.Nonactivated,
  194. List<String>? roleCodes,
  195. List<String>? rankCodes,
  196. List<String>? positionCodes,
  197. ApplyStateEnum applyState = ApplyStateEnum.NotApply,
  198. DateTime? createTime,
  199. DateTime? updateTime,
  200. }) : super(
  201. userCode: userCode,
  202. userName: userName,
  203. phone: phone,
  204. email: email,
  205. nickName: nickName,
  206. fullName: fullName,
  207. headImageUrl: headImageUrl,
  208. organizationCode: organizationCode,
  209. rootOrganizationCode: rootOrganizationCode,
  210. authorityGroups: authorityGroups,
  211. bindDevices: bindDevices,
  212. lastIP: lastIP,
  213. logintimes: logintimes,
  214. userState: userState,
  215. roleCodes: roleCodes,
  216. rankCodes: rankCodes,
  217. positionCodes: positionCodes,
  218. applyState: applyState,
  219. createTime: createTime,
  220. updateTime: updateTime,
  221. );
  222. factory AlterUserInfoRequest.fromJson(Map<String, dynamic> map) {
  223. return AlterUserInfoRequest(
  224. token: map['Token'],
  225. extensionData: map['ExtensionData'],
  226. userCode: map['UserCode'],
  227. userName: map['UserName'],
  228. phone: map['Phone'],
  229. email: map['Email'],
  230. nickName: map['NickName'],
  231. fullName: map['FullName'],
  232. headImageUrl: map['HeadImageUrl'],
  233. organizationCode: map['OrganizationCode'],
  234. rootOrganizationCode: map['RootOrganizationCode'],
  235. authorityGroups: map['AuthorityGroups'].cast<String>().toList(),
  236. bindDevices: map['BindDevices'].cast<String>().toList(),
  237. lastIP: map['LastIP'],
  238. logintimes: map['Logintimes'],
  239. userState: UserInfoStateEnum.values
  240. .firstWhere((e) => e.index == map['UserState']),
  241. roleCodes: map['RoleCodes'].cast<String>().toList(),
  242. rankCodes: map['RankCodes'].cast<String>().toList(),
  243. positionCodes: map['PositionCodes'].cast<String>().toList(),
  244. applyState:
  245. ApplyStateEnum.values.firstWhere((e) => e.index == map['ApplyState']),
  246. createTime:
  247. map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null,
  248. updateTime:
  249. map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null,
  250. );
  251. }
  252. Map<String, dynamic> toJson() {
  253. final map = super.toJson();
  254. if (token != null) map['Token'] = token;
  255. if (extensionData != null) map['ExtensionData'] = extensionData;
  256. return map;
  257. }
  258. }
  259. class GetUserListRequest extends TokenRequest {
  260. String? roleCode;
  261. String? rankCode;
  262. String? positionCode;
  263. String? organizationCode;
  264. GetUserListRequest({
  265. this.roleCode,
  266. this.rankCode,
  267. this.positionCode,
  268. this.organizationCode,
  269. String? token,
  270. }) : super(
  271. token: token,
  272. );
  273. factory GetUserListRequest.fromJson(Map<String, dynamic> map) {
  274. return GetUserListRequest(
  275. roleCode: map['RoleCode'],
  276. rankCode: map['RankCode'],
  277. positionCode: map['PositionCode'],
  278. organizationCode: map['OrganizationCode'],
  279. token: map['Token'],
  280. );
  281. }
  282. Map<String, dynamic> toJson() {
  283. final map = super.toJson();
  284. if (roleCode != null) map['RoleCode'] = roleCode;
  285. if (rankCode != null) map['RankCode'] = rankCode;
  286. if (positionCode != null) map['PositionCode'] = positionCode;
  287. if (organizationCode != null) map['OrganizationCode'] = organizationCode;
  288. return map;
  289. }
  290. }
  291. class RemoveUsersFromOrganizationRequest extends TokenRequest {
  292. List<String>? userCodes;
  293. RemoveUsersFromOrganizationRequest({
  294. this.userCodes,
  295. String? token,
  296. }) : super(
  297. token: token,
  298. );
  299. factory RemoveUsersFromOrganizationRequest.fromJson(
  300. Map<String, dynamic> map) {
  301. return RemoveUsersFromOrganizationRequest(
  302. userCodes: map['UserCodes'].cast<String>().toList(),
  303. token: map['Token'],
  304. );
  305. }
  306. Map<String, dynamic> toJson() {
  307. final map = super.toJson();
  308. if (userCodes != null) map['UserCodes'] = userCodes;
  309. return map;
  310. }
  311. }
  312. class SetUserOrganizationInfoRequest extends TokenRequest {
  313. String? userCode;
  314. List<String>? roleCodes;
  315. List<String>? rankCodes;
  316. List<String>? positionCodes;
  317. String? organizationCode;
  318. SetUserOrganizationInfoRequest({
  319. this.userCode,
  320. this.roleCodes,
  321. this.rankCodes,
  322. this.positionCodes,
  323. this.organizationCode,
  324. String? token,
  325. }) : super(
  326. token: token,
  327. );
  328. factory SetUserOrganizationInfoRequest.fromJson(Map<String, dynamic> map) {
  329. return SetUserOrganizationInfoRequest(
  330. userCode: map['UserCode'],
  331. roleCodes: map['RoleCodes'].cast<String>().toList(),
  332. rankCodes: map['RankCodes'].cast<String>().toList(),
  333. positionCodes: map['PositionCodes'].cast<String>().toList(),
  334. organizationCode: map['OrganizationCode'],
  335. token: map['Token'],
  336. );
  337. }
  338. Map<String, dynamic> toJson() {
  339. final map = super.toJson();
  340. if (userCode != null) map['UserCode'] = userCode;
  341. if (roleCodes != null) map['RoleCodes'] = roleCodes;
  342. if (rankCodes != null) map['RankCodes'] = rankCodes;
  343. if (positionCodes != null) map['PositionCodes'] = positionCodes;
  344. if (organizationCode != null) map['OrganizationCode'] = organizationCode;
  345. return map;
  346. }
  347. }
  348. class AlterPersonInfoRequest extends UserDTO {
  349. String? token;
  350. AlterPersonInfoRequest({
  351. this.token,
  352. String? userCode,
  353. String? userName,
  354. String? phone,
  355. String? email,
  356. String? nickName,
  357. String? fullName,
  358. String? headImageUrl,
  359. String? organizationCode,
  360. String? rootOrganizationCode,
  361. List<String>? authorityGroups,
  362. List<String>? bindDevices,
  363. String? lastIP,
  364. int logintimes = 0,
  365. UserInfoStateEnum userState = UserInfoStateEnum.Nonactivated,
  366. List<String>? roleCodes,
  367. List<String>? rankCodes,
  368. List<String>? positionCodes,
  369. ApplyStateEnum applyState = ApplyStateEnum.NotApply,
  370. DateTime? createTime,
  371. DateTime? updateTime,
  372. }) : super(
  373. userCode: userCode,
  374. userName: userName,
  375. phone: phone,
  376. email: email,
  377. nickName: nickName,
  378. fullName: fullName,
  379. headImageUrl: headImageUrl,
  380. organizationCode: organizationCode,
  381. rootOrganizationCode: rootOrganizationCode,
  382. authorityGroups: authorityGroups,
  383. bindDevices: bindDevices,
  384. lastIP: lastIP,
  385. logintimes: logintimes,
  386. userState: userState,
  387. roleCodes: roleCodes,
  388. rankCodes: rankCodes,
  389. positionCodes: positionCodes,
  390. applyState: applyState,
  391. createTime: createTime,
  392. updateTime: updateTime,
  393. );
  394. factory AlterPersonInfoRequest.fromJson(Map<String, dynamic> map) {
  395. return AlterPersonInfoRequest(
  396. token: map['Token'],
  397. userCode: map['UserCode'],
  398. userName: map['UserName'],
  399. phone: map['Phone'],
  400. email: map['Email'],
  401. nickName: map['NickName'],
  402. fullName: map['FullName'],
  403. headImageUrl: map['HeadImageUrl'],
  404. organizationCode: map['OrganizationCode'],
  405. rootOrganizationCode: map['RootOrganizationCode'],
  406. authorityGroups: map['AuthorityGroups'].cast<String>().toList(),
  407. bindDevices: map['BindDevices'].cast<String>().toList(),
  408. lastIP: map['LastIP'],
  409. logintimes: map['Logintimes'],
  410. userState: UserInfoStateEnum.values
  411. .firstWhere((e) => e.index == map['UserState']),
  412. roleCodes: map['RoleCodes'].cast<String>().toList(),
  413. rankCodes: map['RankCodes'].cast<String>().toList(),
  414. positionCodes: map['PositionCodes'].cast<String>().toList(),
  415. applyState:
  416. ApplyStateEnum.values.firstWhere((e) => e.index == map['ApplyState']),
  417. createTime:
  418. map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null,
  419. updateTime:
  420. map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null,
  421. );
  422. }
  423. Map<String, dynamic> toJson() {
  424. final map = super.toJson();
  425. if (token != null) map['Token'] = token;
  426. return map;
  427. }
  428. }