device.m.dart 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. import 'package:fis_jsonrpc/utils.dart';
  2. import 'package:fis_common/json_convert.dart';
  3. class BaseRequest {
  4. String? token;
  5. BaseRequest({
  6. this.token,
  7. });
  8. factory BaseRequest.fromJson(Map<String, dynamic> map) {
  9. return BaseRequest(
  10. token: map['Token'],
  11. );
  12. }
  13. Map<String, dynamic> toJson() {
  14. final map = Map<String, dynamic>();
  15. if(token != null)
  16. map['Token'] = token;
  17. return map;
  18. }
  19. }
  20. class BaseEntity {
  21. DateTime? createTime;
  22. DateTime? updateTime;
  23. BaseEntity({
  24. this.createTime,
  25. this.updateTime,
  26. });
  27. factory BaseEntity.fromJson(Map<String, dynamic> map) {
  28. return BaseEntity(
  29. createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null,
  30. updateTime: map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null,
  31. );
  32. }
  33. Map<String, dynamic> toJson() {
  34. final map = Map<String, dynamic>();
  35. if(createTime != null)
  36. map['CreateTime'] = JsonRpcUtils.dateFormat(createTime!);
  37. if(updateTime != null)
  38. map['UpdateTime'] = JsonRpcUtils.dateFormat(updateTime!);
  39. return map;
  40. }
  41. }
  42. class DeviceInfo extends BaseEntity{
  43. String? deviceCode;
  44. String? serialNumber;
  45. String? description;
  46. String? deviceModel;
  47. String? deviceType;
  48. String? headPicUrl;
  49. String? deviceSoftwareVersion;
  50. String? sDKSoftwareVersion;
  51. String? organizationCode;
  52. String? shortCode;
  53. DeviceInfo({
  54. this.deviceCode,
  55. this.serialNumber,
  56. this.description,
  57. this.deviceModel,
  58. this.deviceType,
  59. this.headPicUrl,
  60. this.deviceSoftwareVersion,
  61. this.sDKSoftwareVersion,
  62. this.organizationCode,
  63. this.shortCode,
  64. DateTime? createTime,
  65. DateTime? updateTime,
  66. }) : super(
  67. createTime: createTime,
  68. updateTime: updateTime,
  69. );
  70. factory DeviceInfo.fromJson(Map<String, dynamic> map) {
  71. return DeviceInfo(
  72. deviceCode: map['DeviceCode'],
  73. serialNumber: map['SerialNumber'],
  74. description: map['Description'],
  75. deviceModel: map['DeviceModel'],
  76. deviceType: map['DeviceType'],
  77. headPicUrl: map['HeadPicUrl'],
  78. deviceSoftwareVersion: map['DeviceSoftwareVersion'],
  79. sDKSoftwareVersion: map['SDKSoftwareVersion'],
  80. organizationCode: map['OrganizationCode'],
  81. shortCode: map['ShortCode'],
  82. createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null,
  83. updateTime: map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null,
  84. );
  85. }
  86. Map<String, dynamic> toJson() {
  87. final map = super.toJson();
  88. if(deviceCode != null)
  89. map['DeviceCode'] = deviceCode;
  90. if(serialNumber != null)
  91. map['SerialNumber'] = serialNumber;
  92. if(description != null)
  93. map['Description'] = description;
  94. if(deviceModel != null)
  95. map['DeviceModel'] = deviceModel;
  96. if(deviceType != null)
  97. map['DeviceType'] = deviceType;
  98. if(headPicUrl != null)
  99. map['HeadPicUrl'] = headPicUrl;
  100. if(deviceSoftwareVersion != null)
  101. map['DeviceSoftwareVersion'] = deviceSoftwareVersion;
  102. if(sDKSoftwareVersion != null)
  103. map['SDKSoftwareVersion'] = sDKSoftwareVersion;
  104. if(organizationCode != null)
  105. map['OrganizationCode'] = organizationCode;
  106. if(shortCode != null)
  107. map['ShortCode'] = shortCode;
  108. return map;
  109. }
  110. }
  111. class CreateDeviceInfoRequest extends BaseRequest{
  112. DeviceInfo? info;
  113. CreateDeviceInfoRequest({
  114. this.info,
  115. String? token,
  116. }) : super(
  117. token: token,
  118. );
  119. factory CreateDeviceInfoRequest.fromJson(Map<String, dynamic> map) {
  120. return CreateDeviceInfoRequest(
  121. info: map['Info'],
  122. token: map['Token'],
  123. );
  124. }
  125. Map<String, dynamic> toJson() {
  126. final map = super.toJson();
  127. if(info != null)
  128. map['Info'] = info;
  129. return map;
  130. }
  131. }
  132. class PageCollection<T> {
  133. int currentPage;
  134. int pageSize;
  135. int dataCount;
  136. List<T>? pageData;
  137. PageCollection({
  138. this.currentPage = 0,
  139. this.pageSize = 0,
  140. this.dataCount = 0,
  141. this.pageData,
  142. });
  143. factory PageCollection.fromJson(Map<String, dynamic> map) {
  144. List<T> pageDataList = [];
  145. if (map['PageData'] != null) {
  146. pageDataList.addAll(
  147. (map['PageData'] as List).map((e) => FJsonConvert.fromJson<T>(e)!));
  148. }
  149. return PageCollection(
  150. currentPage: map['CurrentPage'],
  151. pageSize: map['PageSize'],
  152. dataCount: map['DataCount'],
  153. pageData: pageDataList,
  154. );
  155. }
  156. Map<String, dynamic> toJson() {
  157. final map = Map<String, dynamic>();
  158. map['CurrentPage'] = currentPage;
  159. map['PageSize'] = pageSize;
  160. map['DataCount'] = dataCount;
  161. if(pageData != null)
  162. map['PageData'] = pageData;
  163. return map;
  164. }
  165. }
  166. class PageRequest extends BaseRequest{
  167. int currentPage;
  168. int pageSize;
  169. Map<String,String>? filter;
  170. bool isFuzzy;
  171. PageRequest({
  172. this.currentPage = 0,
  173. this.pageSize = 0,
  174. this.filter,
  175. this.isFuzzy = false,
  176. String? token,
  177. }) : super(
  178. token: token,
  179. );
  180. factory PageRequest.fromJson(Map<String, dynamic> map) {
  181. return PageRequest(
  182. currentPage: map['CurrentPage'],
  183. pageSize: map['PageSize'],
  184. filter: map['Filter'].cast<String,String>(),
  185. isFuzzy: map['IsFuzzy'],
  186. token: map['Token'],
  187. );
  188. }
  189. Map<String, dynamic> toJson() {
  190. final map = super.toJson();
  191. map['CurrentPage'] = currentPage;
  192. map['PageSize'] = pageSize;
  193. if(filter != null)
  194. map['Filter'] = filter;
  195. map['IsFuzzy'] = isFuzzy;
  196. return map;
  197. }
  198. }