user.m.dart 12 KB

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