loki.wu преди 1 година
родител
ревизия
2dfe6d5a50
променени са 1 файла, в които са добавени 149 реда и са изтрити 133 реда
  1. 149 133
      lib/rpc.dart

+ 149 - 133
lib/rpc.dart

@@ -1,9 +1,11 @@
 library fis_jsonrpc;
 
 import 'dart:collection';
+import 'dart:convert';
 
 import 'package:fis_common/extensions/type.dart';
 import 'package:fis_common/logger/logger.dart';
+import 'package:fis_jsonrpc/encrpyt.dart';
 
 import 'client_base.dart';
 import 'interceptor.dart';
@@ -44,210 +46,225 @@ class JsonRpcProxy {
 
   static PlatformService? _platformService;
 
+  /// 请求加密配置
+  JsonRpcEncryptConfig get requestEncryptConfig =>
+      JsonRpcClientBase.requestEncryptConfig;
+  set requestEncryptConfig(JsonRpcEncryptConfig config) {
+    JsonRpcClientBase.requestEncryptConfig = config;
+    final cfgJson = jsonEncode(config.toJson());
+    logger.i("JsonRpcProxy - set RequestEncryptConfig: $cfgJson.");
+  }
+
+  /// 响应加密配置
+  JsonRpcEncryptConfig get responseEncryptConfig =>
+      JsonRpcClientBase.responseEncryptConfig;
+  set responseEncryptConfig(JsonRpcEncryptConfig config) {
+    JsonRpcClientBase.responseEncryptConfig = config;
+    final cfgJson = jsonEncode(config.toJson());
+    logger.i("JsonRpcProxy - set ResponseEncryptConfig: $cfgJson.");
+  }
+
   /* 服务代理设置 Start */
 
   /// 平台服务
   PlatformService get platform {
     if (_platformService == null)
-      _platformService = PlatformService("http://$platformHost", timeout: 15000);
+      _platformService =
+          PlatformService("http://$platformHost", timeout: 15000);
     return _platformService!;
   }
 
-	LiveConsultationService get liveConsultation =>
-	findService(() => new LiveConsultationService(currentHostAddress));
-
-	AIDiagnosisService get aIDiagnosis =>
-	findService(() => new AIDiagnosisService(currentHostAddress));
+  LiveConsultationService get liveConsultation =>
+      findService(() => new LiveConsultationService(currentHostAddress));
 
-	AppletAPIService get appletAPI =>
-	findService(() => new AppletAPIService(currentHostAddress));
+  AIDiagnosisService get aIDiagnosis =>
+      findService(() => new AIDiagnosisService(currentHostAddress));
 
-	ASRService get aSR =>
-	findService(() => new ASRService(currentHostAddress));
+  AppletAPIService get appletAPI =>
+      findService(() => new AppletAPIService(currentHostAddress));
 
-	AuthenticationService get authentication =>
-	findService(() => new AuthenticationService(currentHostAddress));
+  ASRService get aSR => findService(() => new ASRService(currentHostAddress));
 
-	ChatMessageService get chatMessage =>
-	findService(() => new ChatMessageService(currentHostAddress));
+  AuthenticationService get authentication =>
+      findService(() => new AuthenticationService(currentHostAddress));
 
-	ConnectService get connect =>
-	findService(() => new ConnectService(currentHostAddress));
+  ChatMessageService get chatMessage =>
+      findService(() => new ChatMessageService(currentHostAddress));
 
-	DeployPlatformService get deployPlatform =>
-	findService(() => new DeployPlatformService(currentHostAddress));
+  ConnectService get connect =>
+      findService(() => new ConnectService(currentHostAddress));
 
-	DeviceService get device =>
-	findService(() => new DeviceService(currentHostAddress));
+  DeployPlatformService get deployPlatform =>
+      findService(() => new DeployPlatformService(currentHostAddress));
 
-	EducationService get education =>
-	findService(() => new EducationService(currentHostAddress));
+  DeviceService get device =>
+      findService(() => new DeviceService(currentHostAddress));
 
-	EmailService get email =>
-	findService(() => new EmailService(currentHostAddress));
+  EducationService get education =>
+      findService(() => new EducationService(currentHostAddress));
 
-	IdentityApplyService get identityApply =>
-	findService(() => new IdentityApplyService(currentHostAddress));
+  EmailService get email =>
+      findService(() => new EmailService(currentHostAddress));
 
-	LabService get lab =>
-	findService(() => new LabService(currentHostAddress));
+  IdentityApplyService get identityApply =>
+      findService(() => new IdentityApplyService(currentHostAddress));
 
-	LoginService get login =>
-	findService(() => new LoginService(currentHostAddress));
+  LabService get lab => findService(() => new LabService(currentHostAddress));
 
-	OrganizationService get organization =>
-	findService(() => new OrganizationService(currentHostAddress));
+  LoginService get login =>
+      findService(() => new LoginService(currentHostAddress));
 
-	PatientService get patient =>
-	findService(() => new PatientService(currentHostAddress));
+  OrganizationService get organization =>
+      findService(() => new OrganizationService(currentHostAddress));
 
-	PaymentService get payment =>
-	findService(() => new PaymentService(currentHostAddress));
+  PatientService get patient =>
+      findService(() => new PatientService(currentHostAddress));
 
-	PositionService get position =>
-	findService(() => new PositionService(currentHostAddress));
+  PaymentService get payment =>
+      findService(() => new PaymentService(currentHostAddress));
 
-	RankService get rank =>
-	findService(() => new RankService(currentHostAddress));
+  PositionService get position =>
+      findService(() => new PositionService(currentHostAddress));
 
-	RecognitionService get recognition =>
-	findService(() => new RecognitionService(currentHostAddress));
+  RankService get rank =>
+      findService(() => new RankService(currentHostAddress));
 
-	RecordInfoService get recordInfo =>
-	findService(() => new RecordInfoService(currentHostAddress));
+  RecognitionService get recognition =>
+      findService(() => new RecognitionService(currentHostAddress));
 
-	RegionService get region =>
-	findService(() => new RegionService(currentHostAddress));
+  RecordInfoService get recordInfo =>
+      findService(() => new RecordInfoService(currentHostAddress));
 
-	RegisterService get register =>
-	findService(() => new RegisterService(currentHostAddress));
+  RegionService get region =>
+      findService(() => new RegionService(currentHostAddress));
 
-	RemedicalService get remedical =>
-	findService(() => new RemedicalService(currentHostAddress));
+  RegisterService get register =>
+      findService(() => new RegisterService(currentHostAddress));
 
-	ReportService get report =>
-	findService(() => new ReportService(currentHostAddress));
+  RemedicalService get remedical =>
+      findService(() => new RemedicalService(currentHostAddress));
 
-	RoleService get role =>
-	findService(() => new RoleService(currentHostAddress));
+  ReportService get report =>
+      findService(() => new ReportService(currentHostAddress));
 
-	SMSService get sMS =>
-	findService(() => new SMSService(currentHostAddress));
+  RoleService get role =>
+      findService(() => new RoleService(currentHostAddress));
 
-	StorageService get storage =>
-	findService(() => new StorageService(currentHostAddress));
+  SMSService get sMS => findService(() => new SMSService(currentHostAddress));
 
-	UpgradeService get upgrade =>
-	findService(() => new UpgradeService(currentHostAddress));
+  StorageService get storage =>
+      findService(() => new StorageService(currentHostAddress));
 
-	UserService get user =>
-	findService(() => new UserService(currentHostAddress));
+  UpgradeService get upgrade =>
+      findService(() => new UpgradeService(currentHostAddress));
 
-	VinnoIOTService get vinnoIOT =>
-	findService(() => new VinnoIOTService(currentHostAddress));
+  UserService get user =>
+      findService(() => new UserService(currentHostAddress));
 
-	VinnoServerService get vinnoServer =>
-	findService(() => new VinnoServerService(currentHostAddress));
+  VinnoIOTService get vinnoIOT =>
+      findService(() => new VinnoIOTService(currentHostAddress));
 
-	VitalHealthExamBookingService get vitalHealthExamBooking =>
-	findService(() => new VitalHealthExamBookingService(currentHostAddress));
+  VinnoServerService get vinnoServer =>
+      findService(() => new VinnoServerService(currentHostAddress));
 
-	VitalAnalyzeConfigService get vitalAnalyzeConfig =>
-	findService(() => new VitalAnalyzeConfigService(currentHostAddress));
+  VitalHealthExamBookingService get vitalHealthExamBooking =>
+      findService(() => new VitalHealthExamBookingService(currentHostAddress));
 
-	VitalCompletionRecordService get vitalCompletionRecord =>
-	findService(() => new VitalCompletionRecordService(currentHostAddress));
+  VitalAnalyzeConfigService get vitalAnalyzeConfig =>
+      findService(() => new VitalAnalyzeConfigService(currentHostAddress));
 
-	VitalContractRecordService get vitalContractRecord =>
-	findService(() => new VitalContractRecordService(currentHostAddress));
+  VitalCompletionRecordService get vitalCompletionRecord =>
+      findService(() => new VitalCompletionRecordService(currentHostAddress));
 
-	VitalContractTemplateService get vitalContractTemplate =>
-	findService(() => new VitalContractTemplateService(currentHostAddress));
+  VitalContractRecordService get vitalContractRecord =>
+      findService(() => new VitalContractRecordService(currentHostAddress));
 
-	VitalDeviceService get vitalDevice =>
-	findService(() => new VitalDeviceService(currentHostAddress));
+  VitalContractTemplateService get vitalContractTemplate =>
+      findService(() => new VitalContractTemplateService(currentHostAddress));
 
-	VitalDiagnosisService get vitalDiagnosis =>
-	findService(() => new VitalDiagnosisService(currentHostAddress));
+  VitalDeviceService get vitalDevice =>
+      findService(() => new VitalDeviceService(currentHostAddress));
 
-	VitalDictionaryService get vitalDictionary =>
-	findService(() => new VitalDictionaryService(currentHostAddress));
+  VitalDiagnosisService get vitalDiagnosis =>
+      findService(() => new VitalDiagnosisService(currentHostAddress));
 
-	VitalDynamicTypeService get vitalDynamicType =>
-	findService(() => new VitalDynamicTypeService(currentHostAddress));
+  VitalDictionaryService get vitalDictionary =>
+      findService(() => new VitalDictionaryService(currentHostAddress));
 
-	VitalExamService get vitalExam =>
-	findService(() => new VitalExamService(currentHostAddress));
+  VitalDynamicTypeService get vitalDynamicType =>
+      findService(() => new VitalDynamicTypeService(currentHostAddress));
 
-	VitalFollowUpService get vitalFollowUp =>
-	findService(() => new VitalFollowUpService(currentHostAddress));
+  VitalExamService get vitalExam =>
+      findService(() => new VitalExamService(currentHostAddress));
 
-	VitalLabelService get vitalLabel =>
-	findService(() => new VitalLabelService(currentHostAddress));
+  VitalFollowUpService get vitalFollowUp =>
+      findService(() => new VitalFollowUpService(currentHostAddress));
 
-	VitalLoginService get vitalLogin =>
-	findService(() => new VitalLoginService(currentHostAddress));
+  VitalLabelService get vitalLabel =>
+      findService(() => new VitalLabelService(currentHostAddress));
 
-	VitalOperationLogService get vitalOperationLog =>
-	findService(() => new VitalOperationLogService(currentHostAddress));
+  VitalLoginService get vitalLogin =>
+      findService(() => new VitalLoginService(currentHostAddress));
 
-	VitalOrganizationService get vitalOrganization =>
-	findService(() => new VitalOrganizationService(currentHostAddress));
+  VitalOperationLogService get vitalOperationLog =>
+      findService(() => new VitalOperationLogService(currentHostAddress));
 
-	VitalPatientExtensionService get vitalPatientExtension =>
-	findService(() => new VitalPatientExtensionService(currentHostAddress));
+  VitalOrganizationService get vitalOrganization =>
+      findService(() => new VitalOrganizationService(currentHostAddress));
 
-	VitalPatientService get vitalPatient =>
-	findService(() => new VitalPatientService(currentHostAddress));
+  VitalPatientExtensionService get vitalPatientExtension =>
+      findService(() => new VitalPatientExtensionService(currentHostAddress));
 
-	VitalRegionService get vitalRegion =>
-	findService(() => new VitalRegionService(currentHostAddress));
+  VitalPatientService get vitalPatient =>
+      findService(() => new VitalPatientService(currentHostAddress));
 
-	VitalReportService get vitalReport =>
-	findService(() => new VitalReportService(currentHostAddress));
+  VitalRegionService get vitalRegion =>
+      findService(() => new VitalRegionService(currentHostAddress));
 
-	VitalResidenceService get vitalResidence =>
-	findService(() => new VitalResidenceService(currentHostAddress));
+  VitalReportService get vitalReport =>
+      findService(() => new VitalReportService(currentHostAddress));
 
-	VitalRoleService get vitalRole =>
-	findService(() => new VitalRoleService(currentHostAddress));
+  VitalResidenceService get vitalResidence =>
+      findService(() => new VitalResidenceService(currentHostAddress));
 
-	VitalScheduleService get vitalSchedule =>
-	findService(() => new VitalScheduleService(currentHostAddress));
+  VitalRoleService get vitalRole =>
+      findService(() => new VitalRoleService(currentHostAddress));
 
-	VitalServicePackService get vitalServicePack =>
-	findService(() => new VitalServicePackService(currentHostAddress));
+  VitalScheduleService get vitalSchedule =>
+      findService(() => new VitalScheduleService(currentHostAddress));
 
-	VitalStatisticService get vitalStatistic =>
-	findService(() => new VitalStatisticService(currentHostAddress));
+  VitalServicePackService get vitalServicePack =>
+      findService(() => new VitalServicePackService(currentHostAddress));
 
-	VitalSystemSettingService get vitalSystemSetting =>
-	findService(() => new VitalSystemSettingService(currentHostAddress));
+  VitalStatisticService get vitalStatistic =>
+      findService(() => new VitalStatisticService(currentHostAddress));
 
-	VitalTeamRegionService get vitalTeamRegion =>
-	findService(() => new VitalTeamRegionService(currentHostAddress));
+  VitalSystemSettingService get vitalSystemSetting =>
+      findService(() => new VitalSystemSettingService(currentHostAddress));
 
-	VitalTeamService get vitalTeam =>
-	findService(() => new VitalTeamService(currentHostAddress));
+  VitalTeamRegionService get vitalTeamRegion =>
+      findService(() => new VitalTeamRegionService(currentHostAddress));
 
-	VitalTemplateService get vitalTemplate =>
-	findService(() => new VitalTemplateService(currentHostAddress));
+  VitalTeamService get vitalTeam =>
+      findService(() => new VitalTeamService(currentHostAddress));
 
-	VitalTownService get vitalTown =>
-	findService(() => new VitalTownService(currentHostAddress));
+  VitalTemplateService get vitalTemplate =>
+      findService(() => new VitalTemplateService(currentHostAddress));
 
-	VitalUpgradeService get vitalUpgrade =>
-	findService(() => new VitalUpgradeService(currentHostAddress));
+  VitalTownService get vitalTown =>
+      findService(() => new VitalTownService(currentHostAddress));
 
-	VitalUserFeatureService get vitalUserFeature =>
-	findService(() => new VitalUserFeatureService(currentHostAddress));
+  VitalUpgradeService get vitalUpgrade =>
+      findService(() => new VitalUpgradeService(currentHostAddress));
 
-	VitalUserPasswordService get vitalUserPassword =>
-	findService(() => new VitalUserPasswordService(currentHostAddress));
+  VitalUserFeatureService get vitalUserFeature =>
+      findService(() => new VitalUserFeatureService(currentHostAddress));
 
-	VitalUserService get vitalUser =>
-	findService(() => new VitalUserService(currentHostAddress));
+  VitalUserPasswordService get vitalUserPassword =>
+      findService(() => new VitalUserPasswordService(currentHostAddress));
 
+  VitalUserService get vitalUser =>
+      findService(() => new VitalUserService(currentHostAddress));
 
   /* 服务代理设置 End */
 
@@ -274,4 +291,3 @@ class JsonRpcProxy {
     return _serviceCache[serviceType] as T;
   }
 }
-