masterInteractionCenter.m.dart 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. import 'package:fis_jsonrpc/utils.dart';
  2. enum MongoDBActionTypeEnum {
  3. InsertOne,
  4. InsertOneAsync,
  5. InsertMany,
  6. InsertManyAsync,
  7. DeleteOne,
  8. DeleteOneAsync,
  9. DeleteMany,
  10. DeleteManyAsync,
  11. FindOneAndDelete,
  12. FindOneAndDeleteAsync,
  13. ReplaceOne,
  14. ReplaceOneAsync,
  15. FindOneAndReplace,
  16. FindOneAndReplaceAsync,
  17. UpdateOne,
  18. UpdateOneAsync,
  19. UpdateMany,
  20. UpdateManyAsync,
  21. FindOneAndUpdate,
  22. FindOneAndUpdateAsync,
  23. }
  24. class OperationLogDTO {
  25. int id;
  26. String? collectionName;
  27. MongoDBActionTypeEnum actionType;
  28. String? bsonContent;
  29. String? filterContent;
  30. DateTime? createTime;
  31. String? code;
  32. String? sourceUrl;
  33. bool isSimple;
  34. OperationLogDTO({
  35. this.id = 0,
  36. this.collectionName,
  37. this.actionType = MongoDBActionTypeEnum.InsertOne,
  38. this.bsonContent,
  39. this.filterContent,
  40. this.createTime,
  41. this.code,
  42. this.sourceUrl,
  43. this.isSimple = false,
  44. });
  45. factory OperationLogDTO.fromJson(Map<String, dynamic> map) {
  46. return OperationLogDTO(
  47. id: map['Id'],
  48. collectionName: map['CollectionName'],
  49. actionType: MongoDBActionTypeEnum.values.firstWhere((e) => e.index == map['ActionType']),
  50. bsonContent: map['BsonContent'],
  51. filterContent: map['FilterContent'],
  52. createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null,
  53. code: map['Code'],
  54. sourceUrl: map['SourceUrl'],
  55. isSimple: map['IsSimple'],
  56. );
  57. }
  58. Map<String, dynamic> toJson() {
  59. final map = Map<String, dynamic>();
  60. map['Id'] = id;
  61. if(collectionName != null)
  62. map['CollectionName'] = collectionName;
  63. map['ActionType'] = actionType.index;
  64. if(bsonContent != null)
  65. map['BsonContent'] = bsonContent;
  66. if(filterContent != null)
  67. map['FilterContent'] = filterContent;
  68. if(createTime != null)
  69. map['CreateTime'] = JsonRpcUtils.dateFormat(createTime!);
  70. if(code != null)
  71. map['Code'] = code;
  72. if(sourceUrl != null)
  73. map['SourceUrl'] = sourceUrl;
  74. map['IsSimple'] = isSimple;
  75. return map;
  76. }
  77. }
  78. class GetOpLogsFormMasterRequest {
  79. int cursor;
  80. String? sourceUrl;
  81. GetOpLogsFormMasterRequest({
  82. this.cursor = 0,
  83. this.sourceUrl,
  84. });
  85. factory GetOpLogsFormMasterRequest.fromJson(Map<String, dynamic> map) {
  86. return GetOpLogsFormMasterRequest(
  87. cursor: map['Cursor'],
  88. sourceUrl: map['SourceUrl'],
  89. );
  90. }
  91. Map<String, dynamic> toJson() {
  92. final map = Map<String, dynamic>();
  93. map['Cursor'] = cursor;
  94. if(sourceUrl != null)
  95. map['SourceUrl'] = sourceUrl;
  96. return map;
  97. }
  98. }
  99. class GetOpLogsByCodesFormMasterRequest {
  100. List<String >? codes;
  101. GetOpLogsByCodesFormMasterRequest({
  102. this.codes,
  103. });
  104. factory GetOpLogsByCodesFormMasterRequest.fromJson(Map<String, dynamic> map) {
  105. return GetOpLogsByCodesFormMasterRequest(
  106. codes: map['Codes'] != null ? map['Codes'].cast<String>().toList() : null,
  107. );
  108. }
  109. Map<String, dynamic> toJson() {
  110. final map = Map<String, dynamic>();
  111. if(codes != null)
  112. map['Codes'] = codes;
  113. return map;
  114. }
  115. }
  116. class SyncOpLogToMasterRequest {
  117. String? collectionName;
  118. MongoDBActionTypeEnum actionType;
  119. String? bsonContent;
  120. String? filterContent;
  121. DateTime? createTime;
  122. String? sourceUrl;
  123. String? code;
  124. String? serverID;
  125. bool isSimple;
  126. SyncOpLogToMasterRequest({
  127. this.collectionName,
  128. this.actionType = MongoDBActionTypeEnum.InsertOne,
  129. this.bsonContent,
  130. this.filterContent,
  131. this.createTime,
  132. this.sourceUrl,
  133. this.code,
  134. this.serverID,
  135. this.isSimple = false,
  136. });
  137. factory SyncOpLogToMasterRequest.fromJson(Map<String, dynamic> map) {
  138. return SyncOpLogToMasterRequest(
  139. collectionName: map['CollectionName'],
  140. actionType: MongoDBActionTypeEnum.values.firstWhere((e) => e.index == map['ActionType']),
  141. bsonContent: map['BsonContent'],
  142. filterContent: map['FilterContent'],
  143. createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null,
  144. sourceUrl: map['SourceUrl'],
  145. code: map['Code'],
  146. serverID: map['ServerID'],
  147. isSimple: map['IsSimple'],
  148. );
  149. }
  150. Map<String, dynamic> toJson() {
  151. final map = Map<String, dynamic>();
  152. if(collectionName != null)
  153. map['CollectionName'] = collectionName;
  154. map['ActionType'] = actionType.index;
  155. if(bsonContent != null)
  156. map['BsonContent'] = bsonContent;
  157. if(filterContent != null)
  158. map['FilterContent'] = filterContent;
  159. if(createTime != null)
  160. map['CreateTime'] = JsonRpcUtils.dateFormat(createTime!);
  161. if(sourceUrl != null)
  162. map['SourceUrl'] = sourceUrl;
  163. if(code != null)
  164. map['Code'] = code;
  165. if(serverID != null)
  166. map['ServerID'] = serverID;
  167. map['IsSimple'] = isSimple;
  168. return map;
  169. }
  170. }
  171. enum SyncTypeEnum {
  172. Initiate,
  173. Accept,
  174. Reject,
  175. CancelInitiate,
  176. HeartRateJoin,
  177. NetworkErr,
  178. HeartRateLeave,
  179. Leave,
  180. Close,
  181. ChangeMuteState,
  182. ChangeVideoOpenState,
  183. InviteIn,
  184. CancelInviteIn,
  185. AcceptIn,
  186. RejectIn,
  187. ChangeConsultationStatus,
  188. Agree,
  189. }
  190. class SyncReceiveServiceDataRequest {
  191. SyncTypeEnum syncType;
  192. String? serviceDataJson;
  193. List<OperationLogDTO >? oplogs;
  194. String? sourceUrl;
  195. String? serverID;
  196. SyncReceiveServiceDataRequest({
  197. this.syncType = SyncTypeEnum.Initiate,
  198. this.serviceDataJson,
  199. this.oplogs,
  200. this.sourceUrl,
  201. this.serverID,
  202. });
  203. factory SyncReceiveServiceDataRequest.fromJson(Map<String, dynamic> map) {
  204. return SyncReceiveServiceDataRequest(
  205. syncType: SyncTypeEnum.values.firstWhere((e) => e.index == map['SyncType']),
  206. serviceDataJson: map['ServiceDataJson'],
  207. oplogs: map['Oplogs'] != null ? (map['Oplogs'] as List).map((e)=>OperationLogDTO.fromJson(e as Map<String,dynamic>)).toList() : null,
  208. sourceUrl: map['SourceUrl'],
  209. serverID: map['ServerID'],
  210. );
  211. }
  212. Map<String, dynamic> toJson() {
  213. final map = Map<String, dynamic>();
  214. map['SyncType'] = syncType.index;
  215. if(serviceDataJson != null)
  216. map['ServiceDataJson'] = serviceDataJson;
  217. if(oplogs != null)
  218. map['Oplogs'] = oplogs;
  219. if(sourceUrl != null)
  220. map['SourceUrl'] = sourceUrl;
  221. if(serverID != null)
  222. map['ServerID'] = serverID;
  223. return map;
  224. }
  225. }