Commit ff0f3b11 authored by 曹志's avatar 曹志

API模块

parent c5760d13
...@@ -93,3 +93,483 @@ ...@@ -93,3 +93,483 @@
[2020-11-16 18:45:48] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66 [2020-11-16 18:45:48] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-16 18:45:48] [WARN ] - [DUBBO] Use random available port(20880) for protocol dubbo, dubbo version: 2.7.6, current host: 10.10.10.66 [2020-11-16 18:45:48] [WARN ] - [DUBBO] Use random available port(20880) for protocol dubbo, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-16 18:45:48] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66 [2020-11-16 18:45:48] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:24:32] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:24:32] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:24:32] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:24:32] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:24:32] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:25:28] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:25:28] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:25:28] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:25:28] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:25:28] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:29:15] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:29:15] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:29:15] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:29:15] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:29:15] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:30:58] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:30:58] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:30:58] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:30:58] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:30:58] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:32:14] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:32:14] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:32:14] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:32:14] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:32:14] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:32:29] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:32:29] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:32:29] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:32:29] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:32:29] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:33:13] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:33:13] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:33:13] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:33:13] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:33:13] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:36:30] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:36:30] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:36:30] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:36:30] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:36:30] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:38:39] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:38:39] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:38:39] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:38:39] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:38:39] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:38:42] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:38:42] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:38:42] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:48:58] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:48:58] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:48:58] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:48:58] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:48:58] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:49:04] [WARN ] - [DUBBO] Duplicate RegistryConfig found, there already has one default RegistryConfig or more than two RegistryConfigs have the same id, you can try to give each RegistryConfig a different id : <dubbo:registry address="spring-cloud://10.10.10.221:8848" protocol="spring-cloud" port="8848" />, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:49:33] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:49:33] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:49:33] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:49:33] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:49:33] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:49:39] [WARN ] - [DUBBO] Duplicate RegistryConfig found, there already has one default RegistryConfig or more than two RegistryConfigs have the same id, you can try to give each RegistryConfig a different id : <dubbo:registry address="spring-cloud://10.10.10.221:8848" protocol="spring-cloud" port="8848" />, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:49:39] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:49:39] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:49:40] [WARN ] - [DUBBO] Use random available port(20880) for protocol dubbo, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:49:40] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:49:54] [WARN ] - [DUBBO] All registry instances have been destroyed, failed to fetch any instance. Usually, this means no need to try to do unnecessary redundant resource clearance, all registries has been taken care of., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:49:54] [WARN ] - [DUBBO] All registry instances have been destroyed, failed to fetch any instance. Usually, this means no need to try to do unnecessary redundant resource clearance, all registries has been taken care of., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:50:01] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:50:01] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:50:01] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:50:01] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:50:01] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:50:04] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:50:04] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:50:04] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:54:08] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:54:08] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:54:08] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:54:08] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:54:08] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:54:12] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:54:12] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:54:12] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:55:02] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:55:02] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:55:02] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:55:02] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:55:02] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:55:04] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:55:04] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:55:04] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:57:27] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:57:27] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:57:27] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:57:27] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:57:27] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:57:30] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:57:30] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:57:30] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:59:15] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:59:15] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:59:15] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:59:15] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:59:15] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:59:17] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:59:17] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 16:59:17] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:02:16] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:02:16] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:02:16] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:02:16] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:02:16] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:02:18] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:02:18] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:02:19] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:02:21] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:04:31] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:04:31] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:04:31] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:04:31] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:04:31] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:04:34] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:04:34] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:04:34] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:04:36] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:05:00] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:05:00] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:05:00] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:05:00] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:05:00] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:05:02] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:05:02] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:05:02] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:05:05] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:05:52] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:05:52] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:05:52] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:05:52] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:05:52] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:05:54] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:05:54] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:05:54] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:05:56] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:06:50] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:06:50] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:06:50] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:06:50] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:06:50] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:06:52] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:06:52] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:06:52] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:06:54] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:10:48] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:10:48] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:10:48] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:10:48] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:10:48] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:10:51] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:10:51] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:10:51] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:10:53] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:11:25] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:11:25] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:11:25] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:11:25] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:11:25] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:11:28] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:11:28] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:11:28] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:11:30] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:14:23] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:14:23] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:14:23] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:14:23] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:14:23] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:14:26] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:14:26] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:14:26] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:14:28] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:17:04] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:17:04] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:17:04] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:17:04] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:17:04] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:17:07] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:17:07] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:17:07] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:17:09] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:24:57] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:24:57] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:24:57] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:24:57] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:24:57] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:25:00] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:25:00] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:25:00] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:25:02] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:33:19] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:33:19] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:33:19] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:33:19] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:33:19] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:33:22] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:33:22] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:33:22] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:33:25] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:33:39] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:33:39] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:33:39] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:33:39] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:33:39] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:33:42] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:33:42] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:33:42] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:33:43] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:39:13] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:39:13] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:39:13] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:39:13] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:39:13] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:39:16] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:39:16] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:39:16] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:39:18] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:40:07] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:40:07] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:40:07] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:40:07] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:40:07] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:40:10] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:40:10] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:40:10] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:40:12] [WARN ] - [DUBBO] Use random available port(20880) for protocol dubbo, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:40:12] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:42:54] [WARN ] - [DUBBO] unsubscribe listener == null, dubbo version: 2.7.6, current host: 10.10.10.66
java.lang.IllegalArgumentException: unsubscribe listener == null
at org.apache.dubbo.registry.support.AbstractRegistry.unsubscribe(AbstractRegistry.java:325)
at org.apache.dubbo.registry.support.FailbackRegistry.unsubscribe(FailbackRegistry.java:329)
at org.apache.dubbo.registry.ListenerRegistryWrapper.unsubscribe(ListenerRegistryWrapper.java:129)
at org.apache.dubbo.registry.integration.RegistryProtocol$ExporterChangeableWrapper.unexport(RegistryProtocol.java:735)
at org.apache.dubbo.registry.integration.RegistryProtocol$DestroyableExporter.unexport(RegistryProtocol.java:554)
at org.apache.dubbo.config.ServiceConfig.unexport(ServiceConfig.java:170)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.lambda$unexportServices$16(DubboBootstrap.java:926)
at java.util.ArrayList.forEach(ArrayList.java:1259)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.unexportServices(DubboBootstrap.java:924)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.destroy(DubboBootstrap.java:1046)
at org.apache.dubbo.config.bootstrap.DubboBootstrap$1.callback(DubboBootstrap.java:191)
at org.apache.dubbo.common.function.ThrowableAction.execute(ThrowableAction.java:46)
at org.apache.dubbo.common.lang.ShutdownHookCallbacks.lambda$callback$0(ShutdownHookCallbacks.java:70)
at java.lang.Iterable.forEach(Iterable.java:75)
at org.apache.dubbo.common.lang.ShutdownHookCallbacks.callback(ShutdownHookCallbacks.java:70)
at org.apache.dubbo.config.DubboShutdownHook.callback(DubboShutdownHook.java:85)
at org.apache.dubbo.config.DubboShutdownHook.run(DubboShutdownHook.java:73)
[2020-11-17 17:43:01] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:43:01] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:43:01] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:43:01] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:43:01] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:43:03] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:43:03] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:43:03] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:43:05] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:46:43] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:46:43] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:46:43] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:46:43] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:46:43] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:46:46] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:46:46] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:46:46] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:46:48] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:46:49] [WARN ] - [DUBBO] Use random available port(20880) for protocol dubbo, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:49:15] [ERROR] - [DUBBO] Got unchecked and undeclared exception which called by 0:0:0:0:0:0:0:1. service: com.spacetech.service.RestApiHub, method: callPcApi, exception: java.lang.RuntimeException: 获取数据发现异常:null, dubbo version: 2.7.6, current host: 10.10.10.66
java.lang.RuntimeException: 获取数据发现异常:null
at com.spacetech.util.MemCacheForOnecardUtil.get(MemCacheForOnecardUtil.java:160)
at com.spacetech.util.MemCacheForOnecardUtil.getLoginSession(MemCacheForOnecardUtil.java:47)
at com.spacetech.service.RestApiHubImpl.extractedCallApi(RestApiHubImpl.java:337)
at com.spacetech.service.RestApiHubImpl.callPcApi(RestApiHubImpl.java:144)
at org.apache.dubbo.common.bytecode.Wrapper7.invokeMethod(Wrapper7.java)
at org.apache.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:47)
at org.apache.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:84)
at org.apache.dubbo.config.invoker.DelegateProviderMetaDataInvoker.invoke(DelegateProviderMetaDataInvoker.java:56)
at org.apache.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56)
at org.apache.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:52)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:89)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
at org.apache.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:44)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
at org.apache.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:77)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
at org.apache.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:118)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
at org.apache.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:152)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
at org.apache.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
at org.apache.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:41)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
at org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:74)
at org.apache.dubbo.common.bytecode.proxy6.callPcApi(proxy6.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:138)
at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:543)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:432)
at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$0(ResourceMethodInvoker.java:393)
at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:395)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:364)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:337)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:440)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:229)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:135)
at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358)
at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:138)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:215)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:245)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:61)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)
at org.apache.dubbo.rpc.protocol.rest.DubboHttpProtocolServer$RestHandler.handle(DubboHttpProtocolServer.java:89)
at org.apache.dubbo.remoting.http.servlet.DispatcherServlet.service(DispatcherServlet.java:61)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
[2020-11-17 17:49:15] [WARN ] - [DUBBO] Unexpected error occured when unexport org.apache.dubbo.registry.integration.RegistryProtocol$DestroyableExporter@508fed, dubbo version: 2.7.6, current host: 10.10.10.66
java.lang.IllegalStateException: org.springframework.context.annotation.AnnotationConfigApplicationContext@5298dead has been closed already
at org.springframework.context.support.AbstractApplicationContext.assertBeanFactoryActive(AbstractApplicationContext.java:1092)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1125)
at com.alibaba.cloud.dubbo.registry.SpringCloudRegistryFactory.init(SpringCloudRegistryFactory.java:82)
at com.alibaba.cloud.dubbo.registry.SpringCloudRegistryFactory.getRegistry(SpringCloudRegistryFactory.java:94)
at org.apache.dubbo.registry.RegistryFactoryWrapper.getRegistry(RegistryFactoryWrapper.java:34)
at org.apache.dubbo.registry.RegistryFactory$Adaptive.getRegistry(RegistryFactory$Adaptive.java)
at org.apache.dubbo.registry.integration.RegistryProtocol.getRegistry(RegistryProtocol.java:312)
at org.apache.dubbo.registry.integration.RegistryProtocol$ExporterChangeableWrapper.unexport(RegistryProtocol.java:727)
at org.apache.dubbo.registry.integration.RegistryProtocol$DestroyableExporter.unexport(RegistryProtocol.java:554)
at org.apache.dubbo.config.ServiceConfig.unexport(ServiceConfig.java:170)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.lambda$unexportServices$16(DubboBootstrap.java:926)
at java.util.ArrayList.forEach(ArrayList.java:1259)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.unexportServices(DubboBootstrap.java:924)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.destroy(DubboBootstrap.java:1046)
at org.apache.dubbo.config.bootstrap.DubboBootstrap$1.callback(DubboBootstrap.java:191)
at org.apache.dubbo.common.function.ThrowableAction.execute(ThrowableAction.java:46)
at org.apache.dubbo.common.lang.ShutdownHookCallbacks.lambda$callback$0(ShutdownHookCallbacks.java:70)
at java.lang.Iterable.forEach(Iterable.java:75)
at org.apache.dubbo.common.lang.ShutdownHookCallbacks.callback(ShutdownHookCallbacks.java:70)
at org.apache.dubbo.config.DubboShutdownHook.callback(DubboShutdownHook.java:85)
at org.apache.dubbo.config.DubboShutdownHook.run(DubboShutdownHook.java:73)
[2020-11-17 17:49:36] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:49:36] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:49:36] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:49:36] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:49:36] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:49:39] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:49:39] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:49:39] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:49:41] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:50:03] [WARN ] - [DUBBO] No spring extension (bean) named:monitor, try to find an extension (bean) of type org.apache.dubbo.config.MonitorConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:50:03] [WARN ] - [DUBBO] No spring extension (bean) named:module, try to find an extension (bean) of type org.apache.dubbo.config.ModuleConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:50:03] [WARN ] - [DUBBO] No spring extension (bean) named:metrics, try to find an extension (bean) of type org.apache.dubbo.config.MetricsConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:50:03] [WARN ] - [DUBBO] No spring extension (bean) named:ssl, try to find an extension (bean) of type org.apache.dubbo.config.SslConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:50:03] [WARN ] - [DUBBO] No spring extension (bean) named:application, try to find an extension (bean) of type org.apache.dubbo.config.ApplicationConfig, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:50:05] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:50:05] [WARN ] - [DUBBO] You specified the config center, but there's not even one single config item in it., dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:50:05] [WARN ] - [DUBBO] No spring extension (bean) named:applicationContext, try to find an extension (bean) of type org.springframework.context.ConfigurableApplicationContext, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:50:07] [WARN ] - [DUBBO] No spring extension (bean) named:logger, try to find an extension (bean) of type org.apache.dubbo.common.logger.Logger, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:50:08] [WARN ] - [DUBBO] Use random available port(20880) for protocol dubbo, dubbo version: 2.7.6, current host: 10.10.10.66
[2020-11-17 17:50:32] [ERROR] - [DUBBO] Got unchecked and undeclared exception which called by 0:0:0:0:0:0:0:1. service: com.spacetech.service.RestApiHub, method: callPcApi, exception: java.lang.RuntimeException: 获取数据发现异常:null, dubbo version: 2.7.6, current host: 10.10.10.66
java.lang.RuntimeException: 获取数据发现异常:null
at com.spacetech.util.MemCacheForOnecardUtil.get(MemCacheForOnecardUtil.java:160)
at com.spacetech.util.MemCacheForOnecardUtil.getLoginSession(MemCacheForOnecardUtil.java:47)
at com.spacetech.service.RestApiHubImpl.extractedCallApi(RestApiHubImpl.java:337)
at com.spacetech.service.RestApiHubImpl.callPcApi(RestApiHubImpl.java:144)
at org.apache.dubbo.common.bytecode.Wrapper7.invokeMethod(Wrapper7.java)
at org.apache.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:47)
at org.apache.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:84)
at org.apache.dubbo.config.invoker.DelegateProviderMetaDataInvoker.invoke(DelegateProviderMetaDataInvoker.java:56)
at org.apache.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56)
at org.apache.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:52)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:89)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
at org.apache.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:44)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
at org.apache.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:77)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
at org.apache.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:118)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
at org.apache.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:152)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
at org.apache.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
at org.apache.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:41)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
at org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:74)
at org.apache.dubbo.common.bytecode.proxy6.callPcApi(proxy6.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:138)
at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:543)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:432)
at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$0(ResourceMethodInvoker.java:393)
at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:395)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:364)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:337)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:440)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:229)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:135)
at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358)
at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:138)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:215)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:245)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:61)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)
at org.apache.dubbo.rpc.protocol.rest.DubboHttpProtocolServer$RestHandler.handle(DubboHttpProtocolServer.java:89)
at org.apache.dubbo.remoting.http.servlet.DispatcherServlet.service(DispatcherServlet.java:61)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
[2020-11-17 17:50:59] [WARN ] - [DUBBO] Unexpected error occured when unexport org.apache.dubbo.registry.integration.RegistryProtocol$DestroyableExporter@1cf8adc5, dubbo version: 2.7.6, current host: 10.10.10.66
java.lang.IllegalStateException: org.springframework.context.annotation.AnnotationConfigApplicationContext@25230246 has been closed already
at org.springframework.context.support.AbstractApplicationContext.assertBeanFactoryActive(AbstractApplicationContext.java:1092)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1125)
at com.alibaba.cloud.dubbo.registry.SpringCloudRegistryFactory.init(SpringCloudRegistryFactory.java:82)
at com.alibaba.cloud.dubbo.registry.SpringCloudRegistryFactory.getRegistry(SpringCloudRegistryFactory.java:94)
at org.apache.dubbo.registry.RegistryFactoryWrapper.getRegistry(RegistryFactoryWrapper.java:34)
at org.apache.dubbo.registry.RegistryFactory$Adaptive.getRegistry(RegistryFactory$Adaptive.java)
at org.apache.dubbo.registry.integration.RegistryProtocol.getRegistry(RegistryProtocol.java:312)
at org.apache.dubbo.registry.integration.RegistryProtocol$ExporterChangeableWrapper.unexport(RegistryProtocol.java:727)
at org.apache.dubbo.registry.integration.RegistryProtocol$DestroyableExporter.unexport(RegistryProtocol.java:554)
at org.apache.dubbo.config.ServiceConfig.unexport(ServiceConfig.java:170)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.lambda$unexportServices$16(DubboBootstrap.java:926)
at java.util.ArrayList.forEach(ArrayList.java:1259)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.unexportServices(DubboBootstrap.java:924)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.destroy(DubboBootstrap.java:1046)
at org.apache.dubbo.config.bootstrap.DubboBootstrap$1.callback(DubboBootstrap.java:191)
at org.apache.dubbo.common.function.ThrowableAction.execute(ThrowableAction.java:46)
at org.apache.dubbo.common.lang.ShutdownHookCallbacks.lambda$callback$0(ShutdownHookCallbacks.java:70)
at java.lang.Iterable.forEach(Iterable.java:75)
at org.apache.dubbo.common.lang.ShutdownHookCallbacks.callback(ShutdownHookCallbacks.java:70)
at org.apache.dubbo.config.DubboShutdownHook.callback(DubboShutdownHook.java:85)
at org.apache.dubbo.config.DubboShutdownHook.run(DubboShutdownHook.java:73)
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<module>spacetech-common-util</module> <module>spacetech-common-util</module>
<module>spacetech-service-interface</module> <module>spacetech-service-interface</module>
<module>spacetech-service-growth</module> <module>spacetech-service-growth</module>
<module>spacetech-service-api</module>
</modules> </modules>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
......
...@@ -180,6 +180,12 @@ ...@@ -180,6 +180,12 @@
<dependency> <dependency>
<groupId>com.alibaba.nacos</groupId> <groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId> <artifactId>nacos-client</artifactId>
<exclusions>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>spacetech-cloud</artifactId>
<groupId>com.spacetech</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spacetech-service-api</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.spacetech</groupId>
<artifactId>spacetech-service-interface</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.spacetech</groupId>
<artifactId>spacetech-common-util</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<!-- ueditor编辑器使用 end -->
<dependency>
<groupId>com.baidu</groupId>
<artifactId>ueditor</artifactId>
<version>1.1.2</version>
</dependency>
<!--hutool工具包-->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.3.8</version>
</dependency>
<!--使用resteasy netty发布rest服务 -->
<!--<dependency>-->
<!--<groupId>org.jboss.resteasy</groupId>-->
<!--<artifactId>resteasy-netty4</artifactId>-->
<!--<version>3.9.3.Final</version>-->
<!--<exclusions>-->
<!--<exclusion>-->
<!--<artifactId>httpclient</artifactId>-->
<!--<groupId>org.apache.httpcomponents</groupId>-->
<!--</exclusion>-->
<!--</exclusions>-->
<!--</dependency>-->
<!-- resteasy-jaxrs -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.13.0.Final</version>
</dependency>
<!-- tomcat-embed-core -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>8.5.30</version>
</dependency>
<!-- JAX对fastjson支持 -->
<dependency>
<groupId>com.colobu</groupId>
<artifactId>fastjson-jaxrs-json-provider</artifactId>
<version>0.3.2</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.baidu.ueditor.upload;
import com.baidu.ueditor.PathFormat;
import com.baidu.ueditor.define.AppInfo;
import com.baidu.ueditor.define.BaseState;
import com.baidu.ueditor.define.FileType;
import com.baidu.ueditor.define.State;
import java.util.Map;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class Base64Uploader {
private static Logger logger = LoggerFactory.getLogger(Base64Uploader.class);
public static State save(String content, Map<String, Object> conf) {
byte[] data = decode(content);
long maxSize = ((Long) conf.get("maxSize")).longValue();
if (!validSize(data, maxSize)) {
return new BaseState(false, AppInfo.MAX_SIZE);
}
String suffix = FileType.getSuffix("JPG");
String savePath = PathFormat.parse((String) conf.get("savePath"),
(String) conf.get("filename"));
savePath = savePath + suffix;
logger.info("put qiniu filename Base64Uploader ueditor savePath=" + savePath);
State storageState = StorageManager.saveBinaryFile(data, savePath);
if (storageState.isSuccess()) {
// storageState.putInfo("url", PathFormat.format(savePath));
storageState.putInfo("type", suffix);
storageState.putInfo("original", "");
}
return storageState;
}
private static byte[] decode(String content) {
return Base64.decodeBase64(content);
}
private static boolean validSize(byte[] data, long length) {
return data.length <= length;
}
}
\ No newline at end of file
package com.baidu.ueditor.upload;
import com.baidu.ueditor.PathFormat;
import com.baidu.ueditor.define.AppInfo;
import com.baidu.ueditor.define.BaseState;
import com.baidu.ueditor.define.FileType;
import com.baidu.ueditor.define.State;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.FileItemStream;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.util.Streams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest;
public class BinaryUploader {
private static Logger logger = LoggerFactory.getLogger(BinaryUploader.class);
public static final State save(HttpServletRequest request,
Map<String, Object> conf) {
InputStream fileStream = null;
if (!ServletFileUpload.isMultipartContent(request)) {
return new BaseState(false, AppInfo.NOT_MULTIPART_CONTENT);
}
try {
//修改了百度使用原生的commons上传方式
//创建ServletFileUpload实例
ServletFileUpload fileUpload = new ServletFileUpload();
//解析request请求 返回FileItemStream的iterator实例
FileItemIterator iter = fileUpload.getItemIterator(request);
InputStream is = null;//输出流
//迭代取出
while (iter.hasNext()){
FileItemStream item = iter.next();//获取文件流
is = item.openStream();//得到对应表单的输出流
if (!item.isFormField()){//如果是非文件域,设置进入map,这里要注意多值处理
return processFile(conf, is, item);
}
}
if (fileStream == null) {
return new BaseState(false, AppInfo.NOTFOUND_UPLOAD_DATA);
}
} catch (ClassCastException e) {
e.printStackTrace();
return new BaseState(false, AppInfo.PARSE_REQUEST_ERROR);
}catch (IOException e){
e.printStackTrace();
return new BaseState(false, AppInfo.IO_ERROR);
} catch (FileUploadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return new BaseState(false, AppInfo.IO_ERROR);
}
logger.info("put qiniu filename BinaryUploader ueditor savePathIO_ERROR=");
return new BaseState(false, AppInfo.IO_ERROR);
}
public static State processFile(Map<String, Object> conf, InputStream is,
FileItemStream item) throws IOException {
String originFileName;
if (is.available()>0){//如果输出流的内容大于0
originFileName = item.getName();//获取文件名
//Streams.copy(fileStream,new FileOutputStream("/Users/hbz/work/"+originFileName),true);//拷贝内容到上传路径
//params.put(name,new String[]{fname});//把文件名设置进request中
//fileStream= is;
String suffix = FileType.getSuffixByFilename(originFileName);
long maxSize = ((Long) conf.get("maxSize")).longValue();
if (!validType(suffix, (String[]) conf.get("allowFiles"))) {
return new BaseState(false, AppInfo.NOT_ALLOW_FILE_TYPE);
}
State storageState = StorageManager.saveFileByInputStream(is,
originFileName, maxSize);
is.close();
if (storageState.isSuccess()) {
storageState.putInfo("type", suffix);
storageState.putInfo("original", originFileName);
}
return storageState;
}
return new BaseState(false, AppInfo.REMOTE_FAIL);
}
public String upload(HttpServletRequest request) {
//创建ServletFileUpload实例
ServletFileUpload fileUpload = new ServletFileUpload();
try {
//解析request请求 返回FileItemStream的iterator实例
FileItemIterator iter = fileUpload.getItemIterator(request);
InputStream is = null;//输出流
//迭代取出
while (iter.hasNext()){
FileItemStream item = iter.next();//获取文件流
String name = item.getFieldName();//返回表单中标签的name值
is = item.openStream();//得到对应表单的输出流
if (item.isFormField()){//如果是非文件域,设置进入map,这里要注意多值处理
//setFormParam(name,is);//如果不是文件上传,处理
}else {
if (is.available()>0){//如果输出流的内容大于0
String fname = item.getName();//获取文件名
Streams.copy(is,new FileOutputStream("/Users/hbz/work/"+fname),true);//拷贝内容到上传路径
//params.put(name,new String[]{fname});//把文件名设置进request中
}
}
}
} catch (FileUploadException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return "upload complete !";
}
private static boolean validType(String type, String[] allowTypes) {
List<String> list = Arrays.asList(allowTypes);
return list.contains(type);
}
}
package com.baidu.ueditor.upload;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baidu.ueditor.define.AppInfo;
import com.baidu.ueditor.define.BaseState;
import com.baidu.ueditor.define.State;
import com.spacetech.common.utils.OSSClientUtil;
import com.spacetech.common.utils.StringUtil;
import com.spacetech.framework.SystemContext;
import com.spacetech.provider.ApiProvider;
public class StorageManager {
public static final int BUFFER_SIZE = 8192;
private static Logger logger = LoggerFactory.getLogger(StorageManager.class);
public StorageManager() {
}
public static State saveBinaryFile(byte[] data, String path) {
logger.info("put qiniu filename ueditor saveBinaryFile=" + path);
File file = getTmpFile(path);
State state = valid(file);
if (!state.isSuccess()) {
return state;
}
File tmpFile = getTmpFile(file.getName());
try {
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tmpFile));
bos.write(data);
bos.flush();
bos.close();
} catch (IOException ioe) {
logger.error("文件上传失败 path=" + path, ioe);
return new BaseState(false, AppInfo.IO_ERROR);
}
state = saveTmpFile(tmpFile, file.getName());
return state;
}
public static State saveFileByInputStream(InputStream is, String originFileName, long maxSize) {
State state = null;
logger.info("put qiniu filename ueditor saveFileByInputStream originFileName=" + originFileName);
File tmpFile = getTmpFile(originFileName);
byte[] dataBuf = new byte[2048];
BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE);
try {
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE);
int count = 0;
while ((count = bis.read(dataBuf)) != -1) {
bos.write(dataBuf, 0, count);
}
bos.flush();
bos.close();
if (tmpFile.length() > maxSize) {
tmpFile.delete();
return new BaseState(false, AppInfo.MAX_SIZE);
}
state = saveTmpFile(tmpFile, originFileName);
if (!state.isSuccess()) {
tmpFile.delete();
}
return state;
} catch (IOException e) {
logger.error("文件上传失败 originFileName=" + originFileName, e);
}
return new BaseState(false, AppInfo.IO_ERROR);
}
public static State saveFileByInputStream(InputStream is, String path) {
State state = null;
logger.info("put qiniu filename ueditor saveFileByInputStream1 path=" + path);
File tmpFile = getTmpFile("");
byte[] dataBuf = new byte[2048];
BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE);
try {
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE);
int count = 0;
while ((count = bis.read(dataBuf)) != -1) {
bos.write(dataBuf, 0, count);
}
bos.flush();
bos.close();
state = saveTmpFile(tmpFile, path);
if (!state.isSuccess()) {
tmpFile.delete();
}
return state;
} catch (IOException e) {
logger.error("文件上传失败 path=" + path, e);
}
return new BaseState(false, AppInfo.IO_ERROR);
}
private static File getTmpFile(String suffix) {
JSONObject fileParams = SystemContext.baseParams;
String localfileDic = fileParams.getString("localfileDic");
String localfileInternet = fileParams.getString("localfileInternet");
Boolean saveLocalfile = fileParams.getBoolean("saveLocalfile");
File tmpDir = null;
if (StringUtil.isNotEmpty(localfileDic) && saveLocalfile) {
logger.info("put qiniu filename ueditor localfileDic=" + localfileDic + " saveLocalfile=" + saveLocalfile + " localfileInternet=" + localfileInternet);
tmpDir = new File(localfileDic);
} else {
logger.info("put qiniu filename ueditor getTempDirectory=" + localfileDic + " saveLocalfile=" + saveLocalfile + " localfileInternet=" + localfileInternet);
tmpDir = FileUtils.getTempDirectory();
}
String tmpFileName = (Math.random() * 10000 + "").replace(".", "") + suffix;
return new File(tmpDir, tmpFileName);
}
public static State saveTmpFile(File tmpFile, String originFileName) {
State state = null;
String url = "";
String picUrl = "";
JSONObject fileParams = SystemContext.baseParams;
String localfileDic = fileParams.getString("localfileDic");
String localfileInternet = fileParams.getString("localfileInternet");
Boolean saveLocalfile = fileParams.getBoolean("saveLocalfile");
try {
logger.info("put qiniu filename ueditor localfileDic=" + localfileDic + " saveLocalfile=" + saveLocalfile + " localfileInternet=" + localfileInternet
+ " absolutePath()=" + tmpFile.getAbsolutePath());
// url = OSSClientUtil.putFile(tmpFile.getAbsolutePath(), false,
// false,
// saveLocalfile, localfileInternet);
Map fileAndThum = OSSClientUtil.putFileHaveThumbnail(tmpFile.getAbsolutePath(), false, ApiProvider.INTERNAL_OSS, saveLocalfile, localfileInternet, "");
logger.info("putFileHaveThumbnail localfileDic=" + localfileDic + " saveLocalfile=" + saveLocalfile + " localfileInternet=" + localfileInternet + " absolutePath()="
+ tmpFile.getAbsolutePath() + " fileAndThum=" + JSON.toJSONString(fileAndThum));
url = StringUtil.getNullStr(fileAndThum.get("url"));
picUrl = StringUtil.getNullStr(fileAndThum.get("picUrl"));
} catch (IOException e) {
logger.error("文件上传失败IO originFileName=" + originFileName, e);
return new BaseState(false, AppInfo.IO_ERROR);
} catch (Exception e) {
logger.error("文件上传失败 originFileName=" + originFileName, e);
return new BaseState(false, AppInfo.IO_ERROR);
}
state = new BaseState(true);
state.putInfo("size", tmpFile.length());
state.putInfo("title", originFileName);
state.putInfo("url", url.replace(OSSClientUtil.ALI_COMMON_URL, OSSClientUtil.ALI_IMAGE_URL));
state.putInfo("picUrl", picUrl);
return state;
}
public static State saveTmpFile(String absolutePath, String originFileName, int fileSize) {
State state = null;
String url = "";
String picUrl = "";
JSONObject fileParams = SystemContext.baseParams;
String localfileInternet = fileParams.getString("localfileInternet");
Boolean saveLocalfile = fileParams.getBoolean("saveLocalfile");
try {
// Map fileAndThum =
// OSSClientUtil.putFileAndThumbnail(tmpFile.getAbsolutePath(),false);
url = OSSClientUtil.putFile(absolutePath, false, ApiProvider.INTERNAL_OSS, saveLocalfile, localfileInternet);
// url = StringUtil.getNullStr(fileAndThum.get("url"));
// picUrl = StringUtil.getNullStr(fileAndThum.get("picUrl"));
} catch (Exception e) {
logger.error("文件上传失败 path=" + absolutePath+" originFileName="+originFileName, e);
return new BaseState(false, AppInfo.IO_ERROR);
}
state = new BaseState(true);
state.putInfo("size", fileSize);
state.putInfo("title", originFileName);
state.putInfo("url", url.replace(OSSClientUtil.ALI_COMMON_URL, OSSClientUtil.ALI_IMAGE_URL));
state.putInfo("picUrl", picUrl);
return state;
}
private static State valid(File file) {
File parentPath = file.getParentFile();
if ((!parentPath.exists()) && (!parentPath.mkdirs())) {
return new BaseState(false, AppInfo.FAILED_CREATE_FILE);
}
if (!parentPath.canWrite()) {
return new BaseState(false, AppInfo.PERMISSION_DENIED);
}
return new BaseState(true);
}
}
package com.spacetech;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@SpringBootApplication
@EnableDiscoveryClient
@EnableJpaRepositories(basePackages = "com.spacetech.dao")
public class ApiApplication {
public static void main(String[] args) {
SpringApplication.run(ApiApplication.class, args);
}
}
package com.spacetech.dao;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.spacetech.entity.OauthToken;
public interface OauthTokenDao
extends PagingAndSortingRepository<OauthToken, String>, JpaSpecificationExecutor<OauthToken> {
@Query(value = "SELECT * FROM oauth_token limit 1", nativeQuery = true)
OauthToken list();
}
package com.spacetech.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "oauth_token")
public class OauthToken implements Serializable {
private static final long serialVersionUID = -3972468206541958509L;
@Id
private String id;
private String appid;
private String appSecret;
private String accessToken;
private String refreshToken;
private Integer expires_in; //到期时间
private Long creatorid;
private Date create_time;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getAppid() {
return appid;
}
public void setAppid(String appid) {
this.appid = appid;
}
public String getAppSecret() {
return appSecret;
}
public void setAppSecret(String appSecret) {
this.appSecret = appSecret;
}
public String getAccessToken() {
return accessToken;
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
public String getRefreshToken() {
return refreshToken;
}
public void setRefreshToken(String refreshToken) {
this.refreshToken = refreshToken;
}
public Integer getExpires_in() {
return expires_in;
}
public void setExpires_in(Integer expires_in) {
this.expires_in = expires_in;
}
public Long getCreatorid() {
return creatorid;
}
public void setCreatorid(Long creatorid) {
this.creatorid = creatorid;
}
public Date getCreate_time() {
return create_time;
}
public void setCreate_time(Date create_time) {
this.create_time = create_time;
}
}
package com.spacetech.entity;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.servlet.http.HttpServletRequest;
import com.spacetech.service.ProviderService;
import com.spacetech.util.MemCacheUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
import com.spacetech.common.utils.DateUtil;
import com.spacetech.common.utils.StringUtil;
import com.spacetech.framework.SystemContext;
import com.spacetech.util.LogQueue;
import org.springframework.beans.factory.annotation.Autowired;
@Entity
@Table(name = "wx_xx_log")
public class WxXxLog {
private static Logger logger = LoggerFactory.getLogger(WxXxLog.class);
/**
*
*/
public final static String LOG_TYPE_PC_LOAD_PAGE = "PC_LOAD_PAGE";
public final static String LOG_TYPE_PC_LOAD_DATA = "PC_AJAX_QUERY_DATA";
public final static String LOG_TYPE_MOBILE_LOAD_PAGE = "MOBILE_LOAD_PAGE";
public final static String LOG_TYPE_MOBILE_LOAD_DATA = "MOBILE_LOAD_DATA";
public final static String LOG_TYPE_CALL_API = "API";
public final static String LOG_TYPE_CALL_DUBBOX_API = "DUBBOX_API";
public final static String LOG_TYPE_CALL_SECURITY_DUBBOX_API = "SECURITY_DUBBOX_API";
public final static String LOG_TYPE_CALL_SECURITY_API = "SECURITY_API";
public final static String LOG_TYPE_OTHER = "OTHER";
// 是否记录返回值
public final static Boolean LOG_RETURN_STR = false;
private Long id;
private Long orgcode;// 学校代码
private String campusid;
private String operatetime;
private String type;
private String appid;
private String appname;
private String apppath;
private String fromusername;
private Long userid;
private String username;
private String ip;
private String content;// 入参,如果是blob字段就不需要了
private String url;//
private String serialnumber;
private Long time;// 操作时长
private Boolean result;// 操作结果,是否有异常
private String refer;// ref
private String cookie;
private String agent;
private String agentType;
private Integer usertype;
private String resultStr; // 出参数长度
private Integer resultLength; // 出参数长度
private String serverip;
private Long currCampusid;// 当前操作的campusid
private String currCampusName;// 当前操作的campusname
public WxXxLog() {
}
/**
*
* @param
* @param request
* @param operaTime 操作时长
* @param result
* @param resultStr
* @param exception
*/
public WxXxLog(String type, JSONObject param, String fromusername, HttpServletRequest request, String content,
Long operaTime, Boolean result, String resultStr, String exception) {
this.setId(StringUtil.getBigIntId());
this.setServerip(SystemContext.SERVER_IP_ADDRESS);
// this.setSerialnumber(StringUtil.guid());
this.setType(type);
this.setCurrCampusid(param.getLong("campusid"));
this.setCurrCampusName(param.getString("logCampusName"));
this.setOperatetime(DateUtil.formatDateTime(new Date()));
String username = param.getString("logUserName");
String campusid = param.getString("logUserCampusid");
Integer usertype = param.getInteger("usertype");
Long orgcode = param.getLong("orgcode");
if (StringUtil.isNotEmpty(param.getLong("userid"))) {
Long userid =param.getLong("userid");
//如果userid 不为空 存数据 返回查出来的openid
fromusername = makeUserData(userid, fromusername, username, campusid, usertype, orgcode);
} else {
this.setUserid(0l);
this.setUsername("登录用户为空");
}
this.setFromusername(fromusername);
this.setContent(content);
if (request != null) {
this.setIp(request.getRemoteAddr());
this.setRefer(request.getHeader("Referer"));
String agent = request.getHeader("User-Agent");
this.setAgent(agent);
this.setAgentType(agent.contains("Mobile") ? "mobile" : "pc");
this.setCookie(request.getHeader("Cookie"));
this.setUrl(request.getRequestURL().toString());
if (StringUtil.isNullOrEmpty(content)) {
// this.setContent("REQUEST PARAMS:" +
// JSONObject.toJSONString(request.getParameterMap()));
}
} else {
this.setCookie("request为空");
}
this.setResult(result);
this.setTime(operaTime);
if (result) {
// 如果长度太长的话,除非确定需要,否则不予记录
if ((WxXxLog.LOG_TYPE_CALL_DUBBOX_API.equals(type) || WxXxLog.LOG_TYPE_CALL_SECURITY_DUBBOX_API.equals(type)
|| WxXxLog.LOG_TYPE_CALL_SECURITY_API.equals(type) || WxXxLog.LOG_TYPE_CALL_API.equals(type)
|| WxXxLog.LOG_TYPE_PC_LOAD_DATA.equals(type) || WxXxLog.LOG_TYPE_MOBILE_LOAD_DATA.equals(type))
&& !LOG_RETURN_STR && StringUtil.isNotEmpty(resultStr) && resultStr.length() > 10000) {
this.setResultStr("");
logger.info("log resultstr length= " + resultStr.length() + " is out of limit. type=" + type + " appid="
+ this.appid + " loggerid=" + this.getId() + " LogQueue.SIZE="
+ LogQueue.getFeedbackQueue().size());
} else {
this.setResultStr(resultStr);
}
this.setResultLength(resultStr.length());
} else {
this.setResultStr(exception);
}
}
private String makeUserData(Long userid, String fromusername, String username, String campusid, Integer usertype, Long orgcode) {
if (StringUtil.isNullOrEmpty(fromusername) || StringUtil.isNullOrEmpty(usertype)
|| StringUtil.isNullOrEmpty(username) || StringUtil.isNullOrEmpty(campusid)
|| StringUtil.isNullOrEmpty(orgcode)) {
//缓存里取值 没有就算了
JSONObject userJson = MemCacheUtil.getUserInfoFromMemcached(userid);
if (userJson != null) {
username = StringUtil.isNullOrEmpty(userJson.getString("name")) ? username
: userJson.getString("name");
usertype = StringUtil.isNullOrEmpty(usertype) ? userJson.getInteger("usertype") : usertype;
fromusername = StringUtil.isNullOrEmpty(fromusername) ? userJson.getString("slaveuser")
: fromusername;
campusid = StringUtil.isNullOrEmpty(campusid) ? userJson.getString("campusid") : campusid;
orgcode = StringUtil.isNullOrEmpty(orgcode) ? userJson.getLong("orgcode") : orgcode;
}
}
this.setCampusid(campusid);
this.setOrgcode(orgcode);
this.setUserid(userid);
this.setUsername(username);
this.setUsertype(usertype);
return fromusername;
}
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getUsertype() {
return usertype;
}
public void setUsertype(Integer usertype) {
this.usertype = usertype;
}
public String getAgentType() {
return agentType;
}
public void setAgentType(String agentType) {
this.agentType = agentType;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Long getOrgcode() {
return orgcode;
}
public void setOrgcode(Long orgcode) {
this.orgcode = orgcode;
}
public String getCampusid() {
return campusid;
}
public void setCampusid(String campusid) {
this.campusid = campusid;
}
public String getAppid() {
return appid;
}
public void setAppid(String appid) {
this.appid = appid;
}
public String getApppath() {
return apppath;
}
public void setApppath(String apppath) {
this.apppath = apppath;
}
public Long getUserid() {
return userid;
}
public void setUserid(Long userid) {
this.userid = userid;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getOperatetime() {
return operatetime;
}
public void setOperatetime(String operatetime) {
this.operatetime = operatetime;
}
public String getAppname() {
return appname;
}
public void setAppname(String appname) {
this.appname = appname;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getSerialnumber() {
return serialnumber;
}
public void setSerialnumber(String serialnumber) {
this.serialnumber = serialnumber;
}
public Long getTime() {
return time;
}
public void setTime(Long time) {
this.time = time;
}
public Boolean getResult() {
return result;
}
public void setResult(Boolean result) {
this.result = result;
}
public String getRefer() {
return refer;
}
public void setRefer(String refer) {
this.refer = refer;
}
public String getCookie() {
return cookie;
}
public void setCookie(String cookie) {
this.cookie = cookie;
}
public String getAgent() {
return agent;
}
public void setAgent(String agent) {
this.agent = agent;
}
public String getResultStr() {
return resultStr;
}
public void setResultStr(String resultStr) {
this.resultStr = resultStr;
}
public Integer getResultLength() {
return resultLength;
}
public void setResultLength(Integer resultLength) {
this.resultLength = resultLength;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getFromusername() {
return fromusername;
}
public void setFromusername(String fromusername) {
this.fromusername = fromusername;
}
public String getServerip() {
return serverip;
}
public void setServerip(String serverip) {
this.serverip = serverip;
}
public Long getCurrCampusid() {
return currCampusid;
}
public void setCurrCampusid(Long currCampusid) {
this.currCampusid = currCampusid;
}
public String getCurrCampusName() {
return currCampusName;
}
public void setCurrCampusName(String currCampusName) {
this.currCampusName = currCampusName;
}
}
package com.spacetech.framework;
import java.net.InterfaceAddress;
import java.net.NetworkInterface;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import com.alibaba.fastjson.JSONObject;
import com.spacetech.common.ConstantVar;
import com.spacetech.common.utils.FileUtil;
import com.spacetech.common.utils.StringUtil;
import com.spacetech.provider.ApiProvider;
import com.spacetech.util.MemCacheForOnecardUtil;
import com.spacetech.util.MemCacheUtil;
/**
*
* @author wm web工程上下文
*/
public final class SystemContext {
private String memcacheutilIpPort;
private String memcacheutilUsername;
private String memcacheutilPassword;
private String memcacheforonecardutilIpPort;
private String memcacheforonecardutilUsername;
private String memcacheforonecardutilPassword;
private Boolean internalOss = false;
private Boolean saveLocalfile = false;
private String localfileDic = "";
private String localfileInternet;
public final static JSONObject baseParams = new JSONObject();
public static String SERVER_IP_ADDRESS = "";
public void init() {
// 初始化参数配置
// ConfigUtil.loadProperties("jdbc.properties");
if (StringUtil.isNullOrEmpty(memcacheutilIpPort) || memcacheutilIpPort.indexOf(":") < 0) {
throw new RuntimeException("缓存未配置或者格式有误(127.0.0.1:11211)");
}
if (StringUtil.isNullOrEmpty(localfileDic)) {
throw new RuntimeException("Zookeeper未配置本地存储目录路径");
}
FileUtil.makeDir(localfileDic);
if (saveLocalfile && StringUtil.isNullOrEmpty(localfileInternet)) {
throw new RuntimeException("Zookeeper未配置本地访问路径");
}
baseParams.put("saveLocalfile", saveLocalfile);
baseParams.put("localfileDic", localfileDic);
baseParams.put("localfileInternet", localfileInternet);
baseParams.put("internalOss", internalOss);
if (StringUtil.isNotEmpty(memcacheutilUsername)
&& !ConstantVar.SPACE_PLACEHOLDER.equals(memcacheutilUsername)) {
MemCacheUtil.start(memcacheutilIpPort, memcacheutilUsername, memcacheutilPassword);
} else {
MemCacheUtil.start(memcacheutilIpPort);
}
if (StringUtil.isNotEmpty(memcacheforonecardutilUsername)
&& !ConstantVar.SPACE_PLACEHOLDER.equals(memcacheforonecardutilUsername)) {
MemCacheForOnecardUtil.start(memcacheforonecardutilIpPort, memcacheforonecardutilUsername,
memcacheforonecardutilPassword);
} else {
MemCacheForOnecardUtil.start(memcacheforonecardutilIpPort);
}
ApiProvider.INTERNAL_OSS = internalOss;
initIpAddrList();
}
public String getMemcacheutilIpPort() {
return memcacheutilIpPort;
}
public void setMemcacheutilIpPort(String memcacheutilIpPort) {
this.memcacheutilIpPort = memcacheutilIpPort;
}
public String getMemcacheutilUsername() {
return memcacheutilUsername;
}
public void setMemcacheutilUsername(String memcacheutilUsername) {
this.memcacheutilUsername = memcacheutilUsername;
}
public String getMemcacheutilPassword() {
return memcacheutilPassword;
}
public void setMemcacheutilPassword(String memcacheutilPassword) {
this.memcacheutilPassword = memcacheutilPassword;
}
public String getMemcacheforonecardutilIpPort() {
return memcacheforonecardutilIpPort;
}
public void setMemcacheforonecardutilIpPort(String memcacheforonecardutilIpPort) {
this.memcacheforonecardutilIpPort = memcacheforonecardutilIpPort;
}
public String getMemcacheforonecardutilUsername() {
return memcacheforonecardutilUsername;
}
public void setMemcacheforonecardutilUsername(String memcacheforonecardutilUsername) {
this.memcacheforonecardutilUsername = memcacheforonecardutilUsername;
}
public String getMemcacheforonecardutilPassword() {
return memcacheforonecardutilPassword;
}
public void setMemcacheforonecardutilPassword(String memcacheforonecardutilPassword) {
this.memcacheforonecardutilPassword = memcacheforonecardutilPassword;
}
public Boolean getSaveLocalfile() {
return saveLocalfile;
}
public void setSaveLocalfile(Boolean saveLocalfile) {
this.saveLocalfile = saveLocalfile;
}
public String getLocalfileDic() {
return localfileDic;
}
public void setLocalfileDic(String localfileDic) {
this.localfileDic = localfileDic;
}
public String getLocalfileInternet() {
return localfileInternet;
}
public void setLocalfileInternet(String localfileInternet) {
this.localfileInternet = localfileInternet;
}
public Boolean getInternalOss() {
return internalOss;
}
public void setInternalOss(Boolean internalOss) {
this.internalOss = internalOss;
}
public static void initIpAddrList() {
try {
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netint : Collections.list(nets))
if (null != netint.getHardwareAddress()) {
List<InterfaceAddress> list = netint.getInterfaceAddresses();
for (InterfaceAddress interfaceAddress : list) {
String localipstr = interfaceAddress.getAddress().toString();
String localip = localipstr.substring(1, localipstr.length());
if (localip.startsWith("10.")) {
SERVER_IP_ADDRESS = localip;
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com.spacetech.framework.hibernate;
import org.apache.commons.lang.StringUtils;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
public class ImprovedNamingStrategy implements PhysicalNamingStrategy {
@Override
public Identifier toPhysicalCatalogName(Identifier identifier,
JdbcEnvironment jdbcEnv) {
return convert(identifier);
}
@Override
public Identifier toPhysicalColumnName(Identifier identifier,
JdbcEnvironment jdbcEnv) {
return convert(identifier);
}
@Override
public Identifier toPhysicalSchemaName(Identifier identifier,
JdbcEnvironment jdbcEnv) {
return convert(identifier);
}
@Override
public Identifier toPhysicalSequenceName(Identifier identifier,
JdbcEnvironment jdbcEnv) {
return convert(identifier);
}
@Override
public Identifier toPhysicalTableName(Identifier identifier,
JdbcEnvironment jdbcEnv) {
return convert(identifier);
}
private Identifier convert(Identifier identifier) {
if (identifier == null || StringUtils.isBlank(identifier.getText())) {
return identifier;
}
String regex = "([a-z])([A-Z])";
String replacement = "$1_$2";
String newName = identifier.getText().replaceAll(regex, replacement)
.toLowerCase();
return Identifier.toIdentifier(newName);
}
}
\ No newline at end of file
package com.spacetech.provider;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.spacetech.service.ProviderService;
import com.spacetech.service.RestApiHub;
import com.spacetech.util.LogServer;
import com.spacetech.websocketchat.TextWebSocketFrameHandler;
import com.spacetech.websocketchat.WebsocketChatServer;
import com.spacetech.websocketchat.ClassbrandWebsocket.TextWebSocketClassBrandFrameHandler;
import com.spacetech.websocketchat.ClassbrandWebsocket.WebsocketClassBrandServer;
import com.spacetech.websocketcomment.CommentSocketFrameHandler;
import com.spacetech.websocketcomment.WebsocketCommentThread;
public class ApiProvider {
private static Logger logger = LoggerFactory.getLogger(ApiProvider.class);
public static boolean INTERNAL_OSS = false;
public static void main(String[] args) {
// String zookeeperAddress = "";
// if (args != null && args.length > 0) {
// zookeeperAddress = args[0];
// logger.error("Zookeeper argu zookeeperAddress=" + zookeeperAddress);
// } else {
// zookeeperAddress = ConfigUpdater.ZK_ADDRESS;
// logger.error("Zookeeper argu error,user local config zookeeperAddress=" + zookeeperAddress);
//
// }
// ZookeeperClientUtil.init(zookeeperAddress, ConfigUpdater.PATH);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"classpath*:META-INF/spring/spring-context.xml");
context.start();
ProviderService providerService = (ProviderService) context.getBean("providerService");
LogServer.setProviderService(providerService);
runThread(new LogServer(), 15);
RestApiHub restApiHub = (RestApiHub) context.getBean("restApiHub");
Thread commentThread = new Thread(new WebsocketCommentThread(8001));
commentThread.start();
try {
new WebsocketChatServer(8000).run();
new WebsocketClassBrandServer(9000).run();
} catch (Exception e) {
logger.error(e.toString());
}
System.out.println("服务已经启动...");
synchronized (ApiProvider.class) {
while (true) {
try {
ApiProvider.class.wait();
} catch (Throwable e) {
}
}
}
}
private static void runThread(Runnable run, int loop) {
ExecutorService pool = Executors.newFixedThreadPool(loop);
for (int i = 0; i < loop; i++) {
pool.execute(run);
}
}
}
package com.spacetech.service;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.spacetech.common.exception.ApiException;
import com.spacetech.common.logger.LoggerUtil;
import com.spacetech.common.utils.ApiUtil;
import com.spacetech.common.utils.HttpClientUtil;
import com.spacetech.common.utils.JsonUtil;
import com.spacetech.gateway.ApiEndpointApiHub;
public class ApiEndpointApiHubImpl implements ApiEndpointApiHub {
private static Logger logger = LoggerFactory
.getLogger(ApiEndpointApiHubImpl.class);
@Autowired
private OauthTokenService oauthTokenService;
public String callApi(String apiMethod, Boolean readonly, JSONObject param) {
try {
LoggerUtil.setMdcRequestId(param.getString("requestId"));
logger.info("before apiMethod=" + apiMethod + " 入参:" + JSON.toJSONString(param) + " readonly=" + readonly);
String result = "";
if (readonly) {
result= this.query(apiMethod, param);
} else {
result= this.update(apiMethod, param);
}
logger.info("after apiMethod=" + apiMethod + " result=" + result);
return result;
} catch (ApiException e) {
String errorMsg = e.getErrorMsg();
if (errorMsg != null && errorMsg.indexOf("发生异常:") > -1) {
errorMsg = errorMsg.substring(errorMsg.indexOf("【发生异常:") + 6,
errorMsg.indexOf("】"));
}
logger.error(apiMethod + "发生了API Exception的错误," + errorMsg+" 入参:" + JSON.toJSONString(param),e);
return JsonUtil
.formatJsonResult(apiMethod, "", "500", errorMsg, "");
} catch (Exception e) {
logger.error(apiMethod + "发生了非API Exception的错误,入参:" + JSON.toJSONString(param), e);
String resultCode = "500";
String fullStackTrace = org.apache.commons.lang.exception.ExceptionUtils
.getFullStackTrace(e);
String resultMsg = fullStackTrace;
return JsonUtil.formatJsonResult(apiMethod, "", resultCode,
resultMsg, "");
}
}
/**
* 需要走事务通道
*
* @param apiMethod
* @param
* @return
*/
@Transactional(readOnly = false)
public String update(String apiMethod, JSONObject param) {
return this.callApiMethod(apiMethod, param);
}
/**
* 不用走事务通道
*
* @param apiMethod
* @param
* @return
*/
public String query(String apiMethod, JSONObject param) {
return this.callApiMethod(apiMethod, param);
}
/**
* 调用API的通用方法<BR>
* <BR>
* 通过反射找到对应的api以及api方法,并对调用结果进行封装
*
* @param apiMethod
* 要调用的api方法,格式[API/METHOD],ServiceFactory会根据API+
* Service定位到具体的api类,并根据反射找到要执行的方法并进行调用
* @return
*/
@SuppressWarnings("rawtypes")
public String callApiMethod(String apiMethod, JSONObject params) {
Object methodResult = null;
String resultCode = ApiUtil.SUCCESS;
String resultMsg = "";
// 如果是模拟输入
if (ApiUtil.isMockCall(params)) {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("api", apiMethod);
Map<String, String> resultMap;
try {
resultMap = HttpClientUtil.submitPostRequest(
ApiUtil.MOCK_SERVER_URL, paramsMap, null);
String status = resultMap.get("status");
if ("200".equals(status)) {
return resultMap.get("responseMessage");
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return "error";
}
// return apiMockService.callMockApi(apiMethod, params);
} else {
String[] apiMethods = apiMethod.split("_");
String apiName = apiMethods[0];
String methodName = apiMethods[1];
// JSONObject result = new JSONObject();
try {
Class[] argsClass = ApiUtil.getJsonArgClass();
if ("oauthtoken".equals(apiName)) {
Method method = oauthTokenService.getClass().getMethod(
methodName, argsClass);
methodResult = method.invoke(oauthTokenService, params);
} else {
// 服务不存在
resultCode = ApiUtil.ERROR_CLASS_NOTEXISTS;
resultMsg = apiMethod + "对应的服务类不存在";
}
} catch (ApiException e) {
logger.warn("API ApiException apiMethod=" + apiMethod + " 错误原因:" + e.getMessage());
throw e;
} catch (java.lang.reflect.InvocationTargetException e) {
logger.error(
"API InvocationTargetException apiMethod=" + apiMethod + " 入参数=" + JSON.toJSONString(params),
e);
throw new ApiException(e.getTargetException().getMessage());
} catch (NoSuchMethodException e) {
logger.error("API NoSuchMethodException apiMethod=" + apiMethod, e);
throw new ApiException("【" + apiMethod + "】服务方法未注册!");
} catch (Exception e) {
logger.error("API Exception apiMethod=" + apiMethod + " 入参数=" + JSON.toJSONString(params), e);
throw new RuntimeException(e);
}
}
return ApiUtil.formatJsonResult(apiMethod, methodResult, resultCode,
resultMsg, "");
}
}
package com.spacetech.service;
public class ApiException extends RuntimeException {
public String getErrorMsg() {
return errorMsg;
}
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
public Throwable getErrorCause() {
return errorCause;
}
public void setErrorCause(Throwable errorCause) {
this.errorCause = errorCause;
}
private static final long serialVersionUID = -9171287832448832971L;
protected String errorMsg; // 错误信息(For debug)
protected Throwable errorCause = null; // 错误发生原因(原始Exception)
public ApiException(Throwable e, String errorMsg) {
super(errorMsg);
this.errorMsg = errorMsg;
this.errorCause = e;
}
public ApiException(String errorMsg) {
super(errorMsg);
this.errorMsg = errorMsg;
}
}
package com.spacetech.service;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URLDecoder;
import java.util.Arrays;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jdk.nashorn.internal.ir.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.dubbo.rpc.RpcContext;
import com.alibaba.dubbo.rpc.RpcException;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.spacetech.common.utils.AESUtil;
import com.spacetech.common.utils.JsonUtil;
import com.spacetech.common.utils.StringUtil;
import com.spacetech.entity.WxXxLog;
import com.spacetech.gateway.AppStoreApiHub;
import com.spacetech.gateway.AttendanceApiHub;
import com.spacetech.gateway.BaseDataApiHub;
import com.spacetech.gateway.CorpeduApiHub;
import com.spacetech.gateway.DtalkApiHub;
import com.spacetech.gateway.ElectiveApiHub;
import com.spacetech.gateway.EvaluationApiHub;
import com.spacetech.gateway.ExamScoreApiHub;
import com.spacetech.gateway.GrowthApiHub;
import com.spacetech.gateway.HomeworkApiHub;
import com.spacetech.gateway.LogApiHub;
import com.spacetech.gateway.MessageApiHub;
import com.spacetech.gateway.MicrolectureApiHub;
import com.spacetech.gateway.OaApiHub;
import com.spacetech.gateway.OperateApiHub;
import com.spacetech.gateway.ParentlicenseApiHub;
import com.spacetech.gateway.PayApiHub;
import com.spacetech.gateway.PortalApiHub;
import com.spacetech.gateway.QualityApiHub;
import com.spacetech.gateway.RecruitmentApiHub;
import com.spacetech.gateway.RegistrationApiHub;
import com.spacetech.gateway.SqxyApiHub;
import com.spacetech.gateway.SurveyApiHub;
import com.spacetech.gateway.TokenApiHub;
import com.spacetech.gateway.UserApiHub;
import com.spacetech.gateway.WechatApiHub;
import com.spacetech.util.LogQueue;
@Component
@Transactional(readOnly = true)
public class ApiHub {
private static Logger logger = LoggerFactory.getLogger(ApiHub.class);
private static String MOCK_SERVER_URL = "http://weixt.spacetech.com.cn:8090/integratest/mockcall";
private String SUCCESS = "200";
private String ERROR_INTERNAL_SERVER = "500";
private String ERROR_CLASS_NOTEXISTS = "001_001";
private String ERROR_METHOD_NOTEXISTS = "001_002";
/**
* 微门户服务
*/
@Reference
private PortalApiHub portalApiHub;
@Reference
private AppStoreApiHub appStoreApiHub;
@Reference
private ElectiveApiHub electiveApiHub;
@Reference
private MessageApiHub messageApiHub;
@Reference
private MicrolectureApiHub microlectureApiHub;
@Reference
private HomeworkApiHub homeworkApiHub;
@Reference
private ExamScoreApiHub examScoreApiHub;
@Reference
private OaApiHub oaApiHub;
@Reference
private BaseDataApiHub baseDataApiHub;
@Reference
private UserApiHub userApiHub;
@Reference
private EvaluationApiHub evaluationApiHub;
@Reference
private WechatApiHub wechatApiHub;
@Reference
private ParentlicenseApiHub parentlicenseApiHub;
@Reference
private LogApiHub logApiHub;
@Reference
private TokenApiHub tokenApiHub;
@Reference
private ProviderService providerService;
@Reference
private RegistrationApiHub registrationApiHub;
@Reference
private SurveyApiHub surveyApiHub;
@Reference
private PayApiHub payApiHub;
@Reference
private SqxyApiHub sqxyApiHub;
@Reference
private QualityApiHub qualityApiHub;
@Reference
private AttendanceApiHub attendanceApiHub;
@Reference
private GrowthApiHub growthApiHub;
@Reference
private OperateApiHub operateApiHub;
@Reference
private RecruitmentApiHub recruitmentApiHub;
@Reference
private DtalkApiHub dtalkApiHub;
@Reference
private CorpeduApiHub corpeduApiHub;
public static String getErrorInfoFromException(Exception e) {
try {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
return "\r\n" + sw.toString() + "\r\n";
} catch (Exception e2) {
return "bad getErrorInfoFromException";
}
}
public String processCallApi(String apiMethod, String paramsStr) {
// TODO Auto-generated method stub
logger.info("before callApi apiMethod=" + apiMethod + " 入参:" + paramsStr);
paramsStr = URLDecoder.decode(paramsStr);
if (StringUtil.isNullOrEmpty(paramsStr)) {
throw new ApiException("入参格式错误");
}
HttpServletRequest request = RpcContext.getContext().getRequest(HttpServletRequest.class);
if (paramsStr.indexOf("apiparams=") > -1) {
paramsStr = paramsStr.replaceFirst("apiparams=", "");
}
JSONObject apiparams = JSON.parseObject(paramsStr);
if (apiparams == null) {
throw new ApiException("入参格式错误");
}
boolean readonly = apiparams.getBooleanValue("readonly");
boolean async = apiparams.getBooleanValue("async");
JSONObject params = new JSONObject();
if (StringUtil.isNotEmpty(apiparams.getString("params"))) {
params = apiparams.getJSONObject("params");
}
String token = apiparams.getString("token");
HttpServletResponse response = RpcContext.getContext().getResponse(HttpServletResponse.class);
if (request != null) {
// logger.info("Client SessionI from RpcContext: " +
// request.getRequestedSessionId());
// logger.info("Client IP address from RpcContext: " +
// request.getRemoteAddr());
logger.info("Client Cookies from RpcContext: " + JSON.toJSONString(request.getCookies()));
params.put("ip", request.getRemoteAddr());
// addCookie(request, response, "userid");
// params.put("request", request);
response.setHeader("Access-Control-Allow-Origin", "*");
}
Long campusid = processAesData(params);
if (StringUtil.isNotEmpty(campusid)) {
params.put("campusid", campusid);
}
String result = callApi(apiMethod, readonly, token, async, params, request);
logger.info("After callApi apiMethod=" + apiMethod + " params=" + paramsStr + " result=" + result);
return result;
}
private Long processAesData(JSONObject params) {
String token = params.getString("token");
String campusid = params.getString("campusid");
Long result = 0L;
if (StringUtil.isNotEmpty(token) && token.equals("0d78fb004b7520b53c7bdc4c8ed957d1")) {
// 家长执照接口特殊处理
}
if (StringUtil.isNotEmpty(campusid) && campusid.length() > 11) {
// params.put("campusid", MD5Util.md5Decode(campusid));
result = StringUtil.getNullLong(AESUtil.decrypt(campusid));
}
return result;
}
private JSONObject checkToken(String apiMethod, String token, JSONObject params) {
if (apiMethod.indexOf("parentlicense") <= -1 && apiMethod.indexOf("token_oauth_tokens") <= -1
&& apiMethod.indexOf("user_user_login") <= -1) {
// 家长执照暂时不校验
Long campusid = params.getLong("campusid");
JSONObject tokenInfo = providerService.checkToken(apiMethod, campusid, token);
JSONObject ret = tokenInfo.getJSONObject("ret");
if (ret.getString("code").equals(ERROR_INTERNAL_SERVER)) {
throw new ApiException(ret.getString("msg"));
}
JSONObject data = tokenInfo.getJSONObject("data");
params.put("interface_appid", data.getString("providerid"));
params.put("interface_appname", data.getString("name"));
if (data.getString("return_code").equals("fail")) {
throw new ApiException(data.getString("errorMsg"));
}
}
return params;
}
public String callApi(String apiMethod, Boolean readonly, String token, Boolean async, JSONObject param,
HttpServletRequest request) {
String result = "";
String resultCode = "200";
long time0 = System.currentTimeMillis();
try {
// TODO Auto-generated method stub
checkToken(apiMethod, token, param);
String serviceApp = apiMethod.split("_")[0];
result = this.callDubboxService(serviceApp, apiMethod.split("_")[1] + "_" + apiMethod.split("_")[2],
readonly, async, param);
if (readonly) {
this.logCallApi(param, request, apiMethod, "QUERY:" + param.toString(),
System.currentTimeMillis() - time0, true, result, "");
} else {
boolean resultFlag = true;
if (result.indexOf("\"ret\":{\"code\":\"500\"") > 0) {
resultFlag = false;
}
this.logCallApi(param, request, apiMethod, "UPDATE:" + param.toString(),
System.currentTimeMillis() - time0, resultFlag, result, "");
}
} catch (ApiException e) {
e.printStackTrace();
String errorMsg = e.getErrorMsg();
if (errorMsg != null && errorMsg.indexOf("发生异常:") > -1) {
errorMsg = errorMsg.substring(errorMsg.indexOf("【发生异常:") + 6, errorMsg.indexOf("】"));
}
resultCode = "500";
param.put("return_exception", errorMsg);
logger.error(apiMethod + "发生了API Exception的错误," + errorMsg);
this.logCallApi(param, request, apiMethod, (readonly ? "QUERY" : "UPDATE:") + param.toString(),
System.currentTimeMillis() - time0, false, "",
org.apache.commons.lang.exception.ExceptionUtils.getFullStackTrace(e));
result = JsonUtil.formatJsonResult(apiMethod, "", resultCode, errorMsg, "");
} catch (RpcException e) {
String errorMsg = e.getMessage();
logger.error("发生了API RpcException的错误,apI=" + apiMethod + " ,msg=" + errorMsg);
resultCode = "500";
param.put("return_exception", errorMsg);
this.logDubboxCallApi(param, request, apiMethod, (readonly ? "QUERY" : "UPDATE:") + param.toString(),
System.currentTimeMillis() - time0, false, "",
org.apache.commons.lang.exception.ExceptionUtils.getFullStackTrace(e));
result = ApiHub.formatJsonResult(apiMethod, "", resultCode, "系统发生错误,远程服务(" + apiMethod + ")未注册,请联系管理员", "");
} catch (Exception e) {
e.printStackTrace();
logger.error(apiMethod + "发生了非API Exception的错误," + e.getMessage() + " 入参:" + JSON.toJSONString(param));
resultCode = "600";
String fullStackTrace = org.apache.commons.lang.exception.ExceptionUtils.getFullStackTrace(e);
String resultMsg = fullStackTrace;
param.put("return_exception", resultMsg);
this.logCallApi(param, request, apiMethod, (readonly ? "QUERY" : "UPDATE:") + param.toString(),
System.currentTimeMillis() - time0, false, "",
org.apache.commons.lang.exception.ExceptionUtils.getFullStackTrace(e));
result = formatJsonResult(apiMethod, "", resultCode, resultMsg, "");
}
saveLog(apiMethod, param, result, resultCode);
return result;
}
public String callPcApi(String apiMethod, Boolean readonly, Boolean async, JSONObject param,
HttpServletRequest request) {
String result = "";
String resultCode = "200";
long time0 = System.currentTimeMillis();
try {
// TODO Auto-generated method stub
String serviceApp = apiMethod.split("_")[0];
result = this.callDubboxService(serviceApp, apiMethod.split("_")[1] + "_" + apiMethod.split("_")[2],
readonly, async, param);
if (readonly) {
this.logCallApi(param, request, apiMethod, "QUERY:" + param.toString(),
System.currentTimeMillis() - time0, true, result, "");
} else {
boolean resultFlag = true;
if (StringUtil.isNotEmpty(result) && result.indexOf("\"ret\":{\"code\":\"500\"") > 0) {
resultFlag = false;
}
this.logCallApi(param, request, apiMethod, "UPDATE:" + param.toString(),
System.currentTimeMillis() - time0, resultFlag, result, "");
}
} catch (ApiException e) {
String errorMsg = e.getErrorMsg();
if (errorMsg != null && errorMsg.indexOf("发生异常:") > -1) {
errorMsg = errorMsg.substring(errorMsg.indexOf("【发生异常:") + 6, errorMsg.indexOf("】"));
}
resultCode = "500";
param.put("return_exception", errorMsg);
logger.error(apiMethod + "发生了API Exception的错误," + errorMsg, e);
this.logCallApi(param, request, apiMethod, (readonly ? "QUERY" : "UPDATE:") + param.toString(),
System.currentTimeMillis() - time0, false, "",
org.apache.commons.lang.exception.ExceptionUtils.getFullStackTrace(e));
result = JsonUtil.formatJsonResult(apiMethod, "", resultCode, errorMsg, "");
} catch (RpcException e) {
String errorMsg = e.getMessage();
logger.error("发生了API RpcException的错误,apI=" + apiMethod + " ,msg=" + errorMsg);
resultCode = "500";
param.put("return_exception", errorMsg);
this.logDubboxCallApi(param, request, apiMethod, (readonly ? "QUERY" : "UPDATE:") + param.toString(),
System.currentTimeMillis() - time0, false, "",
org.apache.commons.lang.exception.ExceptionUtils.getFullStackTrace(e));
result = ApiHub.formatJsonResult(apiMethod, "", resultCode, "系统发生错误,远程服务(" + apiMethod + ")未注册,请联系管理员", "");
} catch (Exception e) {
e.printStackTrace();
logger.error(apiMethod + "发生了非API Exception的错误," + e.getMessage() + " 入参:" + JSON.toJSONString(param));
resultCode = "600";
String fullStackTrace = org.apache.commons.lang.exception.ExceptionUtils.getFullStackTrace(e);
String resultMsg = fullStackTrace;
param.put("return_exception", resultMsg);
this.logCallApi(param, request, apiMethod, (readonly ? "QUERY" : "UPDATE:") + param.toString(),
System.currentTimeMillis() - time0, false, "",
org.apache.commons.lang.exception.ExceptionUtils.getFullStackTrace(e));
result = formatJsonResult(apiMethod, "", resultCode, resultMsg, "");
}
// saveLog(apiMethod, param, result, resultCode);
return result;
}
public void saveLog(String apiMethod, JSONObject param, String result, String resultCode) {
try {
if (!apiMethod.equals("base_stu_checkStuServeInfo")) {
param.put("return_data", result);
param.put("return_code", resultCode);
param.put("api", apiMethod);
providerService.saveInterfaceLog(param);
}
} catch (Exception e) {
logger.error("日志记录错误" + apiMethod + "错误原因:" + e.getMessage());
}
}
/**
* 获取认证主体
*
* @param apiMethod
* @param userid
* @return
*/
private String authPrincipal(String apiMethod, String userid) {
// user_account_authentication 教师用户用在登陆PC端
// user_wechat_authentication 微信端身份认证接口
// token_oauth_tokens 登陆/刷新以获取token
String result = "";
return result;
}
/**
* 调用dubbox 服务
*
* @param serviceApp
* @param apiMethod
* @param readonly
* @param param
* @return
*/
public String callDubboxService(String serviceApp, String apiMethod, Boolean readonly, Boolean async,
JSONObject param) {
String resultCode = SUCCESS;
String resultMsg = "";
String methodResult = "";
if ("appstore".equals(serviceApp)) {
return appStoreApiHub.callApi(apiMethod, readonly, param);
} else if ("elective".equals(serviceApp)) {
if (async) {
return electiveApiHub.callApiAsync(apiMethod, readonly, param);
} else {
return electiveApiHub.callApi(apiMethod, readonly, param);
}
} else if ("portal".equals(serviceApp)) {
if (async) {
return portalApiHub.callApiAsync(apiMethod, readonly, param);
} else {
return portalApiHub.callApi(apiMethod, readonly, param);
}
} else if ("message".equals(serviceApp)) {
return messageApiHub.callApi(apiMethod, readonly, param);
} else if ("micro".equals(serviceApp)) {
return microlectureApiHub.callApi(apiMethod, readonly, param);
} else if ("homework".equals(serviceApp)) {
return homeworkApiHub.callApi(apiMethod, readonly, param);
} else if ("examscore".equals(serviceApp)) {
// if (async) {
// return examScoreApiHub.callApiAsync(apiMethod, readonly, param);
// } else {
return examScoreApiHub.callApi(apiMethod, readonly, param);
// }
} else if ("oa".equals(serviceApp)) {
if (async) {
return oaApiHub.callApiAsync(apiMethod, readonly, param);
} else {
return oaApiHub.callApi(apiMethod, readonly, param);
}
} else if ("base".equals(serviceApp)) {
if (async) {
return baseDataApiHub.callApiAsync(apiMethod, readonly, param);
} else {
return baseDataApiHub.callApi(apiMethod, readonly, param);
}
} else if ("user".equals(serviceApp)) {
return userApiHub.callApi(apiMethod, readonly, param);
} else if ("evaluation".equals(serviceApp)) {
return evaluationApiHub.callApi(apiMethod, readonly, param);
} else if ("wechat".equals(serviceApp)) {
if (async) {
return wechatApiHub.callApiAsync(apiMethod, readonly, param);
} else {
return wechatApiHub.callApi(apiMethod, readonly, param);
}
} else if ("parentlicense".equals(serviceApp)) {
return parentlicenseApiHub.callApi(apiMethod, readonly, param);
} else if ("token".equals(serviceApp)) {
return tokenApiHub.callApi(apiMethod, readonly, param);
} else if ("regist".equals(serviceApp)) {
return registrationApiHub.callApi(apiMethod, readonly, param);
} else if ("survey".equals(serviceApp)) {
if (async) {
return surveyApiHub.callApiAsync(apiMethod, readonly, param);
} else {
return surveyApiHub.callApi(apiMethod, readonly, param);
}
} else if ("pay".equals(serviceApp)) {
return payApiHub.callApi(apiMethod, readonly, param);
} else if ("sqxy".equals(serviceApp)) {
if (async) {
return sqxyApiHub.callApiAsync(apiMethod, readonly, param);
} else {
return sqxyApiHub.callApi(apiMethod, readonly, param);
}
} else if ("quality".equals(serviceApp)) {
return qualityApiHub.callApi(apiMethod, readonly, param);
} else if ("attendance".equals(serviceApp)) {
return attendanceApiHub.callApi(apiMethod, readonly, param);
} else if ("growth".equals(serviceApp)) {
return growthApiHub.callApi(apiMethod, readonly, param);
} else if ("operate".equals(serviceApp)) {
return operateApiHub.callApi(apiMethod, readonly, param);
} else if ("recruitment".equals(serviceApp)) {
if (async) {
return recruitmentApiHub.callApiAsync(apiMethod, readonly, param);
} else {
return recruitmentApiHub.callApi(apiMethod, readonly, param);
}
} else if ("log".equals(serviceApp)) {
if (async) {
return logApiHub.callApiAsync(apiMethod, readonly, param);
} else {
return logApiHub.callApi(apiMethod, readonly, param);
}
} else if ("dtalk".equals(serviceApp)) {
return dtalkApiHub.callApi(apiMethod, readonly, param);
} else if ("corpedu".equals(serviceApp)) {
return corpeduApiHub.callApi(apiMethod, readonly, param);
} else {
// 服务不存在
resultCode = ERROR_CLASS_NOTEXISTS;
resultMsg = serviceApp + "对应的服务未注册(" + apiMethod + ")";
logger.error("服务注册异常 resultCode=" + resultCode + " resultMsg=" + resultMsg);
}
return formatJsonResult(apiMethod, methodResult, resultCode, resultMsg, "");
}
private boolean isMockCall(JSONObject params) {
if (params == null) {
return false;
}
if (params.containsKey("mockcall")) {
return params.getBoolean("mockcall");
} else {
return false;
}
}
private Class[] getJsonArgClass() throws ClassNotFoundException {
Class jsonClass = Class.forName("com.alibaba.fastjson.JSONObject");
Class[] argsClass = new Class[1];
argsClass[0] = jsonClass;
return argsClass;
}
private Class[] getTowArgClass() throws ClassNotFoundException {
Class jsonClass = Class.forName("com.alibaba.fastjson.JSONObject");
Class[] argsClass = new Class[2];
argsClass[0] = jsonClass;
Class inputStreamClass = Class.forName("java.io.InputStream");
argsClass[1] = inputStreamClass;
return argsClass;
}
public static String formatJsonResult(String api, Object obj, String returnCode, String returnMsg, String version) {
JSONObject result = new JSONObject();
result.put("api", api);
result.put("data", obj);
result.put("v", version);
result.put("ret", formatReturnMsg(returnCode, returnMsg));
return JSON.toJSONString(result, SerializerFeature.WriteMapNullValue).replace(" ", " ");
}
public static JSONObject formatReturnMsg(String code, String msg) {
JSONObject result = new JSONObject();
result.put("code", code);
result.put("msg", msg);
return result;
}
protected String logCallApi(JSONObject param, HttpServletRequest request, String apicode, String content,
Long operateTime, Boolean result, String resultStr, String exception) {
try {
WxXxLog log = new WxXxLog(WxXxLog.LOG_TYPE_CALL_API, param, "", request, content, operateTime, result,
resultStr, exception);
log.setAppid(apicode);
LogQueue.put(log);
return log.getSerialnumber();
} catch (Exception e) {
logger.error("记录日志错误", e);
return "";
}
}
protected String logDubboxCallApi(JSONObject param, HttpServletRequest request, String apicode, String content,
Long operateTime, Boolean result, String resultStr, String exception) {
WxXxLog log = new WxXxLog(WxXxLog.LOG_TYPE_CALL_DUBBOX_API, param, "", request, content, operateTime, result,
resultStr, exception);
log.setAppid(apicode);
LogQueue.put(log);
return log.getSerialnumber();
}
public static final String[] SAFE_NOTCHECK_CAMPUSID = new String[] { "wechat_org_findByAppid",
"wechat_oauth2_getSnsapiBaseOpenid", "wechat_oauth2_getJsApiSignature",
"wechat_oauth2_getMiniProgramOpenid", "wechat_oauth2_getMiniProgramSessionKey", "user_user_login" };
public boolean isNotCheckCampusidSafe(String api, String campusType) {
return (StringUtil.isNotEmpty(api) && Arrays.asList(SAFE_NOTCHECK_CAMPUSID).contains(api))
|| isNoAuthorizationCampusid(campusType);
}
public static final String[] CAMPUS_TYLE_LIST = new String[] { "CITY_EDU", "PROVINCE_EDU", "COUNTY_EDU",
"CAMPUS_TYPE_SYSTEM", "PROVIDER" };
/**
* 教育局学校不用校验校区
*
* @param campusType
* @return
*/
private boolean isNoAuthorizationCampusid(String campusType) {
return StringUtil.isNotEmpty(campusType) && Arrays.<String>asList(CAMPUS_TYLE_LIST).contains(campusType);
}
}
package com.spacetech.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject;
import com.spacetech.dao.OauthTokenDao;
import com.spacetech.entity.OauthToken;
@Component
@Transactional(readOnly = true)
public class OauthTokenService {
@Autowired
private OauthTokenDao oauthTokenDao;
/***
* 接口:oauthToken_list
*
* 测试接口
*
* @param params
* @return
*/
@Transactional(readOnly = false)
public OauthToken list(JSONObject params) {
String id = params.getString("id");
return oauthTokenDao.list();
}
}
package com.spacetech.service;
import com.spacetech.common.utils.JsonUtil;
import org.apache.dubbo.config.annotation.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.spacetech.gateway.BaseDataApiHub;
import com.spacetech.gateway.LogApiHub;
import com.spacetech.gateway.TokenApiHub;
import com.spacetech.gateway.UserApiHub;
/**
* 业务dubbox服务,需要依赖其他dubbo服务
*
* @author hbz
*
*/
@Component
@Transactional(readOnly = true)
public class ProviderService {
private static Logger logger = LoggerFactory.getLogger(ProviderService.class);
@Reference
private UserApiHub userApiHub;
@Reference
private BaseDataApiHub baseDataApiHub;
@Reference
private LogApiHub logApiHub;
@Reference
private TokenApiHub tokenApiHub;
/**
* 异步保存日志 后续直接将需要保存的数据丢到metaq
*
* @param
* @return
*/
public String saveInterfaceLog(JSONObject params) {
// JSONObject pidparams = new JSONObject();
// pidparams.put("openid", openid);
String json = "";
try {
json = logApiHub.callApiAsync("log_saveInterfaceLog", false, params);
} catch (Exception e) {
logger.error("日志记录发生错误,错误原因:" + e.getMessage());
}
return json;
}
/**
* 校验token
*
* @param campusid
* @param token
* @return
*/
public JSONObject checkToken(String apiMethod, Long campusid, String token) {
JSONObject pidparams = new JSONObject();
pidparams.put("campusid", campusid);
pidparams.put("token", token);
String json = tokenApiHub.callApi("oauth_checkToken", true, pidparams);
return JSON.parseObject(json);
}
public void saveLog(JSONObject params) {
try {
logApiHub.callApiAsync("log_saveLog", false, params);
} catch (Exception e) {
}
}
public String getParentName(Long stuid, int relationCode) {
JSONObject params = new JSONObject();
params.put("stuid", stuid);
params.put("relationCode", relationCode);
String json = baseDataApiHub.callApi("stu_getParentName", true,params);
return JsonUtil.formatNullStr(json);
}
}
package com.spacetech.service;
public interface RestApiHub {
/**
* 调用API
*
* @return
*/
public String callApi(String api, String param);
public String callApi(String param);
public String callPcApi(String api, String param);
public String receiveNodataApiPost(String api);
public String receiveNodataApiGet(String api);
public String receiveWechatApiPost(String api);
public String receiveWechatApiGet(String api);
public String receiveWechatPayApiPost();
public String receivePcWechatPayApiPost();
public String receiveWechatPayApiPost(String api);
public String initUeditorGet();
public String initUeditorPost();
public String init135Ueditor(String filter);
public String thirdReq(String api);
public String thirdGetReq(String api);
public String callUploadFileApi(String api);
public String callEndpointApi(String api, String param);
public String callClassBrandApi(String param);
public String callUploadApi(String api);
public String callClassBrandStateApi(String param);
public String saveExamByYdb(String param);
public String saveScoreByYdb(String param);
public String xiumiGetAccessToken();
public String xiumiGetPicUrl();
public String xiumiSaveArticles(String param);
}
package com.spacetech.service;
import com.alibaba.dubbo.rpc.RpcContext;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baidu.ueditor.ActionEnter;
import com.spacetech.common.exception.ApiException;
import com.spacetech.common.utils.*;
import com.spacetech.framework.SystemContext;
import com.spacetech.gateway.BaseDataApiHub;
import com.spacetech.gateway.ExamScoreApiHub;
import com.spacetech.gateway.PortalApiHub;
import com.spacetech.provider.ApiProvider;
import com.spacetech.util.MemCacheForOnecardUtil;
import com.spacetech.util.WatermarkUtil;
import com.spacetech.websocketchat.ClassbrandWebsocket.TextWebSocketClassBrandFrameHandler;
import io.netty.channel.Channel;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.FileItemStream;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.util.Streams;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.config.annotation.Service;
import org.apache.log4j.MDC;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.ServletInputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;
import java.io.*;
import java.net.URLDecoder;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;
/**
* 绩效考核数据记录
*
* @author hbz
*/
@Component
@Path("api")
@Service(interfaceClass = RestApiHub.class,protocol = {"rest"})
public class RestApiHubImpl implements RestApiHub {
private static Logger logger = LoggerFactory.getLogger(RestApiHubImpl.class);
private static final String USER_USER_LOGIN = "user_user_login";
private static final String WECHAT_OAUTH2_GETSNSAPIBASEOPENID = "wechat_oauth2_getSnsapiBaseOpenid";
private static final String REGIST_ZJLLLREGIST_PUSHREGISTMSG = "regist_zjlllregist_pushRegistMsg";
@Autowired
private ApiHub apiHub;
@Reference(interfaceClass = BaseDataApiHub.class, check = false)
private BaseDataApiHub baseDataApiHub;
@Reference(interfaceClass = ExamScoreApiHub.class, check = false)
private ExamScoreApiHub examScoreApiHub;
@Reference(interfaceClass = PortalApiHub.class, check = false)
private PortalApiHub portalApiHub;
@Autowired
private XiuMiService xiuMiService;
@Override
@POST
@Path("{apiMethod}")
@Produces({ "application/json; charset=UTF-8", "text/xml; charset=UTF-8" })
public String callApi(@PathParam("apiMethod") String apiMethod, String paramsStr) {
return apiHub.processCallApi(apiMethod, paramsStr);
}
@GET
@Path("{apiMethod}")
@Produces({ "application/json; charset=UTF-8", "text/xml; charset=UTF-8" })
public String callApiGet(@PathParam("apiMethod") String apiMethod, String paramsStr) {
return apiHub.processCallApi(apiMethod, paramsStr);
}
@POST
@Path("pc/req/{apiMethod}")
@Produces({ "application/x-www-form-urlencoded; charset=UTF-8", "text/xml; charset=UTF-8" })
public String thirdReq(@PathParam("apiMethod") String apiMethod) {
JSONObject json = makeParams();
return extractedCallApi(apiMethod, json.toString());
}
@GET
@Path("pc/getreq/{apiMethod}")
@Produces({ "application/x-www-form-urlencoded; charset=UTF-8", "text/xml; charset=UTF-8" })
public String thirdGetReq(@PathParam("apiMethod") String apiMethod) {
JSONObject json = makeParams();
return extractedCallApi(apiMethod, json.toString());
}
private JSONObject makeParams() {
HttpServletRequest request = RpcContext.getContext().getRequest(HttpServletRequest.class);
Map<String, String[]> requestMap = request.getParameterMap();
Iterator<Entry<String, String[]>> entries = requestMap.entrySet().iterator();
Entry<String, String[]> entry = null;
String name = "";
String value = "";
JSONObject json = new JSONObject();
JSONObject paramJson = new JSONObject();
while (entries.hasNext()) {
entry = entries.next();
name = (String) entry.getKey();
Object valueObj = entry.getValue();
if (null == valueObj) {
value = "";
} else {
String[] values = (String[]) valueObj;
for (int i = 0; i < values.length; i++) {
value = values[i] + ",";
}
value = value.substring(0, value.length() - 1);
}
paramJson.put(name, value);
}
json.put("params", paramJson);
return json;
}
@POST
@Path("pc/{apiMethod}")
@Produces({ "application/json; charset=UTF-8", "text/xml; charset=UTF-8" })
public String callPcApi(@PathParam("apiMethod") String apiMethod, String paramsStr) {
return extractedCallApi(apiMethod, paramsStr);
}
@POST
@Path("endpoint/{apiMethod}")
@Produces({ "application/json; charset=UTF-8", "text/xml; charset=UTF-8" })
public String callEndpointApi(@PathParam("apiMethod") String apiMethod, String paramsStr) {
return extractedCallApi(apiMethod, paramsStr);
}
@GET
@Path("pc/{apiMethod}")
@Produces({ "application/json; charset=UTF-8", "text/xml; charset=UTF-8" })
public String callGetPcApi(@PathParam("apiMethod") String apiMethod, String paramsStr) {
return extractedCallApi(apiMethod, paramsStr);
}
@POST
@Path("pc/uploadfile/{apiMethod}")
@Produces({ "multipart/form-data; charset=UTF-8", "text/xml; charset=UTF-8" })
public String callUploadFileApi(@PathParam("apiMethod") String apiMethod) {
String hashkey = StringUtil.guid();
MDC.put("requestId", hashkey);
logger.info("before 发生了API callApi apiMethod==uploadfile");
HttpServletRequest request = RpcContext.getContext().getRequest(HttpServletRequest.class);
String sessionid = getCookieValue(request, TYPE_SESSION_ID);
JSONObject sessionUser = MemCacheForOnecardUtil.getLoginSession(sessionid, "");
if (sessionUser == null) {
logger.error("apiMethod=" + apiMethod + "sessionUserid=" + sessionid + "会话过期" + "openid=");
}
String result = transformationRequestStr(request);
logger.info("after 发生了API callApi apiMethod==" + apiMethod + " result:" + result);
return result;
}
@POST
@Path("pc/upload/{apiMethod}")
@Produces({ "multipart/form-data; charset=UTF-8", "text/xml; charset=UTF-8" })
public String callUploadApi(@PathParam("apiMethod") String apiMethod) {
String hashkey = StringUtil.guid();
MDC.put("requestId", hashkey);
JSONObject json = makeParams();
logger.info("before 发生了API callApi apiMethod==uploadfile" + apiMethod + " json=" + json);
HttpServletRequest request = RpcContext.getContext().getRequest(HttpServletRequest.class);
String sessionid = getCookieValue(request, TYPE_SESSION_ID);
JSONObject sessionUser = MemCacheForOnecardUtil.getLoginSession(sessionid, "");
if (sessionUser == null) {
logger.error("apiMethod=" + apiMethod + "sessionUserid=" + sessionid + "会话过期" + "openid=");
}
Map<String, String> result = new HashMap<String, String>();
String resultCode = "500";
String resultMsg = "";
try {
result = transformationRequest(request);
} catch (ApiException e) {
logger.error("API ApiException apiMethod=" + apiMethod, e);
resultMsg = e.getMessage();
} catch (Exception e) {
logger.error("API Exception apiMethod=" + apiMethod, e);
resultMsg = e.getMessage();
}
logger.info("after 发生了API callApi apiMethod==" + apiMethod + " result:" + result);
return ApiUtil.formatJsonResult(apiMethod, result, resultCode, resultMsg, "");
}
private static String remoteUrl = "http://weixt.spacetech.com.cn:9090/integratest/";
public static String loginTomcat(String url, String loginName, String password) {
Map<String, String> params = new HashMap<String, String>();
params.put("username", loginName);
params.put("password", password);
try {
Map<String, String> sessoinMap = HttpClientUtil.submitPostRequest(url, params, null);
String session = sessoinMap.get("Cookie");
if (session != null && !session.equals("")) {
return session;
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private static String MOCK_SERVER_URL = "http://weixt.spacetech.com.cn:9090/integratest/mockcall";
public static String mockCall(String api, String paramsStr) {
HashMap<String, String> paramsMap = new HashMap<String, String>();
HashMap<String, String> cookieMap = new HashMap<String, String>();
paramsMap.put("api", api);
paramsMap.put("apiparams", paramsStr);
logger.info("in MOCK CALL API=" + api + " paramsStr=" + paramsStr);
String jsessionId = loginTomcat(remoteUrl + "login", "mhm@spacetech.com.cn", "zaq1234");
if (jsessionId != null) {
cookieMap.put("Cookie", jsessionId);
}
Map<String, String> resultMap;
try {
resultMap = HttpClientUtil.submitPostRequest(MOCK_SERVER_URL, paramsMap, cookieMap);
String status = resultMap.get("status");
if ("200".equals(status)) {
return ApiHub.formatJsonResult(api, resultMap.get("responseMessage"), "200", "", "");
} else {
return ApiHub.formatJsonResult(api, "", "500", "远程服务器返回错误,错误代码:" + status, "");
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return ApiHub.formatJsonResult(api, "", "500",
"调用MOCK CALL发生异常" + org.apache.commons.lang.exception.ExceptionUtils.getFullStackTrace(e), "");
}
}
private boolean isMockCall(JSONObject params) {
if (params == null) {
return false;
}
if (params.containsKey("mockcall")) {
return params.getBoolean("mockcall");
} else {
return false;
}
}
public String extractedCallApi(String apiMethod, String paramsStr) {
// TODO Auto-generated method stub
String hashkey = StringUtil.guid();
MDC.put("requestId", hashkey);
if (paramsStr.indexOf("isBatchUpload") == -1) {
paramsStr = URLDecoder.decode(paramsStr);
}
logger.info("before 发生了API callApi apiMethod==" + apiMethod + " 入参:" + paramsStr);
if (StringUtil.isNullOrEmpty(paramsStr)) {
logger.error(apiMethod + "发生了API Exception的参数错误," + paramsStr);
return JsonUtil.formatJsonResult(apiMethod, "", "500", "非法参数请求", "");
}
if (paramsStr.indexOf("apiparams=") > -1) {
paramsStr = paramsStr.replaceFirst("apiparams=", "");
}
JSONObject apiparams = JSON.parseObject(paramsStr);
if (apiparams == null) {
logger.error(apiMethod + "发生了API Exception的参数错误," + paramsStr);
return JsonUtil.formatJsonResult(apiMethod, "", "500", "非法参数请求", "");
}
// paramsStr = URLDecoder.decode(paramsStr);
boolean readonly = apiparams.getBooleanValue("readonly");
String token = apiparams.getString("token");
boolean async = apiparams.getBooleanValue("async");
JSONObject params = new JSONObject();
if (StringUtil.isNotEmpty(apiparams.getString("params"))) {
params = apiparams.getJSONObject("params");
params.put("requestId", hashkey);
}
params.put("requestId", hashkey);
if (isMockCall(params)) {
return mockCall(apiMethod, paramsStr);
}
HttpServletRequest request = RpcContext.getContext().getRequest(HttpServletRequest.class);
HttpServletResponse response = RpcContext.getContext().getResponse(HttpServletResponse.class);
if (request != null) {
params.put("ip", getRemoteAddr(request));
params.put("userAgent", request.getHeader("user-agent"));
params.put("redirectUrl", getRedirectUrl(request));
response.setHeader("Access-Control-Allow-Origin", "*");
}
String sessionid = getCookieValue(request, TYPE_SESSION_ID);
if (StringUtil.isNullOrEmpty(sessionid)) {
logger.warn("apiMethod=" + apiMethod + "sessionUserid=" + sessionid + "无效" + "openid="
+ params.getString("openid"));
sessionid = params.getString("openid");
}
params.put("sessionid", sessionid);
JSONObject sessionUser = MemCacheForOnecardUtil.getLoginSession(sessionid, params.getString("openid"));
if (StringUtil.isNullOrEmpty(token)) {
token = params.getString("token");
}
String checkSession = setSessionUserInfo(response, sessionUser, params, apiMethod, token, sessionid);
if (StringUtil.isNotEmpty(checkSession)) {
return checkSession;
}
boolean updloadState = params.getBooleanValue("updloadState");
if (updloadState) {
// 上传文件
params.put("uploadFilePath", transformationRequestStr(request));
}
boolean isBatchUpload = params.getBooleanValue("isBatchUpload");
if (isBatchUpload) {
makeBatchUploadParams(params);
}
initBaseParam(params);
String result = apiHub.callPcApi(apiMethod, readonly, async, params, request);
if (StringUtil.isNullOrEmpty(result)) {
result = JsonUtil.formatJsonResult(apiMethod, "", ApiUtil.SUCCESS, "数据未返回", "");
} else {
setCookie(response, apiMethod, result);
}
// logger.info("after 发生了API callApi apiMethod==" + apiMethod + " result:" +
// result);
return result;
}
private void setCookie(HttpServletResponse response, String api, String result) {
try {
if (!WECHAT_OAUTH2_GETSNSAPIBASEOPENID.equals(api)) {
return;
}
JSONObject userInfo = JsonUtil.formatJSONObject(result);
Long orgcode = userInfo.getLong("orgcode");
String openid = userInfo.getString("openid");
Long userid = userInfo.getLong("userid");
Boolean isRegister = userInfo.getBoolean("isRegister");
addWechatCookie(response, openid, StringUtil.getNullLong(userid));
addOpenidWechatCookie(response, StringUtil.getNullStr(orgcode), openid);
if (isRegister && StringUtil.isNotEmpty(userid)) {
addUseridWechatCookie(response, StringUtil.getNullStr(orgcode), userid);
} else {
deleteWechatUseridCookie(response, StringUtil.getNullStr(orgcode));
}
} catch (Exception e) {
logger.error("setCookie error result=" + result + " msg=" + e.getMessage(), e);
}
}
public static void addWechatCookie(HttpServletResponse response, String fromusername, Long userid) {
Cookie formusercookie = new Cookie("fromusername", fromusername);
formusercookie.setHttpOnly(true);
formusercookie.setMaxAge(ONEYEAR);
response.addCookie(formusercookie);
Cookie useridcookie = new Cookie("userid", userid + "");
useridcookie.setHttpOnly(true);
useridcookie.setMaxAge(ONEYEAR);
response.addCookie(useridcookie);
}
public static void addUseridWechatCookie(HttpServletResponse response, String cookieKey, Long userid) {
if (StringUtil.isNotEmpty(userid)) {
Cookie useridcookie = new Cookie(COOKIENAME_WECHAT_AUTH2_USERID + cookieKey, userid + "");
useridcookie.setHttpOnly(true);
useridcookie.setMaxAge(ONEYEAR);
useridcookie.setPath("/");
response.addCookie(useridcookie);
}
}
public static void addOpenidWechatCookie(HttpServletResponse response, String cookieKey, String fromusername) {
if (StringUtil.isNotEmpty(fromusername)) {
Cookie formusercookie = new Cookie(COOKIENAME_WECHAT_AUTH2_OPENID + cookieKey, fromusername);
formusercookie.setHttpOnly(true);
formusercookie.setMaxAge(ONEYEAR);
response.addCookie(formusercookie);
}
}
public static void deleteWechatUseridCookie(HttpServletResponse response, String cookieKey) {
Cookie useridcookie = new Cookie(COOKIENAME_WECHAT_AUTH2_USERID + cookieKey, null);
useridcookie.setMaxAge(ONEYEAR);
response.addCookie(useridcookie);
}
public static final String COOKIENAME_WECHAT_AUTH2 = "WECHAT_AUTH2";
public static final String COOKIENAME_WECHAT_AUTH2_OPENID = "WECHAT_AUTH2_OPENID";
public static final String COOKIENAME_WECHAT_AUTH2_USERID = "WECHAT_AUTH2_USERID";
private String getRemoteAddr(HttpServletRequest request) {
String realIP = request.getHeader("X-real-ip");
String newIP = StringUtil.isNotEmpty(realIP) ? realIP : request.getRemoteAddr();
return newIP;
}
private void makeBatchUploadParams(JSONObject params) {
List<JSONObject> resultlist = (List<JSONObject>) params.get("list");
for (JSONObject result : resultlist) {
String photo = result.getString("photo");
photo = "data:image/jpeg;base64," + photo;
result.put("photo", FileUtil.processBase64Img(photo, ApiProvider.INTERNAL_OSS,
params.getBoolean("saveLocalfile"), params.getString("localfileInternet")));
}
}
/**
* 内部方法:动态获取项目的回调地址
*/
private static String getRedirectUrl(HttpServletRequest request) {
String url = "";
String serverName = request.getServerName();
// serverName = "kong.sso.com";
if (request.getServerPort() == 80) {
url = String.format("%s://%s%s/weixt/mobile/authentication", request.getScheme(), serverName,
request.getContextPath());
return url;
}
url = String.format("%s://%s:%s%s/weixt/mobile/authentication", request.getScheme(), serverName, "8080",
request.getContextPath());
return url;
}
private void initBaseParam(JSONObject params) {
params.putAll(SystemContext.baseParams);
}
/**
* 清除缓存
*
* @param response
*/
public static void deleteWechatCookie(HttpServletResponse response) {
Cookie formusercookie = new Cookie(TYPE_SESSION_ID, null);
formusercookie.setMaxAge(ONEYEAR);
response.addCookie(formusercookie);
}
@SuppressWarnings("unchecked")
public String setSessionUserInfo(HttpServletResponse response, JSONObject sessionUser, JSONObject params,
String apiMethod, String token, String sessionid) {
if (sessionUser == null && (isAuthorization(apiMethod) && isNoAuthorizationToken(token, apiMethod))) {
logger.error("apiMethod=" + apiMethod + "sessionUserid=" + sessionid + "会话过期" + "params="
+ JSONObject.toJSONString(params));
deleteWechatCookie(response);
return JsonUtil.formatJsonResult(apiMethod, "", "sessionExpired", "登录过期,请重新登录", "");
}
if (sessionUser != null) {
String campusid = params.getString("campusid");
String cookieCampusids = sessionUser.getString("cookieCampusids");
String campusType = sessionUser.getString("campusType");
if (StringUtil.isNotEmpty(campusid) && StringUtil.isNotEmpty(cookieCampusids)
&& cookieCampusids.indexOf(campusid) < 0 && campusid.indexOf(",") < 0
&& !apiHub.isNotCheckCampusidSafe(apiMethod, campusType)) {
// 校验校区权限是否越界,针对部分逻辑场景campusid用了逗号隔开暂时屏蔽
// return JsonUtil.formatJsonResult(apiMethod, "", "sessionExpired", "校区权限不足",
// "");
sessionUser.remove("userid");
sessionUser.remove("isRegister");
params.put("userid", 0L);
}
Long userid = sessionUser.getLong("userid");
if (StringUtil.isNotEmpty(userid)) {
params.put("userid", userid);
}
Long orgcode = sessionUser.getLong("orgcode");
if (StringUtil.isNotEmpty(userid)) {
params.put("orgcode", orgcode);
}
String sessionCorpid = sessionUser.getString("sessionCorpid");
if (StringUtil.isNotEmpty(sessionCorpid)) {
params.put("sessionCorpid", sessionCorpid);
}
String userName = sessionUser.getString("userName");
if (StringUtil.isNotEmpty(userName)) {
params.put("logUserName", userName);
}
String campusName = sessionUser.getString("campusName");
if (StringUtil.isNotEmpty(campusName)) {
params.put("logCampusName", campusName);
}
List<JSONObject> campusList = (List<JSONObject>) sessionUser.get("campusList");
if (campusList != null && campusList.size() > 0) {
params.put("logUserCampusid",
campusList.stream().map(c -> c.getString("campusid")).collect(Collectors.joining(",")));
if (StringUtil.isNullOrEmpty(params.getString("campusid"))) {
params.put("campusid", campusList.get(0).getLong("campusid"));
}
}
}
return "";
}
@GET
@Path("pc/nodata/{apiMethod}")
@Produces({ "application/x-www-form-urlencoded; charset=UTF-8", "text/xml; charset=UTF-8" })
public String receiveNodataApiGet(@PathParam("apiMethod") String apiMethod) {
return "欢迎关注!";
}
@POST
@Path("pc/nodata/{apiMethod}")
@Produces({ "application/x-www-form-urlencoded; charset=UTF-8", "text/xml; charset=UTF-8" })
public String receiveNodataApiPost(@PathParam("apiMethod") String apiMethod) {
return "欢迎关注!";
}
@GET
@Path("pc/wechat/{apiMethod}")
@Produces({ "application/x-www-form-urlencoded; charset=UTF-8", "text/xml; charset=UTF-8" })
public String receiveWechatApiGet(@PathParam("apiMethod") String apiMethod) {
HttpServletRequest request = RpcContext.getContext().getRequest(HttpServletRequest.class);
return processWechatRequest(apiMethod, request);
}
@POST
@Path("pc/wechat/{apiMethod}")
@Produces({ "application/x-www-form-urlencoded; charset=UTF-8", "text/xml; charset=UTF-8" })
public String receiveWechatApiPost(@PathParam("apiMethod") String apiMethod) {
HttpServletRequest request = RpcContext.getContext().getRequest(HttpServletRequest.class);
return processWechatRequest(apiMethod, request);
}
@POST
@Path("wechatpay")
@Produces({ "application/x-www-form-urlencoded; charset=UTF-8", "text/xml; charset=UTF-8" })
public String receiveWechatPayApiPost() {
HttpServletRequest request = RpcContext.getContext().getRequest(HttpServletRequest.class);
return receiveWechatPayRequest("wechat_pay_saveAndCheck", false, request);
}
@POST
@Path("pc/wechatpay/callback")
@Produces({ "application/x-www-form-urlencoded; charset=UTF-8", "text/xml; charset=UTF-8" })
public String receivePcWechatPayApiPost() {
HttpServletRequest request = RpcContext.getContext().getRequest(HttpServletRequest.class);
return receiveWechatPayRequest("wechat_pay_saveAndCheck", false, request);
}
@POST
@Path("wechatpay/{apiMethod}")
@Produces({ "application/x-www-form-urlencoded; charset=UTF-8", "text/xml; charset=UTF-8" })
public String receiveWechatPayApiPost(@PathParam("apiMethod") String apiMethod) {
HttpServletRequest request = RpcContext.getContext().getRequest(HttpServletRequest.class);
return receiveWechatPayRequest(apiMethod, false, request);
}
@GET
@Path("ueditor/init")
@Produces({ "application/json; charset=UTF-8", "text/xml; charset=UTF-8" })
public String initUeditorGet() {
HttpServletRequest request = RpcContext.getContext().getRequest(HttpServletRequest.class);
return initUeditor(request);
}
private String initUeditor(HttpServletRequest request) {
// 配置路径,首先获取webpp根目录绝对路径
String rootPath = UtilConstant.WEIKE_FILE;
// 将config.json放到与ueditor.config.js同一级的目录下。将ueditor所有文件放入到wapapp-static-ueditor下
// 设置获取服务端配置文件地址修正路径,此路径同时作用于文件上传
rootPath = rootPath + "static";
String exec = new ActionEnter(request, rootPath).exec();
if ("uploadimage".equals(request.getParameter("action"))) {
JSONObject json = JSON.parseObject(exec);
Long campusid = StringUtil.getNullLong(request.getParameter("campusid"));
if (campusid == 0) {
return exec;
}
JSONObject params = new JSONObject();
params.put("campusid", campusid);
JSONObject campusconfig = JSONObject
.parseObject(baseDataApiHub.callApi("kgpz_getCampusConfig", true, params)).getJSONObject("data");
JSONObject campus = JSONObject.parseObject(baseDataApiHub.callApi("campus_findCampus", true, params))
.getJSONObject("data");
JSONObject configparam = new JSONObject();
configparam.put("configcode", "WATERMARK_STYLE");
String sysconfig = JSONObject
.parseObject(baseDataApiHub.callApi("config_getSysConfigValue", true, configparam))
.getString("data");
String makeWatermark = WatermarkUtil.makeWatermark(campusid, campus, campusconfig, sysconfig);
if (StringUtil.isNotEmpty(makeWatermark)) {
makeWatermark = "@" + makeWatermark;
}
json.put("url", StringUtil.getNullStr(json.get("url")) + makeWatermark);
exec = json.toJSONString();
}
return exec;
}
@POST
@Path("ueditor/init")
@Produces({ "application/json; charset=UTF-8", "text/xml; charset=UTF-8" })
public String initUeditorPost() {
HttpServletRequest request = RpcContext.getContext().getRequest(HttpServletRequest.class);
return initUeditor(request);
}
private String receiveWechatPayRequest(String apiMethod, Boolean async, HttpServletRequest request) {
String result = "sucess";
String encrypt_msg = "";
try {
encrypt_msg = readRawParameter(request.getReader());
logger.info("receiveWechatPayRequest before apiMethod=" + apiMethod + " encrypt_msg=" + encrypt_msg);
JSONObject param = new JSONObject();
param.put("payNotify", encrypt_msg);
String resultJson = apiHub.callPcApi(apiMethod, false, async, param, request);
logger.info("receiveWechatPayRequest after apiMethod=" + apiMethod + " encrypt_msg=" + encrypt_msg
+ " resultJson=" + resultJson);
result = JSONObject.parseObject(resultJson).getString("data");
} catch (Exception e) {
logger.error("receiveWechatPayRequest 发生异常 apiMethod=" + apiMethod + " encrypt_msg=" + encrypt_msg, e);
}
return result;
}
private static final String WECHAT_CALLBACK = "wechat_postcallback_callBack";
public String processWechatRequest(String apiMethod, HttpServletRequest request) {
if (WECHAT_CALLBACK.equals(apiMethod)) {
return receiveWechatRequest(apiMethod, request, request.getParameter("signature"));
} else {
return receiveWechatRequest(apiMethod, request, request.getParameter("msg_signature"));
}
}
public String receiveWechatRequest(String apiMethod, HttpServletRequest request, String msg_signature) {
String result = "sucess";
String encrypt_msg = "";
try {
encrypt_msg = readRawParameter(request.getReader());
String echostr = request.getParameter("echostr");
String timestamp = request.getParameter("timestamp");
String nonce = request.getParameter("nonce");
String encrypt_type = request.getParameter("encrypt_type");
logger.info("receiveWechatRequest apiMethod=" + apiMethod + " encrypt_msg=" + encrypt_msg + " echostr"
+ echostr + " timestamp=" + timestamp + " encrypt_type=" + encrypt_type);
JSONObject param = new JSONObject();
param.put("echostr", echostr);
param.put("msg_signature", msg_signature);
param.put("timestamp", timestamp);
param.put("nonce", nonce);
param.put("encrypt_type", encrypt_type);
param.put("encrypt_msg", encrypt_msg);
String resultJson = apiHub.callPcApi(apiMethod, false, false, param, request);
logger.info("receiveWechatRequest after apiMethod=" + apiMethod + " encrypt_msg=" + encrypt_msg
+ " resultJson=" + resultJson);
result = JSONObject.parseObject(resultJson).getString("data");
// logger.error("resultJson="+JSON.toJSONString(param));
// logger.error("resultJson="+encrypt_msg);
// logger.error("resultJson result="+result);
// result=echostr;
} catch (Exception e) {
logger.error("receiveWechatRequest 发生异常 apiMethod=" + apiMethod + " encrypt_msg=" + encrypt_msg, e);
}
return result;
}
public static String readRawParameter(BufferedReader reader) {
try {
// 1、获取用户发送的信息
StringBuffer sb = new StringBuffer();
String line = "";
while ((line = reader.readLine()) != null) {
sb.append(line);
}
String result = new String(sb.toString().getBytes(), "utf-8");
// logger.info("接受微信普通消息post=" + sb.toString());
return result;
} catch (Exception e) {
e.printStackTrace();
logger.error("错误 WeChatReqBean readRawParameter" + e.getMessage());
return "";
} finally {
}
}
public static String readRawParameter(ServletInputStream in) {
Scanner scanner = new Scanner(in);
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(in));
// 1、获取用户发送的信息
StringBuffer sb = new StringBuffer(100);
while (scanner.hasNextLine()) {
sb.append(scanner.nextLine());
}
String result = new String(sb.toString().getBytes(), "utf-8");
// logger.info("接受微信普通消息post=" + sb.toString());
return result;
} catch (Exception e) {
e.printStackTrace();
logger.error("错误 WeChatReqBean readRawParameter" + e.getMessage());
return "";
} finally {
if (scanner != null) {
scanner.close();
scanner = null;
}
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
private static final String TYPE_SESSION_ID = "JSSSID_COOKIE";
/**
* 判断是否是一个有效的cookie
*
* @param request
* @param cookiename
* @return
*/
private String getCookieValue(HttpServletRequest request, String cookiename) {
if (request == null || request.getCookies() == null) {
return null;
}
for (Cookie cookie : request.getCookies()) {
if (cookie.getName().equals(cookiename)) {
String cookievalue = cookie.getValue();
if (StringUtil.isNotEmpty(cookievalue)) {
return cookievalue;
}
}
}
return null;
}
private boolean isAuthorization(String api) {
if (StringUtil.isNullOrEmpty(api) || USER_USER_LOGIN.equals(api)
|| WECHAT_OAUTH2_GETSNSAPIBASEOPENID.equals(api) || api.equals("wechat_pay_listPayByLastUpdateTime")
|| api.equals("wechat_pay_updateStateByList") || REGIST_ZJLLLREGIST_PUSHREGISTMSG.equals(api)
|| api.equals("wechat_oauth2_getJsApiSignature") || api.equals("wechat_org_findByAppid")
|| api.equals("wechat_pushLog_updateStateByHashkey") || api.equals("wechat_qrconnect_save")
|| api.equals("wechat_qrconnect_getQrcodeCreateTime") || api.equals("user_user_loginWechatQrcode")
|| api.equals("attendance_attendance_getCheckQrcode")
|| api.equals("attendance_busposition_savePosition") || api.equals("attendance_busteacher_save")
|| api.equals("wechat_oauth2_getMiniProgramOpenid") || api.equals("user_user_getByPersonid")
|| api.equals("evaluation_face_dataAndTxt") || api.equals("wechat_oauth2_getMiniProgramSessionKey")
|| api.equals("attendance_baidufaceresult_save") || api.equals("base_dict_list")
|| api.equals("attendance_cameraMachineLive_saveActionTime")
|| api.equals("recruitment_version_getCurrentid") || api.equals("recruitment_stu_save")
|| api.equals("base_dict_findMap") || api.equals("base_user_saveStuParent")
|| api.equals("base_dataSync_authentication") || api.equals("base_campus_findCampus")
|| api.equals("base_contactUs_save") || api.equals("base_corpStu_updateStuParent")
|| api.equals("base_corpStu_saveStuParentToCorp") || api.equals("base_class_listAllClassAndGrade")
|| api.equals("base_user_checkUserByPhone") || api.equals("base_corpUser_saveTeacherToCorp")
|| api.equals("base_class_groupByGrade") || api.equals("base_userAduit_findAuditKgpzByCampusid")
|| api.equals("wechat_corp_checkSuite") || api.equals("user_user_teacherRegisterForWx")
|| api.equals("user_user_sendLoginSms") || api.equals("base_scoreRelease_checkEduSwitch")
|| api.equals("base_scoreorder_getDuiBaFreeUrl") || api.equals("portal_record_listBanner")
|| api.equals("portal_record_list") || api.equals("attendance_countHeadthCode_getCodeType")
|| api.equals("attendance_countHeadthCode_codeByMacid")|| api.equals("wechat_qrconnect_listQrLoginUser")
|| Arrays.asList(noNeedAuthorization).contains(api) || Arrays.asList(estudyApiList).contains(api)
|| Arrays.asList(drinkWaterRecordList).contains(api) || recruitApiList.contains(api)) {
return false;
} else {
return true;
}
}
public static final String[] noNeedAuthorization = new String[]{"wechat_qrconnect_getCorpQrconnectUrl",
"portal_record_findDetail", "portal_record_listContent", "portal_record_readCountAdd",
"portal_comment_list", "base_class_listGradeAndClassByCampusid", "base_stu_findStuById", "base_campus_getCorpQrcode"};
public static final List<String> recruitApiList = Arrays.asList("recruitment_version_getCurrentid",
"recruitment_stu_save", "recruitment_volunteerConfig_listCampusByRecruitVersionid",
"recruitment_recruitVersion_listSpecialCourse", "recruitment_volunteerRecord_listByStuid",
"recruitment_volunteerRecord_save", "recruitment_volunteerRecord_findStuDetail",
"recruitment_volunteerConfig_find", "recruitment_volunteerRecord_getVolunteerList",
"recruitment_volunteerRecord_saveStuDetail");
public static final String[] estudyApiList = new String[] { "sqxy_emenu_getNavMenu", "sqxy_emenu_getSMZTMenu",
"sqxy_eresource_listTopResource", "sqxy_euser_listOrderByScore", "sqxy_emenu_getXZLMResource",
"sqxy_eresource_listOrderByCount", "sqxy_emenu_getMenuByType", "sqxy_kcsj_list", "base_grade_getGradeList",
"sqxy_kcsj_listEnroll", "sqxy_eresource_list", "sqxy_emenu_getAllMenuByCampusid",
"sqxy_eresource_getResourceInfoPage", "sqxy_kcsj_findById", "base_points_scoreTop10",
"sqxy_eteacher_listTeacher", "evaluation_map_list", "sqxy_emenu_listBannerBycampusid",
"base_sms_smsIdenifyCode", "sqxy_emenu_getChildrenMenuById", "user_user_updatePass",
"user_user_saveSqxyUser" };
public static final String[] drinkWaterRecordList = new String[] { "attendance_drink_drinkOpt" };
public static final String[] tokenList = new String[] { "2056409ead6bfc2b787c5a470dd7e9bf",
"0d78fb004b7520b53c7bdc4c8ed957d1" };
private boolean isNoAuthorizationToken(String token, String api) {
if (StringUtil.isNotEmpty(token)) {
boolean isValid = Arrays.<String>asList(tokenList).contains(token);
return !isValid;
} else {
return true;
}
}
@POST
@Path("tokens")
@Produces({ "application/json; charset=UTF-8", "text/xml; charset=UTF-8" })
public String callApi(String paramsStr) {
return apiHub.processCallApi("token_oauth_tokens", paramsStr);
}
public static final int ONEYEAR = 60 * 60 * 24 * 30 * 12;
private static ServletFileUpload servletFileUpload;
private static ServletFileUpload getServletFileUpload() {
if (servletFileUpload == null) {
try {
servletFileUpload = new ServletFileUpload();
} catch (Exception e) {
// TODO Auto-generated catch block
logger.error("ServletFileUpload初始化失败", e);
}
}
return servletFileUpload;
}
/**
* 处理上传的文件流
*
* @param request
* @return
*/
public Map transformationRequest(HttpServletRequest request) {
String widthAndHeight = request.getParameter("widthAndHeight");
String localFilePath = "";
Map result = new HashMap<String, String>();
InputStream is = null;// 输出流
try {
// 创建ServletFileUpload实例
ServletFileUpload fileUpload = getServletFileUpload();
// 解析request请求 返回FileItemStream的iterator实例
FileItemIterator iter = fileUpload.getItemIterator(request);
String localfileDic = SystemContext.baseParams.getString("localfileDic");
File dir = new File(localfileDic);
if (!dir.exists()) {
dir.mkdir();
}
// 迭代取出
while (iter.hasNext()) {
FileItemStream item = iter.next();// 获取文件流
String name = item.getFieldName();// 返回表单中标签的name值
is = item.openStream();// 得到对应表单的输出流
if (!item.isFormField()) {// 如果是非文件域,设置进入map,这里要注意多值处理
if (is.available() > 0) {// 如果输出流的内容大于0
String fname = item.getName();// 获取文件名
Streams.copy(is, new FileOutputStream(localfileDic + fname), true);// 拷贝内容到上传路径
localFilePath = localfileDic + fname;
}
} else {
logger.info("fieldName=" + name);
}
}
if (StringUtil.isNotEmpty(localFilePath)) {
Boolean saveLocalfile = SystemContext.baseParams.getBoolean("saveLocalfile");
String localfileInternet = SystemContext.baseParams.getString("localfileInternet");
result = OSSClientUtil.putFileHaveThumbnail(localFilePath, true, ApiProvider.INTERNAL_OSS,
saveLocalfile, localfileInternet, widthAndHeight);
}
} catch (FileUploadException e) {
logger.error("文件上传失败FileUploadException", e);
} catch (IOException e) {
logger.error("文件上传失败IOException", e);
} catch (Exception e) {
// TODO Auto-generated catch block
logger.error("文件上传失败Exception", e);
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
if (result == null || StringUtil.isNullOrEmpty(StringUtil.getNullStr(result.get("url")))) {
throw new ApiException("文件上传失败,请重试");
}
return result;
}
public String transformationRequestStr(HttpServletRequest request) {
return JSON.toJSONString(transformationRequest(request));
}
public String uploadPicture(HttpServletRequest request) {
// 获取文件需要上传到的路径
try {
String path = request.getRealPath("/upload") + "/";
File dir = new File(path);
if (!dir.exists()) {
dir.mkdir();
}
logger.debug("path=" + path);
request.setCharacterEncoding("utf-8"); // 设置编码
// 获得磁盘文件条目工厂
DiskFileItemFactory factory = new DiskFileItemFactory();
// 如果没以下两行设置的话,上传大的文件会占用很多内存,
// 设置暂时存放的存储室,这个存储室可以和最终存储文件的目录不同
/**
* 原理: 它是先存到暂时存储室,然后再真正写到对应目录的硬盘上, 按理来说当上传一个文件时,其实是上传了两份,第一个是以 .tem 格式的
* 然后再将其真正写到对应目录的硬盘上
*/
factory.setRepository(dir);
// 设置缓存的大小,当上传文件的容量超过该缓存时,直接放到暂时存储室
factory.setSizeThreshold(1024 * 1024);
// 高水平的API文件上传处理
ServletFileUpload upload = new ServletFileUpload(factory);
try {
List<FileItem> list = upload.parseRequest(request);
FileItem picture = null;
for (FileItem item : list) {
// 获取表单的属性名字
String name = item.getFieldName();
// 如果获取的表单信息是普通的 文本 信息
if (item.isFormField()) {
// 获取用户具体输入的字符串
String value = item.getString();
request.setAttribute(name, value);
logger.debug("name=" + name + ",value=" + value);
} else {
picture = item;
}
}
// 自定义上传图片的名字为userId.jpg
String fileName = request.getAttribute("userId") + ".jpg";
String destPath = path + fileName;
logger.debug("destPath=" + destPath);
// 真正写到磁盘上
File file = new File(destPath);
OutputStream out = new FileOutputStream(file);
InputStream in = picture.getInputStream();
int length = 0;
byte[] buf = new byte[1024];
// in.read(buf) 每次读到的数据存放在buf 数组中
while ((length = in.read(buf)) != -1) {
// 在buf数组中取出数据写到(输出流)磁盘上
out.write(buf, 0, length);
}
in.close();
out.close();
} catch (FileUploadException e1) {
logger.error("", e1);
} catch (Exception e) {
logger.error("", e);
}
HashMap<String, Object> res = new HashMap<String, Object>();
res.put("success", true);
} catch (Exception e) {
}
return null;
}
/**
* 135编辑器
*
* @param filter
* @return
*/
@GET
@Path("pc/ueditor/querystyle/{filter}")
@Produces({ "application/x-www-form-urlencoded; charset=UTF-8", "text/xml; charset=UTF-8" })
public String init135Ueditor(@PathParam("filter") String filter) {
return receiveUdeitorRequest(filter);
}
private String receiveUdeitorRequest(String filter) {
String result = "sucess";
String apiMethod = "portal_style_query";
try {
logger.info("receiveUdeitorRequest before apiMethod=" + apiMethod);
JSONObject param = new JSONObject();
param.put("filter", filter);
String resultJson = apiHub.callPcApi(apiMethod, true, false, param, null);
logger.info("receiveUdeitorRequest after apiMethod=" + apiMethod + " resultJson=" + resultJson);
result = JSONObject.parseObject(resultJson).getString("data");
} catch (Exception e) {
logger.error("receiveUdeitorRequest 发生异常 apiMethod=" + apiMethod, e);
}
return result;
}
@POST
@Path("pc/classbrand")
@Produces({ "application/json; charset=UTF-8", "text/xml; charset=UTF-8" })
public String callClassBrandApi(String param) {
logger.info("callClassBrandApi param" + param);
JSONObject params = JSONObject.parseObject(param);
Channel channel = TextWebSocketClassBrandFrameHandler.getChannelByMacid(params.getString("macid"));
if (channel == null) {
return "该班牌未联网";
}
channel.writeAndFlush(new TextWebSocketFrame(params.getString("action")));
return "ok";
}
@POST
@Path("pc/classbrandstate")
@Produces({ "application/json; charset=UTF-8", "text/xml; charset=UTF-8" })
public String callClassBrandStateApi(String param) {
logger.info("callClassBrandStateApi param" + param);
JSONObject params = JSONObject.parseObject(param);
List<String> macids = StringUtil.getNullStrToStringList(params.getString("macids"));
List<String> onlineMacids = TextWebSocketClassBrandFrameHandler.listClassBrandState(macids);
String result = StringUtil.makeStringListToStr(onlineMacids);
logger.info("callClassBrandStateApi param" + param + " result=" + result);
return result;
}
@POST
@Path("pc/saveExamByYdb")
@Produces({ "application/json; charset=UTF-8", "text/xml; charset=UTF-8" })
public String saveExamByYdb(String param) {
JSONObject params = JSONObject.parseObject(param);
logger.info("saveExamByYdb:园丁邦同步考试数据,入参param = " + param);
String result = examScoreApiHub.callApi("exam_saveExamByYdb", true, params);
logger.info("saveExamByYdb:园丁邦同步考试数据,返回结果result = " + result);
return result;
}
@POST
@Path("pc/saveScoreByYdb")
@Produces({ "application/json; charset=UTF-8", "text/xml; charset=UTF-8" })
public String saveScoreByYdb(String param) {
logger.info("saveExamByYdb:园丁邦同步成绩数据,入参param = " + param);
List<JSONObject> scoreList = JSONObject.parseArray(param, JSONObject.class);
JSONObject params = new JSONObject();
params.put("scoreList", scoreList);
String result = examScoreApiHub.callApi("score_saveScoreByYdb", true, params);
logger.info("saveExamByYdb:园丁邦同步成绩数据,返回结果result = " + result);
return result;
}
@Override
@GET
@Path("pc/xiumi/getAccessToken")
@Produces({ "application/json; charset=UTF-8", "text/xml; charset=UTF-8" })
public String xiumiGetAccessToken() {
HttpServletRequest request = RpcContext.getContext().getRequest(HttpServletRequest.class);
return xiuMiService.getAccessToken(request).toJSONString();
}
@Override
@POST
@Path("pc/xiumi/getPicUrl")
@Produces({ "application/json; multipart/form-data; charset=UTF-8", "text/xml; charset=UTF-8" })
public String xiumiGetPicUrl() {
HttpServletRequest request = RpcContext.getContext().getRequest(HttpServletRequest.class);
return xiuMiService.getPicUrl(request).toJSONString();
}
@Override
@POST
@Path("pc/xiumi/saveArticles")
@Produces({ "application/json; charset=UTF-8", "text/xml; charset=UTF-8" })
public String xiumiSaveArticles(String articles) {
HttpServletRequest request = RpcContext.getContext().getRequest(HttpServletRequest.class);
return xiuMiService.saveArticles(request, JSONObject.parseObject(articles), portalApiHub).toJSONString();
}
}
\ No newline at end of file
package com.spacetech.service;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject;
import com.spacetech.common.ConstantVar;
import com.spacetech.common.utils.StringUtil;
import com.spacetech.gateway.PortalApiHub;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricCrypto;
@Service
@Transactional(readOnly = true)
public class XiuMiService {
private static Logger logger = LoggerFactory.getLogger(XiuMiService.class);
@Autowired
private RestApiHubImpl restApiHubImpl;
private static final String XIUMI_SECRET = "Thie1ba6guke7quoh6veikae3Ierukoh";
private static final String XIUMI_APPID = "eZeecee1aich1aetoh4jooquauqua1ah";
private static final String XIUMI_TOKEN = "Uighuo5EiNguoWoh4nohf7Jaina0il8s";
private static final Long TWELVE_HOURS_SECOND = DateUnit.HOUR.getMillis() * 12 / 1000;
private static final String ACCESS_TOKEN_KEY = "kSA4w7nAYjjveaADreqIZw==";
private static final SymmetricCrypto ACCESS_TOKEN_CRYPTO = new SymmetricCrypto(SymmetricAlgorithm.AES,
Base64.decode(ACCESS_TOKEN_KEY));
enum ErrorCode {
CHECK_APPID_ERROR(-3, "APPID错误"), CHECK_ACCESS_TOKEN_ERROR(-2, "access_token校验失败"),
CHECK_SIGNATURE_ERROR(-1, "签名校验失败"), SUCCESS(0, "success"), PARAM_MISSING_ERROR(1, "参数不完整"),
PHOTO_UPLOAD_ERROR(2, "图片上传失败"), ARTICLES_SAVE_ERROR(3, "图文保存失败");
private final Integer code;
private final String msg;
ErrorCode(int code, String msg) {
this.code = code;
this.msg = msg;
}
}
/**
* 接收图文内容
*
* @param request
* @param portalApiHub
* @return
*/
@Transactional
public JSONObject saveArticles(HttpServletRequest request, JSONObject articlesJson, PortalApiHub portalApiHub) {
// 鉴权
JSONObject checkJson = checkParams(request);
Integer checkCode = checkJson.getInteger("code");
if (!ErrorCode.SUCCESS.code.equals(checkCode)) {
return getRetJson(checkCode, checkJson.getString("msg"), getReceivePhotoDataJson(null, null));
}
articlesJson.put("uid", request.getParameter("uid"));
String resultStr = portalApiHub.callApi("record_saveXiumiArticles", true, articlesJson);
if (!ConstantVar.PRAISE_RETURN_SUCCESS.equals(JSONObject.parseObject(resultStr).getString("data"))) {
logger.warn("xiumi saveArticles ARTICLES_SAVE_ERROR resultStr = {}", new Object[] { resultStr });
return getRetJson(ErrorCode.ARTICLES_SAVE_ERROR.code, ErrorCode.ARTICLES_SAVE_ERROR.msg, null);
}
// 保存图文
return getRetJson(ErrorCode.SUCCESS.code, ErrorCode.SUCCESS.msg, null);
}
/**
* 获取鉴权状态JSON
*
* @param request 请求
* @return 返回的JSON
*/
public JSONObject getAccessToken(HttpServletRequest request) {
String appid = request.getParameter("appid");
String timestamp = request.getParameter("timestamp");
String nonce = request.getParameter("nonce");
String signature = request.getParameter("signature");
if (!XIUMI_APPID.equals(appid)) {
logger.warn("xiumi getAccessToken CHECK_APPID_ERROR appid = {}, timestamp = {}, nonce = {}, signature = {}",
new Object[] { appid, timestamp, nonce, signature });
return getRetJson(ErrorCode.CHECK_APPID_ERROR.code, ErrorCode.CHECK_APPID_ERROR.msg, new JSONObject());
}
if (StrUtil.hasEmpty(appid, timestamp, nonce, signature)) {
return getRetJson(ErrorCode.PARAM_MISSING_ERROR.code, ErrorCode.PARAM_MISSING_ERROR.msg, new JSONObject());
}
List<String> signList = Arrays.asList(XIUMI_SECRET, timestamp, nonce, appid);
signList.sort(String::compareTo);
String unencryptedSignature = String.join("", signList);
String encryptedSignature = SecureUtil.md5(SecureUtil.md5(unencryptedSignature));
if (!signature.equals(encryptedSignature)) {
logger.warn(
"xiumi getAccessToken CHECK_SIGNATURE_ERROR appid = {}, timestamp = {}, nonce = {}, signature = {}",
new Object[] { appid, timestamp, nonce, signature });
return getRetJson(ErrorCode.CHECK_SIGNATURE_ERROR.code, ErrorCode.CHECK_SIGNATURE_ERROR.msg,
new JSONObject());
}
return getAccessTokenRetJson();
}
private JSONObject getAccessTokenRetJson() {
JSONObject retJson = new JSONObject();
retJson.put("access_token", ACCESS_TOKEN_CRYPTO.encrypt(String.valueOf(DateUtil.date().getTime())));
retJson.put("expires_in", TWELVE_HOURS_SECOND);
return retJson;
}
/**
* 请求数据二进制->URL
*
* @param request 请求
* @return 返回参数Json
*/
public JSONObject getPicUrl(HttpServletRequest request) {
// 鉴权
JSONObject checkJson = checkParams(request);
Integer checkCode = checkJson.getInteger("code");
if (!ErrorCode.SUCCESS.code.equals(checkCode)) {
return getRetJson(checkCode, checkJson.getString("msg"), getReceivePhotoDataJson(null, null));
}
@SuppressWarnings("unchecked")
Map<String, String> fileMap = (Map<String, String>) restApiHubImpl.transformationRequest(request);
String url = fileMap.get("url");
if (StringUtil.isNullOrEmpty(url)) {
logger.warn("xiumi getPicUrl PHOTO_UPLOAD_ERROR url = {}, fileMap.isEmpty() = {}",
new Object[] { url, fileMap.isEmpty() });
return getRetJson(ErrorCode.PHOTO_UPLOAD_ERROR.code, ErrorCode.PHOTO_UPLOAD_ERROR.msg,
getReceivePhotoDataJson(null, null));
}
return getRetJson(ErrorCode.SUCCESS.code, ErrorCode.SUCCESS.msg, getReceivePhotoDataJson(url, null));
}
private JSONObject getRetJson(Integer code, String msg, JSONObject dataJson) {
JSONObject retJson = new JSONObject();
retJson.put("code", Objects.isNull(code) ? -1 : code);
retJson.put("msg", StringUtil.getNullStr(msg));
if (Objects.nonNull(dataJson)) {
retJson.put("data", dataJson);
}
return retJson;
}
private JSONObject getReceivePhotoDataJson(String url, String name) {
JSONObject dataJson = new JSONObject();
dataJson.put("url", StringUtil.getNullStr(url));
dataJson.put("name", StringUtil.getNullStr(name));
return dataJson;
}
/**
* 输入参数校验的错误code均为负数
*/
private JSONObject checkParams(ServletRequest request) {
String accessToken = request.getParameter("access_token");
String timestamp = request.getParameter("timestamp");
String uid = request.getParameter("uid");
String signature = request.getParameter("signature");
if (StrUtil.hasEmpty(accessToken, timestamp, uid, signature)) {
logger.warn(
"xiumi getAccessToken PARAM_MISSING_ERROR accessToken = {}, timestamp = {}, uid = {}, signature = {}",
new Object[] { accessToken, timestamp, uid, signature });
return getRetJson(ErrorCode.PARAM_MISSING_ERROR.code, ErrorCode.PARAM_MISSING_ERROR.msg,
getReceivePhotoDataJson(null, null));
}
if (!checkAccessToken(accessToken)) {
logger.warn(
"xiumi getAccessToken CHECK_ACCESS_TOKEN_ERROR accessToken = {}, timestamp = {}, uid = {}, signature = {}",
new Object[] { accessToken, timestamp, uid, signature });
return getRetJson(ErrorCode.CHECK_ACCESS_TOKEN_ERROR.code, ErrorCode.CHECK_ACCESS_TOKEN_ERROR.msg,
getReceivePhotoDataJson(null, null));
}
String unencryptedSignature = accessToken + timestamp;
String encryptedSignature = SecureUtil.md5(SecureUtil.md5(unencryptedSignature) + uid);
if (!signature.equals(encryptedSignature)) {
logger.warn(
"xiumi getAccessToken CHECK_SIGNATURE_ERROR accessToken = {}, timestamp = {}, uid = {}, signature = {}",
new Object[] { accessToken, timestamp, uid, signature });
return getRetJson(ErrorCode.CHECK_SIGNATURE_ERROR.code, ErrorCode.CHECK_SIGNATURE_ERROR.msg,
getReceivePhotoDataJson(null, null));
}
return getRetJson(ErrorCode.SUCCESS.code, ErrorCode.SUCCESS.msg, getReceivePhotoDataJson(null, null));
}
/**
* 校验accessToken
*
* @param accessToken accessToken
* @return token是否正确
*/
private boolean checkAccessToken(String accessToken) {
try {
byte[] decrypt = ACCESS_TOKEN_CRYPTO.decrypt(accessToken);
String accessTokenStr = new String(decrypt);
long dateBetween = DateUtil.between(DateUtil.date(), DateUtil.date(Long.parseLong(accessTokenStr)),
DateUnit.SECOND);
if (dateBetween > TWELVE_HOURS_SECOND) {
return false;
}
} catch (Exception e) {
return false;
}
return true;
}
}
package com.spacetech.util;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
import com.spacetech.entity.WxXxLog;
public class LogQueue {
public static BlockingQueue<JSONObject> logQueue = new ArrayBlockingQueue<JSONObject>(1024 * 1024);
private static Logger logger = LoggerFactory.getLogger(LogQueue.class);
public static void put(WxXxLog log) {
try {
if (log.getAppid() != null && log.getAppid().equals("cache_invalid")) {
return;
}
int lsize = logQueue.size();
if (lsize > 8000) {
logger.warn("put logqueue size max");
return;
} else if (lsize > 0 && lsize % 1000 == 0) {
logger.warn("put logqueue size = " + lsize);
}
JSONObject logJson = new JSONObject();
logJson.put("id", log.getId());
logJson.put("orgcode", log.getOrgcode());
logJson.put("campusid", log.getCampusid());
logJson.put("operatetime", log.getOperatetime());
logJson.put("appid", log.getAppid());
logJson.put("appname", log.getAppname());
logJson.put("apppath", log.getApppath());
logJson.put("userid", log.getUserid());
logJson.put("username", log.getUsername());
logJson.put("ip", log.getIp());
logJson.put("content", log.getContent());
logJson.put("serialnumber", log.getSerialnumber());
logJson.put("time", log.getTime());
logJson.put("result", log.getResult());
logJson.put("refer", log.getRefer());
logJson.put("cookie", log.getCookie());
logJson.put("agent", log.getAgent());
logJson.put("type", log.getType());
logJson.put("url", log.getUrl());
logJson.put("resultStr", log.getResultStr());
logJson.put("resultLength", log.getResultLength());
logJson.put("serverip", log.getServerip());
logJson.put("currCampusid", log.getCurrCampusid());
logJson.put("currCampusName", log.getCurrCampusName());
logJson.put("agentType", log.getAgentType());
logJson.put("usertype", log.getUsertype());
logQueue.put(logJson);
} catch (Exception e) {
logger.error("put logqueue error", e);
}
// logger.info(" 更新后当前logQueue队列数量" + logQueue.size());
}
/**
*
* @return
*/
public static JSONObject take() {
try {
return logQueue.take();
} catch (InterruptedException e) {
return null;
}
}
public static BlockingQueue<JSONObject> getFeedbackQueue() {
return logQueue;
}
}
package com.spacetech.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
import com.spacetech.common.exception.BusinessException;
import com.spacetech.service.ProviderService;
public class LogServer implements Runnable {
private static Logger logger = LoggerFactory.getLogger(LogServer.class);
private static ProviderService providerService;
public static ProviderService getProviderService() {
return providerService;
}
public static void setProviderService(ProviderService providerService) {
LogServer.providerService = providerService;
}
/**
* 从总PushMsgQueue消息队列里取数据,并进行处理
*/
@Override
public void run() {
while (true) {
JSONObject log = LogQueue.take();
try {
providerService.saveLog(log);
// logger.info("LOG:" + log.toJSONString());
} catch (BusinessException be) {
logger.error("save log error", be);
} catch (Exception exception) {
logger.error("save log error2", exception);
}
}
}
}
package com.spacetech.util;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.spacetech.common.ConstantVar;
import com.spacetech.common.utils.StringUtil;
import net.rubyeye.xmemcached.exception.MemcachedException;
import net.rubyeye.xmemcached.utils.AddrUtil;
import net.spy.memcached.ConnectionFactoryBuilder;
import net.spy.memcached.ConnectionFactoryBuilder.Protocol;
import net.spy.memcached.MemcachedClient;
import net.spy.memcached.auth.AuthDescriptor;
import net.spy.memcached.auth.PlainCallbackHandler;
public class MemCacheForOnecardUtil {
private static Logger logger = LoggerFactory.getLogger(MemCacheForOnecardUtil.class);
private static final String TYPE_AES_KEY_DATA_SAFE = "AES_KEY_DATA_SAFE";
private static final String TYPE_LOGIN_SESSION = "TYPE_LOGIN_SESSION";
/**
* 设置用户登录缓存
*
* @param user
*/
public static void setLoginSession(JSONObject user) {
if (user != null) {
// 有效期30天
set(getMemcacheKey(TYPE_LOGIN_SESSION, user.getString("ssid")), 30 * 24 * 60 * 60, JSON.toJSONString(user));
}
}
public static JSONObject getLoginSession(String ssid, String openid) {
if (StringUtil.isNullOrEmpty(ssid)) {
return null;
}
Object result = get(getMemcacheKey(TYPE_LOGIN_SESSION, ssid));
if (result == null && StringUtil.isNotEmpty(openid)) {
result = get(getMemcacheKey(TYPE_LOGIN_SESSION, openid));
}
if (result == null) {
return null;
}
JSONObject user = JSON.parseObject((String) result);
return user;
}
/**
* 使用户登录信息失效
*
* @throws MemcachedException
* @throws InterruptedException
* @throws TimeoutException
*/
public static void invalidLoginSession(String userid) {
if (StringUtil.isNotEmpty(userid)) {
delete(getMemcacheKey(TYPE_LOGIN_SESSION, userid));
}
}
private static String getMemcacheKey(String type, String keyid) {
return type + "_" + keyid;
}
/**
* 设置aeskey
*
*/
public static String getAesKeyDataSafe() {
String result = "";
try {
Object obj = get(ConstantVar.SOURCE_YEY + TYPE_AES_KEY_DATA_SAFE);
if (obj != null) {
result = (String) obj;
return result;
} else {
logger.error("获取aeskey错误1 result=" + result);
return null;
}
} catch (Exception e) {
logger.error("获取aeskey错误2 result=" + result, e);
e.printStackTrace();
return null;
}
}
private static MemcachedClient client = null;
public static void start(String ipPort) {
try {
client = new MemcachedClient(new ConnectionFactoryBuilder().setProtocol(Protocol.BINARY).build(),
AddrUtil.getAddresses(ipPort));
} catch (IOException e) {
logger.error("获取缓存发生错误", e);
}
}
public static void start(String ipPort, String username, String password) {
AuthDescriptor ad = new AuthDescriptor(new String[] { "PLAIN" }, new PlainCallbackHandler(username, password));
try {
client = new MemcachedClient(
new ConnectionFactoryBuilder().setProtocol(Protocol.BINARY).setAuthDescriptor(ad).build(),
AddrUtil.getAddresses(ipPort));
} catch (IOException e) {
logger.error("获取缓存发生错误", e);
}
}
public static void set(String key, Object obj) {
try {
client.set(key, 0, obj);
} catch (Exception e) {
// TODO Auto-generated catch block
logger.error("获取缓存发生错误", e);
throw new RuntimeException("设置数据发现异常:" + e.getMessage());
}
}
public static void delete(String key) {
try {
client.delete(key);
} catch (Exception e) {
// TODO Auto-generated catch block
logger.error("获取缓存发生错误", e);
throw new RuntimeException("删除数据发现异常:" + e.getMessage());
}
}
public static void set(String key, int expire, Object obj) {
try {
client.set(key, expire, obj);
} catch (Exception e) {
// TODO Auto-generated catch block
logger.error("获取缓存发生错误", e);
throw new RuntimeException("设置数据发现异常:" + e.getMessage());
}
}
public static Object get(String key) {
try {
return client.get(key);
} catch (Exception e) {
// TODO Auto-generated catch block
logger.error("获取缓存发生错误", e);
throw new RuntimeException("获取数据发现异常:" + e.getMessage());
}
}
}
package com.spacetech.util;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.spacetech.common.ConstantVar;
import com.spacetech.common.utils.StringUtil;
import com.spacetech.websocketcomment.CommentSocketFrameHandler;
import net.rubyeye.xmemcached.utils.AddrUtil;
import net.spy.memcached.ConnectionFactoryBuilder;
import net.spy.memcached.ConnectionFactoryBuilder.Protocol;
import net.spy.memcached.MemcachedClient;
import net.spy.memcached.auth.AuthDescriptor;
import net.spy.memcached.auth.PlainCallbackHandler;
public class MemCacheUtil {
private static Logger logger = LoggerFactory.getLogger(MemCacheUtil.class);
private static MemcachedClient client = null;
private static final String TYPE_WX_USER_INFO = "WX_USER_INFO_NEW";
private static final String LIVE_LIVECOMMENT = "LIVE_LIVECOMMENT";
private static final Integer LIVE_LIVECOMMENT_UNSHOW = 0;
private static final Integer LIVE_LIVECOMMENT_SHOW = 1;
public static void start(String ipPort) {
try {
client = new MemcachedClient(new ConnectionFactoryBuilder()
.setProtocol(Protocol.BINARY).build(),
AddrUtil.getAddresses(ipPort));
} catch (IOException e) {
logger.error("获取缓存发生错误", e);
}
}
public static void start(String ipPort,String username,String password) {
AuthDescriptor ad = new AuthDescriptor(new String[] { "PLAIN" },
new PlainCallbackHandler(username, password));
try {
client = new MemcachedClient(
new ConnectionFactoryBuilder().setProtocol(Protocol.BINARY)
.setAuthDescriptor(ad).build(),
AddrUtil.getAddresses(ipPort));
} catch (IOException e) {
logger.error("获取缓存发生错误", e);
}
}
public static void set(String key, Object obj) {
try {
client.set(key, 0, obj);
} catch (Exception e) {
// TODO Auto-generated catch block
logger.error("获取缓存发生错误", e);
throw new RuntimeException("设置数据发现异常:" + e.getMessage());
}
}
public static void delete(String key) {
try {
client.delete(key);
} catch (Exception e) {
// TODO Auto-generated catch block
logger.error("获取缓存发生错误", e);
throw new RuntimeException("删除数据发现异常:" + e.getMessage());
}
}
public static void set(String key, int expire, Object obj) {
try {
client.set(key, expire, obj);
} catch (Exception e) {
// TODO Auto-generated catch block
logger.error("获取缓存发生错误", e);
throw new RuntimeException("设置数据发现异常:" + e.getMessage());
}
}
public static Object get(String key) {
try {
return client.get(key);
} catch (Exception e) {
// TODO Auto-generated catch block
logger.error("获取缓存发生错误", e);
throw new RuntimeException("获取数据发现异常:" + e.getMessage());
}
}
/**
* 通过用户id获取缓存
*
* @param userid
* @return
*/
public static JSONObject getUserInfoFromMemcached(Long userid) {
if (StringUtil.isNotEmpty(userid)) {
String userinfo = (String) get(TYPE_WX_USER_INFO + ConstantVar.SOURCE_YEY + userid);
if (StringUtil.isNotEmpty(userinfo)) {
return JSON.parseObject(userinfo);
} else {
return null;
}
} else {
return null;
}
}
public static JSONObject putLiveComment(String recordid, String comment) {
try {
JSONObject commentJson = CommentSocketFrameHandler.getLiveComment(comment);
if (StringUtil.isNullOrEmpty(commentJson.size())) {
logger.info("comment send fail! recordid = " + recordid + " comment = " + comment);
return new JSONObject();
}
Object commentList = get(LIVE_LIVECOMMENT + "_" + recordid);
List<JSONObject> commentJsonList = (commentList == null ? null : (List<JSONObject>) commentList);
if (commentJsonList == null) {
Boolean isFinish = new CommentSocketFrameHandler().getLiveState(null, comment, recordid,
CommentSocketFrameHandler.SENDCOMMENT);
if (isFinish) {
logger.info("comment send fail , live isFinish or forbidden! recordid = " + recordid);
return new JSONObject();
}
commentJsonList = Collections.synchronizedList(new ArrayList<JSONObject>());
} else {
Boolean isFinish = new CommentSocketFrameHandler().getLiveState(null, comment, recordid,
CommentSocketFrameHandler.SENDCOMMENT);
if (isFinish) {
logger.info("comment send fail , live isFinish or forbidden! recordid = " + recordid);
return new JSONObject();
}
}
synchronized (commentJsonList) {
commentJsonList.add(commentJson);
set(LIVE_LIVECOMMENT + "_" + recordid, 24 * 60 * 60, commentJsonList);
}
return commentJson;
} catch (Exception e) {
logger.info("comment put cache error! recordid = " + recordid + " comment = " + comment + " e = "
+ e.getMessage(),e);
return new JSONObject();
}
}
public static List<JSONObject> getCommentList(String recordid) {
List<JSONObject> commentJsonList = new ArrayList<JSONObject>();
try {
Object commentList = get(LIVE_LIVECOMMENT + "_" + recordid);
if (commentList != null) {
commentJsonList = (List<JSONObject>) commentList;
commentJsonList = commentJsonList.stream()
.filter(c -> LIVE_LIVECOMMENT_SHOW.equals(c.getInteger("isShow")))
.collect(Collectors.toList());
Integer commentSize = commentJsonList.size();
if (commentSize > CommentSocketFrameHandler.LIVECOMMENT_COMMENTLISTMAXSIZE) {
commentJsonList = CommentSocketFrameHandler.getCommentLimitList(commentJsonList, commentSize);
}
}
return commentJsonList;
} catch (Exception e) {
logger.info("获取直播评论列表失败, recordid = " + recordid);
return new ArrayList<>();
}
}
}
package com.spacetech.util;
import java.net.URLEncoder;
import com.alibaba.fastjson.JSONObject;
import com.spacetech.common.ConstantVar;
import com.spacetech.common.utils.OSSClientUtil;
import com.spacetech.common.utils.StringUtil;
public class WatermarkUtil {
public static String makeWatermark(Long campusid, JSONObject campus, JSONObject campusconfig, String sysconfig) {
String customWatermark = StringUtil
.getNullStr(campusconfig.getString(ConstantVar.CONFIG_CODE_CUSTOMWATERMARK.toString()));
String watermarkConfig = StringUtil
.getNullStr(campusconfig.getString(ConstantVar.CONFIG_CODE_WATERMARK_STATE.toString()));
String wartermarkText = "";
if (StringUtil.isNotEmpty(customWatermark)) {
wartermarkText = customWatermark;
} else {
wartermarkText = StringUtil.getNullStr(campus.get("campus"));
}
if ("1".equals(watermarkConfig)) {
String logo = StringUtil.getNullStr(campus.get("imgpath"));
if (StringUtil.isNotEmpty(logo) && logo.indexOf(OSSClientUtil.ALI_IMAGE_URL) > -1) {
return makeWatermarkWithImg(campusid, logo, wartermarkText);
} else {
return makeWatermarkOnly(campusid, wartermarkText, sysconfig);
}
}
return "";
}
private static String makeWatermarkOnly(Long campusid, String text, String sysconfig) {
return "watermark=2&text=" + URLEncoder.encode(StringUtil.encodeBASE64(text)) + sysconfig;
}
private static String makeWatermarkWithImg(Long campusid, String imgpath, String text) {
return "watermark=3&object="
+ URLEncoder.encode(
StringUtil.encodeBASE64(imgpath.replace(OSSClientUtil.ALI_IMAGE_URL, "") + "@30h_30w_2e"))
+ "&text=" + URLEncoder.encode(StringUtil.encodeBASE64(text))
+ "&type=ZmFuZ3poZW5na2FpdGk&size=16&t=100&color=I0ZGRkZGRg&order=0&align=1&interval=10&p=9&y=10&x=10";
}
}
package com.spacetech.websocketchat.ClassbrandWebsocket;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
import com.spacetech.common.utils.StringUtil;
import com.spacetech.service.RestApiHub;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 处理TextWebSocketFrame
*
*/
@Component
public class TextWebSocketClassBrandFrameHandler extends SimpleChannelInboundHandler<TextWebSocketFrame> {
private static Logger logger = LoggerFactory.getLogger(TextWebSocketClassBrandFrameHandler.class);
public static Map<Channel, String> channelClassBrandMap = new ConcurrentHashMap<Channel, String>();
public static final String CLASSBRAND_HEATBEAT = "ClassBrand_HeartBeat";
@Autowired
private RestApiHub restApiHub;
@Override
protected void channelRead0(ChannelHandlerContext ctx, TextWebSocketFrame msg) throws Exception { // (1)
Channel incoming = ctx.channel();
JSONObject params = JSONObject.parseObject(msg.text()).getJSONObject("params");
String macid = channelClassBrandMap.get(incoming);
if (CLASSBRAND_HEATBEAT.equals(params.getString("type"))) {
putChannelMap(incoming, params, macid);
incoming.writeAndFlush(new TextWebSocketFrame(CLASSBRAND_HEATBEAT));
}
}
private void putChannelMap(Channel incoming, JSONObject params, String macid) {
logger.info("classBrand macid=" + params.getString("macid") + "加入");
if (StringUtil.isNullOrEmpty(macid)) {
channelClassBrandMap.put(incoming, params.getString("macid"));
}
}
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception { // (2)
Channel incoming = ctx.channel();
logger.info("Client:" + incoming.remoteAddress() + "加入");
}
@Override
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { // (3)
Channel incoming = ctx.channel();
logger.info("Client:" + incoming.remoteAddress() + "离开");
}
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception { // (5)
Channel incoming = ctx.channel();
logger.info("Client:" + incoming.remoteAddress() + "在线");
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception { // (6)
Channel incoming = ctx.channel();
channelClassBrandMap.remove(incoming);
System.out.println("Client:" + incoming.remoteAddress() + "掉线");
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) // (7)
throws Exception {
Channel incoming = ctx.channel();
logger.info("Client:" + incoming.remoteAddress() + "异常");
// 当出现异常就关闭连接
cause.printStackTrace();
ctx.close();
}
public static Channel getChannelByMacid(String macid) {
for (Map.Entry<Channel, String> entry : channelClassBrandMap.entrySet()) {
if (entry.getValue().equals(macid)) {
return entry.getKey();
}
}
return null;
}
public static List<String> listClassBrandState(List<String> macids) {
Set<String> onlineClassBrandSet = channelClassBrandMap.values().stream().collect(Collectors.toSet());
return macids.stream().filter(macid -> makeClassBrandState(macid, onlineClassBrandSet))
.collect(Collectors.toList());
}
private static Boolean makeClassBrandState(String macid, Set<String> onlineClassBrandSet) {
if (onlineClassBrandSet.contains(macid)) {
return true;
}
return false;
}
}
package com.spacetech.websocketchat.ClassbrandWebsocket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
/**
* Websocket 聊天服务器-服务端
*
* @author waylau.com
* @date 2015-3-7
*/
public class WebsocketClassBrandServer {
private static Logger logger = LoggerFactory.getLogger(WebsocketClassBrandServer.class);
private int port;
public WebsocketClassBrandServer(int port) {
this.port = port;
}
public void run() throws Exception {
EventLoopGroup bossGroup = new NioEventLoopGroup(); // (1)
EventLoopGroup workerGroup = new NioEventLoopGroup();
ServerBootstrap b = new ServerBootstrap(); // (2)
b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) // (3)
.childHandler(new WebsocketClassBrandServerInitializer()) // (4)
.option(ChannelOption.SO_BACKLOG, 128) // (5)
.childOption(ChannelOption.SO_KEEPALIVE, true); // (6)
logger.info("WebsocketClassBrandServer 启动了" + port);
// 绑定端口,开始接收进来的连接
b.bind(port).sync(); // (7)
}
public static void main(String[] args) throws Exception {
int port;
if (args.length > 0) {
port = Integer.parseInt(args[0]);
} else {
port = 9000;
}
new WebsocketClassBrandServer(port).run();
}
}
\ No newline at end of file
package com.spacetech.websocketchat.ClassbrandWebsocket;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler;
import io.netty.handler.stream.ChunkedWriteHandler;
/**
* 服务端 ChannelInitializer
*
* @author waylau.com
* @date 2015-3-13
*/
public class WebsocketClassBrandServerInitializer extends ChannelInitializer<SocketChannel> { // 1
@Override
public void initChannel(SocketChannel ch) throws Exception {// 2
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new HttpServerCodec());
pipeline.addLast(new HttpObjectAggregator(64 * 1024));
pipeline.addLast(new ChunkedWriteHandler());
pipeline.addLast(new WebSocketServerProtocolHandler("/weixtclassbrand"));
pipeline.addLast(new TextWebSocketClassBrandFrameHandler());
}
}
package com.spacetech.websocketchat;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
import com.spacetech.common.utils.JsonUtil;
import com.spacetech.service.ProviderService;
import com.spacetech.service.RestApiHub;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 处理TextWebSocketFrame
*
* @author waylau.com 2015年3月26日
*/
@Component
public class TextWebSocketFrameHandler extends SimpleChannelInboundHandler<TextWebSocketFrame> {
private static Logger logger = LoggerFactory.getLogger(ProviderService.class);
public static Map<Channel, JSONObject> channelMap = new ConcurrentHashMap<Channel, JSONObject>();
public static final String HEATBEAT = "HeartBeat";
@Autowired
private RestApiHub restApiHub;
@Override
protected void channelRead0(ChannelHandlerContext ctx, TextWebSocketFrame msg) throws Exception { // (1)
Channel incoming = ctx.channel();
JSONObject params = JSONObject.parseObject(msg.text()).getJSONObject("params");
JSONObject channelChatJson = channelMap.get(incoming);
String useridStuid = params.getLong("userid") + "**" + params.getLongValue("stuid");
if (HEATBEAT.equals(params.getString("type"))) {
putChannelMap(incoming, params, channelChatJson, useridStuid);
incoming.writeAndFlush(new TextWebSocketFrame(HEATBEAT));
return;
}
String result = restApiHub.callPcApi("message_chat_save", msg.text());
JSONObject chatJson = JsonUtil.formatJSONObject(result);
String chatPersonidChatPersonStuid = params.getLong("chatPersonid") + "**"
+ params.getLongValue("chatPersonStuid");
String serialNumber = chatJson.getString("serialNumber");
Boolean onLineState = false;
for (Entry<Channel, JSONObject> channelEntry : channelMap.entrySet()) {
JSONObject entryChatJson = channelEntry.getValue();
if (entryChatJson.getString("serialNumber").equals(serialNumber)
&& entryChatJson.getString("useridStuid").equals(chatPersonidChatPersonStuid)) {
onLineState = true;
channelEntry.getKey().writeAndFlush(new TextWebSocketFrame(chatJson.toJSONString()));
logger.info(channelMap.size() + " " + channelEntry.getValue() + " " + chatPersonidChatPersonStuid + " "
+ chatJson.getString("receiverName") + "收到消息:" + chatJson.getString("content"));
restApiHub.callPcApi("message_chat_updateIsReadTrue", msg.text());
break;
}
}
if (onLineState == false) {
params.put("userName", chatJson.getString("senderName"));
JSONObject resultJson = new JSONObject();
resultJson.put("params", params);
restApiHub.callPcApi("message_chat_pushChatMsg", resultJson.toJSONString());
}
incoming.writeAndFlush(new TextWebSocketFrame(chatJson.toJSONString()));
logger.info(chatJson.getString("senderName") + "发出消息:" + chatJson.getString("content"));
}
private void putChannelMap(Channel incoming, JSONObject params, JSONObject channelChatJson, String useridStuid) {
if (channelChatJson == null) {
JSONObject oneChatJson = new JSONObject();
oneChatJson.put("useridStuid", useridStuid);
oneChatJson.put("serialNumber", makeSerialNumber(params));
channelMap.put(incoming, oneChatJson);
}
}
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception { // (2)
Channel incoming = ctx.channel();
System.out.println("Client:" + incoming.remoteAddress() + "加入");
}
@Override
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { // (3)
Channel incoming = ctx.channel();
System.out.println("Client:" + incoming.remoteAddress() + "离开");
}
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception { // (5)
Channel incoming = ctx.channel();
System.out.println("Client:" + incoming.remoteAddress() + "在线");
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception { // (6)
Channel incoming = ctx.channel();
channelMap.remove(incoming);
System.out.println("Client:" + incoming.remoteAddress() + "掉线");
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) // (7)
throws Exception {
Channel incoming = ctx.channel();
System.out.println("Client:" + incoming.remoteAddress() + "异常");
// 当出现异常就关闭连接
cause.printStackTrace();
ctx.close();
}
private String makeSerialNumber(JSONObject params) {
Long chatPersonid = params.getLong("chatPersonid");
Long chatPersonStuid = params.getLongValue("chatPersonStuid");
Long stuid = params.getLongValue("stuid");
Long userid = params.getLong("userid");
if (chatPersonid < userid) {
return chatPersonid + "**" + chatPersonStuid + "**" + userid + "**" + stuid;
} else if (chatPersonid.equals(userid)) {
return compareStuid(userid, stuid, chatPersonid, chatPersonStuid);
} else {
return userid + "**" + stuid + "**" + chatPersonid + "**" + chatPersonStuid;
}
}
private String compareStuid(Long userid, Long stuid, Long chatPersonid, Long chatPersonStuid) {
if (chatPersonStuid < stuid) {
return chatPersonid + "**" + chatPersonStuid + "**" + userid + "**" + stuid;
} else {
return userid + "**" + stuid + "**" + chatPersonid + "**" + chatPersonStuid;
}
}
}
package com.spacetech.websocketchat;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
/**
* Websocket 聊天服务器-服务端
*
* @author waylau.com
* @date 2015-3-7
*/
public class WebsocketChatServer {
private int port;
public WebsocketChatServer(int port) {
this.port = port;
}
public void run() throws Exception {
EventLoopGroup bossGroup = new NioEventLoopGroup(); // (1)
EventLoopGroup workerGroup = new NioEventLoopGroup();
ServerBootstrap b = new ServerBootstrap(); // (2)
b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) // (3)
.childHandler(new WebsocketChatServerInitializer()) // (4)
.option(ChannelOption.SO_BACKLOG, 128) // (5)
.childOption(ChannelOption.SO_KEEPALIVE, true); // (6)
System.out.println("WebsocketServer 启动了" + port);
// 绑定端口,开始接收进来的连接
b.bind(port).sync(); // (7)
}
public static void main(String[] args) throws Exception {
int port;
if (args.length > 0) {
port = Integer.parseInt(args[0]);
} else {
port = 8000;
}
new WebsocketChatServer(port).run();
}
}
\ No newline at end of file
package com.spacetech.websocketchat;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler;
import io.netty.handler.stream.ChunkedWriteHandler;
/**
* 服务端 ChannelInitializer
*
* @author waylau.com
* @date 2015-3-13
*/
public class WebsocketChatServerInitializer extends ChannelInitializer<SocketChannel> { // 1
@Override
public void initChannel(SocketChannel ch) throws Exception {// 2
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new HttpServerCodec());
pipeline.addLast(new HttpObjectAggregator(64 * 1024));
pipeline.addLast(new ChunkedWriteHandler());
pipeline.addLast(new WebSocketServerProtocolHandler("/weixtws"));
pipeline.addLast(new TextWebSocketFrameHandler());
}
}
package com.spacetech.websocketcomment;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
import com.spacetech.common.ConstantVar;
import com.spacetech.common.utils.DateUtil;
import com.spacetech.common.utils.StringUtil;
import com.spacetech.service.ProviderService;
import com.spacetech.service.RestApiHub;
import com.spacetech.util.MemCacheUtil;
import com.spacetech.websocketchat.TextWebSocketFrameHandler;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class CommentSocketFrameHandler extends SimpleChannelInboundHandler<TextWebSocketFrame> {
private static Logger logger = LoggerFactory.getLogger(ProviderService.class);
// 用于存储相同record的channel列表
private static Map<String, List<Channel>> recordChannelMap = new ConcurrentHashMap<String, List<Channel>>();
// 用于存储相channel和record的对应关系
private static Map<Channel, String> channelMap = new ConcurrentHashMap<Channel, String>();
private static final String HEARTBEAT = "HeartBeat";
public static final String SENDCOMMENT = "SendComment";
private static final String LIVESTATE = "LiveState";
private static final String REMOVECOMMENT = "RemoveComment";
private static final String ACTION_COMMENTLIST = "CommentList";
private static final String ACTION_SENDCOMMENT = "SendComment";
private static final String ACTION_STATE = "State";
public static Integer LIVECOMMENT_COMMENTLISTMAXSIZE = 200;
public static Integer LIVECOMMENT_CONTENTMAXSIZE = 50;
@Autowired
private RestApiHub restApiHub;
@Autowired
private static ProviderService providerService;
public void setProviderService(ProviderService providerService) {
CommentSocketFrameHandler.providerService = providerService;
}
@Override
protected void channelRead0(ChannelHandlerContext ctx, TextWebSocketFrame msg) throws Exception {
Channel channel = ctx.channel();
JSONObject params = null;
try {
params = JSONObject.parseObject(msg.text()).getJSONObject("params");
if (params == null) {
logger.info("params is null , json = " + msg.text());
return;
}
} catch (Exception e) {
logger.info("error json , json = " + msg.text());
return;
}
String recordid = params.getString("recordid");
Long userid = params.getLong("userid");
List<Channel> channelList = recordChannelMap.get(recordid);
if (HEARTBEAT.equals(params.getString("type"))) {
getHeartBeatStr(channelList, channel, msg.text(), recordid, userid);
} else if (SENDCOMMENT.equals(params.getString("type"))) {
if (channelList != null) {
saveAndTransmit(channelList, channel, msg.text(), params);
return;
}
if (params.getBoolean("isAdminOrLeader")) {
JSONObject comment = JSONObject.parseObject(msg.text());
MemCacheUtil.putLiveComment(recordid, comment.toJSONString());
}
} else if (LIVESTATE.equals(params.getString("type"))) {
getLiveState(channel, msg.text(), recordid, LIVESTATE);
} else if (channelList != null && REMOVECOMMENT.equals(params.getString("type"))) {
sendRemoveMessage(channelList, params);
} else {
logger.info("receive type error: type=" + params.getString("type") + " channelList=" + channelList);
}
}
private void sendRemoveMessage(List<Channel> channelList, JSONObject params) {
JSONObject removeJson = new JSONObject();
removeJson.put("action", REMOVECOMMENT);
removeJson.put("commentid", params.getString("commentid"));
synchronized (channelList) {
for (Channel channel : channelList) {
channel.writeAndFlush(new TextWebSocketFrame(removeJson.toJSONString()));
}
}
}
private void getHeartBeatStr(List<Channel> channelList, Channel channel, String msg, String recordid, Long userid) {
String message = StringUtil.RETURN_MSG_SUCCESS;
if (channelList == null) {
if (getLiveState(channel, msg, recordid, HEARTBEAT)) {
channel.writeAndFlush(new TextWebSocketFrame(message));
return;
}
channelList = Collections.synchronizedList(new ArrayList<Channel>());
recordChannelMap.put(recordid, channelList);
}
synchronized (channelList) {
if (!channelList.contains(channel)) {
channelMap.put(channel, recordid);
channelList.add(channel);
// 查询当前所有评论
JSONObject retJson = new JSONObject();
retJson.put("action", ACTION_COMMENTLIST);
retJson.put("data", MemCacheUtil.getCommentList(recordid));
message = StringUtil.getNullStr(retJson.toJSONString());
updateMaxNum(msg, recordid);
logger.info(userid + " add " + recordid + " channel success , liveRoom num = " + channelList.size());
}
}
channel.writeAndFlush(new TextWebSocketFrame(message));
}
private void saveAndTransmit(List<Channel> channelList, Channel userChannel, String msg, JSONObject params) {
String recordid = params.getString("recordid");
Long userid = params.getLong("userid");
Boolean isAdminOrLeader = params.getBoolean("isAdminOrLeader");
synchronized (channelList) {
if (!isAdminOrLeader && (channelList.isEmpty() || channelMap.get(userChannel) == null)) {
logger.info(userid + " in " + recordid
+ " sendComment fail, because channel non-existent or not audience");
return;
}
// 保存评论记录并转发
JSONObject paramsJson = MemCacheUtil.putLiveComment(recordid, msg);
Boolean state = StringUtil.isNullOrEmpty(paramsJson.size());
if (state) {
logger.info("put liveComment fail, state = " + state + "! recordid = " + recordid);
return;
}
paramsJson.put("action", ACTION_SENDCOMMENT);
for (Channel channel : channelList) {
channel.writeAndFlush(new TextWebSocketFrame(paramsJson.toJSONString()));
}
}
}
public Boolean getLiveState(Channel channel, String msg, String recordid, String type) {
JSONObject liveInfoJson = getLiveInfo(msg);
if (SENDCOMMENT.equals(type) && !liveInfoJson.getBoolean("showComment")) {
return true;
}
if (LIVESTATE.equals(type)) {
liveInfoJson.put("action", ACTION_STATE);
channel.writeAndFlush(new TextWebSocketFrame(liveInfoJson.toJSONString()));
}
// 判断直播是否结束
Boolean isFinish = liveInfoJson.size() == 0 || StringUtil.getBooleanOfObj(liveInfoJson.getBoolean("isFinish"));
if (LIVESTATE.equals(type) && isFinish) {
// 结束则删除该直播所有的channel
removeLiveChannel(recordid);
}
return isFinish;
}
private void removeChannel(Channel channel, String command) {
String recordid = channelMap.get(channel);
if (StringUtil.isNullOrEmpty(recordid)) {
return;
}
List<Channel> channelList = recordChannelMap.get(recordid);
if (channelList == null) {
return;
}
synchronized (channelList) {
channelMap.remove(channel);
channelList.remove(channel);
if (channelList.isEmpty()) {
logger.info(recordid + " remove channelRoot success");
recordChannelMap.remove(recordid);
}
}
logger.info(
"CommentClient:" + channel.remoteAddress() + " " + command + " , liveRoom num = " + channelList.size());
}
private void removeLiveChannel(String recordid) {
List<Channel> channelList = recordChannelMap.get(recordid);
if (channelList != null) {
synchronized (channelList) {
if (!channelList.isEmpty()) {
channelList.forEach(c -> {
c.close();
});
}
recordChannelMap.remove(recordid);
}
}
}
private JSONObject getLiveInfo(String msg) {
String result = restApiHub.callPcApi("elective_live_getStateById", msg);
JSONObject liveInfoJson = null;
try {
liveInfoJson = JSONObject.parseObject(result).getJSONObject("data");
} catch (Exception e) {
return new JSONObject();
}
return liveInfoJson == null ? new JSONObject() : liveInfoJson;
}
private void updateMaxNum(String msg, String recordid) {
JSONObject liveInfoJson = getLiveInfo(msg);
liveInfoJson.put("liveid", recordid);
JSONObject msgJson = JSONObject.parseObject(msg);
JSONObject params = msgJson.getJSONObject("params");
params.putAll(liveInfoJson);
msgJson.put("params", params);
restApiHub.callPcApi("elective_live_updateMaxNum", msgJson.toJSONString());
}
public static JSONObject getLiveComment(String comment) {
JSONObject params = JSONObject.parseObject(comment).getJSONObject("params");
String recordid = params.getString("recordid");
String content = params.getString("content");
Long publisherid = params.getLong("userid");
String publisher = params.getString("userName");
Integer usertype = params.getInteger("usertype");
Long revicerid = params.getLong("revicerid");
if (StringUtil.isNullOrEmpty(recordid) || StringUtil.isNullOrEmpty(content)
|| StringUtil.isNullOrEmpty(publisherid) || StringUtil.isNullOrEmpty(publisher)
|| StringUtil.isNullOrEmpty(usertype)) {
return new JSONObject();
}
JSONObject commentJson = new JSONObject();
commentJson.put("id", StringUtil.guid());
commentJson.put("recordid", recordid);
commentJson.put("content",
content.length() > LIVECOMMENT_CONTENTMAXSIZE ? content.substring(0, LIVECOMMENT_CONTENTMAXSIZE)
: content);
commentJson.put("isShow", StringUtil.getNullInt(params.getInteger("isShow")));
commentJson.put("isReply", StringUtil.getNullInt(params.getInteger("isReply")));
commentJson.put("userid", params.getBoolean("isAdminOrLeader") ? publisherid * -1 : publisherid);
if(usertype==ConstantVar.USER_TYPE_PARENT){
String parentName = providerService.getParentName(revicerid,params.getInteger("relationCode"));
publisher = StringUtil.isNotEmpty(parentName)?parentName:publisher;
}
commentJson.put("userName", publisher);
commentJson.put("usertype", usertype);
commentJson.put("createTime", DateUtil.getCurrentAllTime());
commentJson.put("updateTime", DateUtil.getCurrentAllTime());
return commentJson;
}
public static List<JSONObject> getCommentLimitList(List<JSONObject> commentJsonList, Integer commentSize) {
List<JSONObject> commentLimitList = new ArrayList<>();
for (int i = commentSize - 1; i > commentSize - LIVECOMMENT_COMMENTLISTMAXSIZE; i--) {
commentLimitList.add(commentJsonList.get(i));
}
return commentLimitList;
}
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
Channel channel = ctx.channel();
logger.info("CommentClient:" + channel.remoteAddress() + " Added");
}
@Override
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
Channel channel = ctx.channel();
removeChannel(channel, "Removed");
}
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
Channel channel = ctx.channel();
logger.info("CommentClient:" + channel.remoteAddress() + " Active");
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
Channel channel = ctx.channel();
// 移除现有的channel
removeChannel(channel, "Inactive");
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
Channel channel = ctx.channel();
// 移除现有的channel
removeChannel(channel, "Exception");
// 当出现异常就关闭连接
ctx.close();
}
}
package com.spacetech.websocketcomment;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler;
import io.netty.handler.stream.ChunkedWriteHandler;
/**
* 服务端 ChannelInitializer
*
* @author waylau.com
* @date 2015-3-13
*/
public class WebsocketCommentServerInitializer extends ChannelInitializer<SocketChannel> {
@Override
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new HttpServerCodec());
pipeline.addLast(new HttpObjectAggregator(64 * 1024));
pipeline.addLast(new ChunkedWriteHandler());
pipeline.addLast(new WebSocketServerProtocolHandler("/livecommentws"));
pipeline.addLast(new CommentSocketFrameHandler());
}
}
package com.spacetech.websocketcomment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
/**
* Websocket 评论服务器-服务端
*
*/
public class WebsocketCommentThread implements Runnable {
private static Logger logger = LoggerFactory.getLogger(WebsocketCommentThread.class);
private int port;
public WebsocketCommentThread() {
}
public WebsocketCommentThread(int port) {
this.port = port;
}
public void run() {
EventLoopGroup bossGroup = new NioEventLoopGroup();
EventLoopGroup workerGroup = new NioEventLoopGroup();
try {
// 用于推送新增评论
ServerBootstrap commentBootstrap = new ServerBootstrap();
commentBootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
.childHandler(new WebsocketCommentServerInitializer()).option(ChannelOption.SO_BACKLOG, 128)
.childOption(ChannelOption.SO_KEEPALIVE, true);
logger.info("WebsocketCommentServer 启动了" + port);
// 绑定端口,开始接收进来的连接
ChannelFuture cf = commentBootstrap.bind(port).sync();
// 等待服务器 socket 关闭 。
// 在这个例子中,这不会发生,但你可以优雅地关闭你的服务器。
cf.channel().closeFuture().sync();
} catch (Exception e) {
// TODO: handle exception
} finally {
workerGroup.shutdownGracefully();
bossGroup.shutdownGracefully();
logger.info("WebsocketCommentServer 关闭了");
}
}
}
\ No newline at end of file
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/growth-dev?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true
username: root
password: root
type: com.alibaba.druid.pool.DruidDataSource
druid:
### 配置初始化大小、最小、最大
# 通常来说,只需要修改initialSize、minIdle、maxActive
initial-size: 2
min-idle: 2
max-active: 60
test-while-idle: true
# 配置获取连接等待超时的时间
max-wait: 20000
# 配置一个连接在池中最小生存的时间,单位是毫秒
min-evictable-idle-time-millis: 30000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
time-between-eviction-runs-millis: 60000
## 解密密码必须要配置的项
# filters: config
# connect-properties: config.decrypt=false
# 检测连接是否可用的 SQL
validation-query: SELECT 'z'
# 是否在获取连接前检查连接状态
test-on-borrow: false
# 是否在归还连接时检查连接状态
test-on-return: false
## 打开PSCache,并且指定每个连接上PSCache的大小
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 100
# 对于建立连接过长的连接强制关闭
remove-abandoned: true
# 如果连接建立时间超过了10分钟,则强制将其关闭
remove-abandoned-timeout-millis: 600
# 将当前关闭动作记录到日志
log-abandoned: true
connection-init-sqls: set names utf8mb4
jpa:
properties:
hibernate:
hbm2ddl:
auto: update
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
format_sql: true
show-sql: true
dubbo:
# application:
# qos-enable: true
protocols:
rest:
name: rest
port: 8899
server: tomcat
dubbo:
name: dubbo
port: -1
registry:
address: spring-cloud://10.10.10.221:8848
scan:
base-packages: com.spacetech.service
cloud:
subscribed-services: service-growth,service-basedata
consumer:
check: false
spring:
application:
name: service-api
cloud:
nacos:
# nacos 服务发现
discovery:
server-addr: ${nacos.server.addr}
# 配置中心,使用时开启
# config:
# server-addr: ${nacos.server.addr}
# file-extension: yaml
# extension-configs:
# - data-id: logback-spring.xml # 日志配置
# group: COMMON-GROUP
# refresh: true
main:
web-application-type: none
nacos:
server:
addr: 10.10.10.221:8848
...@@ -51,18 +51,6 @@ ...@@ -51,18 +51,6 @@
</exclusions> </exclusions>
</dependency> </dependency>
<!--mysql驱动-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!--druid连接池-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
......
...@@ -5,6 +5,7 @@ import java.lang.reflect.Method; ...@@ -5,6 +5,7 @@ import java.lang.reflect.Method;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apache.dubbo.config.annotation.Service;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -20,6 +21,9 @@ import com.spacetech.common.utils.JsonUtil; ...@@ -20,6 +21,9 @@ import com.spacetech.common.utils.JsonUtil;
import com.spacetech.common.utils.StringUtil; import com.spacetech.common.utils.StringUtil;
import com.spacetech.gateway.GrowthApiHub; import com.spacetech.gateway.GrowthApiHub;
@Service(interfaceClass = GrowthApiHub.class)
public class GrowthApiHubImpl implements GrowthApiHub { public class GrowthApiHubImpl implements GrowthApiHub {
@Autowired @Autowired
private MonthIndexService monthIndexService; private MonthIndexService monthIndexService;
...@@ -158,7 +162,7 @@ public class GrowthApiHubImpl implements GrowthApiHub { ...@@ -158,7 +162,7 @@ public class GrowthApiHubImpl implements GrowthApiHub {
* 需要走事务通道 * 需要走事务通道
* *
* @param apiMethod * @param apiMethod
* @param paramsStr * @param
* @return * @return
*/ */
@Transactional(readOnly = false) @Transactional(readOnly = false)
...@@ -170,7 +174,7 @@ public class GrowthApiHubImpl implements GrowthApiHub { ...@@ -170,7 +174,7 @@ public class GrowthApiHubImpl implements GrowthApiHub {
* 不用走事务通道 * 不用走事务通道
* *
* @param apiMethod * @param apiMethod
* @param paramsStr * @param
* @return * @return
*/ */
public String query(String apiMethod, JSONObject param) { public String query(String apiMethod, JSONObject param) {
......
...@@ -15,8 +15,8 @@ spring: ...@@ -15,8 +15,8 @@ spring:
# group: COMMON-GROUP # group: COMMON-GROUP
# refresh: true # refresh: true
# main: main:
# web-application-type: none web-application-type: none
nacos: nacos:
server: server:
......
...@@ -23,6 +23,12 @@ ...@@ -23,6 +23,12 @@
<dependency> <dependency>
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<exclusions>
<exclusion>
<artifactId>jsr311-api</artifactId>
<groupId>javax.ws.rs</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
<!--sentinel 流控--> <!--sentinel 流控-->
...@@ -36,6 +42,19 @@ ...@@ -36,6 +42,19 @@
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-dubbo</artifactId> <artifactId>spring-cloud-starter-dubbo</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</dependency>
<!--mysql驱动-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment