role.m.dart 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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 RoleShowTypeEnum {
  27. NotShow,
  28. ISShow,
  29. }
  30. enum RoleQualificationEnum {
  31. NoNeed,
  32. ID,
  33. DocLicense,
  34. Both,
  35. }
  36. class RoleDTO extends BaseDTO {
  37. String? roleCode;
  38. String? roleName;
  39. RoleShowTypeEnum roleShowType;
  40. String? description;
  41. String? iConUrl;
  42. String? colorStart;
  43. String? colorEnd;
  44. RoleQualificationEnum roleQualification;
  45. RoleDTO({
  46. this.roleCode,
  47. this.roleName,
  48. this.roleShowType = RoleShowTypeEnum.NotShow,
  49. this.description,
  50. this.iConUrl,
  51. this.colorStart,
  52. this.colorEnd,
  53. this.roleQualification = RoleQualificationEnum.NoNeed,
  54. DateTime? createTime,
  55. DateTime? updateTime,
  56. }) : super(
  57. createTime: createTime,
  58. updateTime: updateTime,
  59. );
  60. factory RoleDTO.fromJson(Map<String, dynamic> map) {
  61. return RoleDTO(
  62. roleCode: map['RoleCode'],
  63. roleName: map['RoleName'],
  64. roleShowType: RoleShowTypeEnum.values
  65. .firstWhere((e) => e.index == map['RoleShowType']),
  66. description: map['Description'],
  67. iConUrl: map['IConUrl'],
  68. colorStart: map['ColorStart'],
  69. colorEnd: map['ColorEnd'],
  70. roleQualification: RoleQualificationEnum.values
  71. .firstWhere((e) => e.index == map['RoleQualification']),
  72. createTime:
  73. map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null,
  74. updateTime:
  75. map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null,
  76. );
  77. }
  78. Map<String, dynamic> toJson() {
  79. final map = super.toJson();
  80. if (roleCode != null) map['RoleCode'] = roleCode;
  81. if (roleName != null) map['RoleName'] = roleName;
  82. map['RoleShowType'] = roleShowType.index;
  83. if (description != null) map['Description'] = description;
  84. if (iConUrl != null) map['IConUrl'] = iConUrl;
  85. if (colorStart != null) map['ColorStart'] = colorStart;
  86. if (colorEnd != null) map['ColorEnd'] = colorEnd;
  87. map['RoleQualification'] = roleQualification.index;
  88. return map;
  89. }
  90. }
  91. class BaseRequest {
  92. BaseRequest();
  93. factory BaseRequest.fromJson(Map<String, dynamic> map) {
  94. return BaseRequest();
  95. }
  96. Map<String, dynamic> toJson() {
  97. final map = Map<String, dynamic>();
  98. return map;
  99. }
  100. }
  101. class TokenRequest extends BaseRequest {
  102. String? token;
  103. TokenRequest({
  104. this.token,
  105. }) : super();
  106. factory TokenRequest.fromJson(Map<String, dynamic> map) {
  107. return TokenRequest(
  108. token: map['Token'],
  109. );
  110. }
  111. Map<String, dynamic> toJson() {
  112. final map = super.toJson();
  113. if (token != null) map['Token'] = token;
  114. return map;
  115. }
  116. }
  117. class GetRoleByCodeRequest extends TokenRequest {
  118. String? roleCode;
  119. GetRoleByCodeRequest({
  120. this.roleCode,
  121. String? token,
  122. }) : super(
  123. token: token,
  124. );
  125. factory GetRoleByCodeRequest.fromJson(Map<String, dynamic> map) {
  126. return GetRoleByCodeRequest(
  127. roleCode: map['RoleCode'],
  128. token: map['Token'],
  129. );
  130. }
  131. Map<String, dynamic> toJson() {
  132. final map = super.toJson();
  133. if (roleCode != null) map['RoleCode'] = roleCode;
  134. return map;
  135. }
  136. }
  137. class FindDefaultRolesRequest extends TokenRequest {
  138. String? organizationCode;
  139. FindDefaultRolesRequest({
  140. this.organizationCode,
  141. String? token,
  142. }) : super(
  143. token: token,
  144. );
  145. factory FindDefaultRolesRequest.fromJson(Map<String, dynamic> map) {
  146. return FindDefaultRolesRequest(
  147. organizationCode: map['OrganizationCode'],
  148. token: map['Token'],
  149. );
  150. }
  151. Map<String, dynamic> toJson() {
  152. final map = super.toJson();
  153. if (organizationCode != null) map['OrganizationCode'] = organizationCode;
  154. return map;
  155. }
  156. }
  157. class FindAuthenticationRolesRequest extends TokenRequest {
  158. String? organizationCode;
  159. FindAuthenticationRolesRequest({
  160. this.organizationCode,
  161. String? token,
  162. }) : super(
  163. token: token,
  164. );
  165. factory FindAuthenticationRolesRequest.fromJson(Map<String, dynamic> map) {
  166. return FindAuthenticationRolesRequest(
  167. organizationCode: map['OrganizationCode'],
  168. token: map['Token'],
  169. );
  170. }
  171. Map<String, dynamic> toJson() {
  172. final map = super.toJson();
  173. if (organizationCode != null) map['OrganizationCode'] = organizationCode;
  174. return map;
  175. }
  176. }