role.m.dart 4.5 KB

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