device.m.dart 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. import 'package:fis_jsonrpc/utils.dart';
  2. import 'package:fis_common/json_convert.dart';
  3. class BaseDTO {
  4. DateTime? createTime;
  5. DateTime? updateTime;
  6. BaseDTO({
  7. this.createTime,
  8. this.updateTime,
  9. });
  10. factory BaseDTO.fromJson(Map<String, dynamic> map) {
  11. return BaseDTO(
  12. createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null,
  13. updateTime: map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null,
  14. );
  15. }
  16. Map<String, dynamic> toJson() {
  17. final map = Map<String, dynamic>();
  18. if(createTime != null)
  19. map['CreateTime'] = JsonRpcUtils.dateFormat(createTime!);
  20. if(updateTime != null)
  21. map['UpdateTime'] = JsonRpcUtils.dateFormat(updateTime!);
  22. return map;
  23. }
  24. }
  25. class DeviceInfoDTO extends BaseDTO{
  26. String? deviceCode;
  27. String? serialNumber;
  28. String? name;
  29. String? description;
  30. String? deviceModel;
  31. String? deviceType;
  32. String? headPicUrl;
  33. String? deviceSoftwareVersion;
  34. String? sDKSoftwareVersion;
  35. String? organizationCode;
  36. String? shortCode;
  37. DeviceInfoDTO({
  38. this.deviceCode,
  39. this.serialNumber,
  40. this.name,
  41. this.description,
  42. this.deviceModel,
  43. this.deviceType,
  44. this.headPicUrl,
  45. this.deviceSoftwareVersion,
  46. this.sDKSoftwareVersion,
  47. this.organizationCode,
  48. this.shortCode,
  49. DateTime? createTime,
  50. DateTime? updateTime,
  51. }) : super(
  52. createTime: createTime,
  53. updateTime: updateTime,
  54. );
  55. factory DeviceInfoDTO.fromJson(Map<String, dynamic> map) {
  56. return DeviceInfoDTO(
  57. deviceCode: map['DeviceCode'],
  58. serialNumber: map['SerialNumber'],
  59. name: map['Name'],
  60. description: map['Description'],
  61. deviceModel: map['DeviceModel'],
  62. deviceType: map['DeviceType'],
  63. headPicUrl: map['HeadPicUrl'],
  64. deviceSoftwareVersion: map['DeviceSoftwareVersion'],
  65. sDKSoftwareVersion: map['SDKSoftwareVersion'],
  66. organizationCode: map['OrganizationCode'],
  67. shortCode: map['ShortCode'],
  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(deviceCode != null)
  75. map['DeviceCode'] = deviceCode;
  76. if(serialNumber != null)
  77. map['SerialNumber'] = serialNumber;
  78. if(name != null)
  79. map['Name'] = name;
  80. if(description != null)
  81. map['Description'] = description;
  82. if(deviceModel != null)
  83. map['DeviceModel'] = deviceModel;
  84. if(deviceType != null)
  85. map['DeviceType'] = deviceType;
  86. if(headPicUrl != null)
  87. map['HeadPicUrl'] = headPicUrl;
  88. if(deviceSoftwareVersion != null)
  89. map['DeviceSoftwareVersion'] = deviceSoftwareVersion;
  90. if(sDKSoftwareVersion != null)
  91. map['SDKSoftwareVersion'] = sDKSoftwareVersion;
  92. if(organizationCode != null)
  93. map['OrganizationCode'] = organizationCode;
  94. if(shortCode != null)
  95. map['ShortCode'] = shortCode;
  96. return map;
  97. }
  98. }
  99. class CreateDeviceRequest extends DeviceInfoDTO{
  100. String? token;
  101. CreateDeviceRequest({
  102. this.token,
  103. String? deviceCode,
  104. String? serialNumber,
  105. String? name,
  106. String? description,
  107. String? deviceModel,
  108. String? deviceType,
  109. String? headPicUrl,
  110. String? deviceSoftwareVersion,
  111. String? sDKSoftwareVersion,
  112. String? organizationCode,
  113. String? shortCode,
  114. DateTime? createTime,
  115. DateTime? updateTime,
  116. }) : super(
  117. deviceCode: deviceCode,
  118. serialNumber: serialNumber,
  119. name: name,
  120. description: description,
  121. deviceModel: deviceModel,
  122. deviceType: deviceType,
  123. headPicUrl: headPicUrl,
  124. deviceSoftwareVersion: deviceSoftwareVersion,
  125. sDKSoftwareVersion: sDKSoftwareVersion,
  126. organizationCode: organizationCode,
  127. shortCode: shortCode,
  128. createTime: createTime,
  129. updateTime: updateTime,
  130. );
  131. factory CreateDeviceRequest.fromJson(Map<String, dynamic> map) {
  132. return CreateDeviceRequest(
  133. token: map['Token'],
  134. deviceCode: map['DeviceCode'],
  135. serialNumber: map['SerialNumber'],
  136. name: map['Name'],
  137. description: map['Description'],
  138. deviceModel: map['DeviceModel'],
  139. deviceType: map['DeviceType'],
  140. headPicUrl: map['HeadPicUrl'],
  141. deviceSoftwareVersion: map['DeviceSoftwareVersion'],
  142. sDKSoftwareVersion: map['SDKSoftwareVersion'],
  143. organizationCode: map['OrganizationCode'],
  144. shortCode: map['ShortCode'],
  145. createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null,
  146. updateTime: map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null,
  147. );
  148. }
  149. Map<String, dynamic> toJson() {
  150. final map = super.toJson();
  151. if(token != null)
  152. map['Token'] = token;
  153. return map;
  154. }
  155. }
  156. class PageCollection<T> {
  157. int currentPage;
  158. int pageSize;
  159. int dataCount;
  160. List<T>? pageData;
  161. PageCollection({
  162. this.currentPage = 0,
  163. this.pageSize = 0,
  164. this.dataCount = 0,
  165. this.pageData,
  166. });
  167. factory PageCollection.fromJson(Map<String, dynamic> map) {
  168. List<T> pageDataList = [];
  169. if (map['PageData'] != null) {
  170. pageDataList.addAll(
  171. (map['PageData'] as List).map((e) => FJsonConvert.fromJson<T>(e)!));
  172. }
  173. return PageCollection(
  174. currentPage: map['CurrentPage'],
  175. pageSize: map['PageSize'],
  176. dataCount: map['DataCount'],
  177. pageData: pageDataList,
  178. );
  179. }
  180. Map<String, dynamic> toJson() {
  181. final map = Map<String, dynamic>();
  182. map['CurrentPage'] = currentPage;
  183. map['PageSize'] = pageSize;
  184. map['DataCount'] = dataCount;
  185. if(pageData != null)
  186. map['PageData'] = pageData;
  187. return map;
  188. }
  189. }
  190. class BaseRequest {
  191. String? token;
  192. BaseRequest({
  193. this.token,
  194. });
  195. factory BaseRequest.fromJson(Map<String, dynamic> map) {
  196. return BaseRequest(
  197. token: map['Token'],
  198. );
  199. }
  200. Map<String, dynamic> toJson() {
  201. final map = Map<String, dynamic>();
  202. if(token != null)
  203. map['Token'] = token;
  204. return map;
  205. }
  206. }
  207. class PageRequest extends BaseRequest{
  208. int currentPage;
  209. int pageSize;
  210. Map<String,String>? filter;
  211. bool isFuzzy;
  212. PageRequest({
  213. this.currentPage = 0,
  214. this.pageSize = 0,
  215. this.filter,
  216. this.isFuzzy = false,
  217. String? token,
  218. }) : super(
  219. token: token,
  220. );
  221. factory PageRequest.fromJson(Map<String, dynamic> map) {
  222. return PageRequest(
  223. currentPage: map['CurrentPage'],
  224. pageSize: map['PageSize'],
  225. filter: map['Filter'] != null ? map['Filter'].cast<String,String>() : null,
  226. isFuzzy: map['IsFuzzy'],
  227. token: map['Token'],
  228. );
  229. }
  230. Map<String, dynamic> toJson() {
  231. final map = super.toJson();
  232. map['CurrentPage'] = currentPage;
  233. map['PageSize'] = pageSize;
  234. if(filter != null)
  235. map['Filter'] = filter;
  236. map['IsFuzzy'] = isFuzzy;
  237. return map;
  238. }
  239. }
  240. class TokenRequest extends BaseRequest{
  241. TokenRequest({
  242. String? token,
  243. }) : super(
  244. token: token,
  245. );
  246. factory TokenRequest.fromJson(Map<String, dynamic> map) {
  247. return TokenRequest(
  248. token: map['Token'],
  249. );
  250. }
  251. Map<String, dynamic> toJson() {
  252. final map = super.toJson();
  253. return map;
  254. }
  255. }
  256. class CreateShareDeviceToUserRequest extends TokenRequest{
  257. List<String>? userCodes;
  258. String? deviceCode;
  259. CreateShareDeviceToUserRequest({
  260. this.userCodes,
  261. this.deviceCode,
  262. String? token,
  263. }) : super(
  264. token: token,
  265. );
  266. factory CreateShareDeviceToUserRequest.fromJson(Map<String, dynamic> map) {
  267. final userCodesData = map['UserCodes'];
  268. return CreateShareDeviceToUserRequest(
  269. userCodes: userCodesData != null ? (userCodesData as List).map((e) => e as String).toList(): null,
  270. deviceCode: map['DeviceCode'],
  271. token: map['Token'],
  272. );
  273. }
  274. Map<String, dynamic> toJson() {
  275. final map = super.toJson();
  276. if(userCodes != null)
  277. map['UserCodes'] = userCodes;
  278. if(deviceCode != null)
  279. map['DeviceCode'] = deviceCode;
  280. return map;
  281. }
  282. }
  283. class DeleteShareDeviceToUserRequest extends TokenRequest{
  284. List<String>? userCodes;
  285. String? deviceCode;
  286. DeleteShareDeviceToUserRequest({
  287. this.userCodes,
  288. this.deviceCode,
  289. String? token,
  290. }) : super(
  291. token: token,
  292. );
  293. factory DeleteShareDeviceToUserRequest.fromJson(Map<String, dynamic> map) {
  294. final userCodesData = map['UserCodes'];
  295. return DeleteShareDeviceToUserRequest(
  296. userCodes: userCodesData != null ? (userCodesData as List).map((e) => e as String).toList(): null,
  297. deviceCode: map['DeviceCode'],
  298. token: map['Token'],
  299. );
  300. }
  301. Map<String, dynamic> toJson() {
  302. final map = super.toJson();
  303. if(userCodes != null)
  304. map['UserCodes'] = userCodes;
  305. if(deviceCode != null)
  306. map['DeviceCode'] = deviceCode;
  307. return map;
  308. }
  309. }