Forráskód Böngészése

Start 类中加入Feign引入

wuxw 7 éve%!(EXTRA string=óta)
szülő
commit
364551a98f

+ 82 - 75
Api/src/main/java/com/java110/api/listener/AbstractServiceApiDataFlowListener.java

@@ -31,9 +31,9 @@ import java.util.Set;
  */
 public abstract class AbstractServiceApiDataFlowListener implements ServiceDataFlowListener {
 
-    private final static Logger logger = LoggerFactory.getLogger(AbstractServiceApiDataFlowListener.class);
+    private static Logger logger = LoggerFactory.getLogger(AbstractServiceApiDataFlowListener.class);
 
-    protected final static int DEFAULT_ORDER = 1;
+    protected static final int DEFAULT_ORDER = 1;
 
     @Autowired
     private RestTemplate restTemplate;
@@ -43,69 +43,72 @@ public abstract class AbstractServiceApiDataFlowListener implements ServiceDataF
 
     /**
      * 调用下游服务
+     *
      * @param event
      * @return
      */
-    protected ResponseEntity<String> callService(ServiceDataFlowEvent event){
+    protected ResponseEntity<String> callService(ServiceDataFlowEvent event) {
 
         DataFlowContext dataFlowContext = event.getDataFlowContext();
         AppService service = event.getAppService();
-        return callService(dataFlowContext,service,dataFlowContext.getReqJson());
+        return callService(dataFlowContext, service, dataFlowContext.getReqJson());
     }
 
 
     /**
      * 调用下游服务
+     *
      * @param context
      * @param serviceCode 下游服务
      * @return
      */
-    protected ResponseEntity<String> callService(DataFlowContext context,String serviceCode,Map paramIn){
+    protected ResponseEntity<String> callService(DataFlowContext context, String serviceCode, Map paramIn) {
 
-        ResponseEntity responseEntity= null;
+        ResponseEntity responseEntity = null;
         AppService appService = DataFlowFactory.getService(context.getAppId(), serviceCode);
-        if(appService == null){
-            responseEntity = new ResponseEntity<String>("当前没有权限访问"+ServiceCodeConstant.SERVICE_CODE_QUERY_STORE_USERS, HttpStatus.UNAUTHORIZED);
+        if (appService == null) {
+            responseEntity = new ResponseEntity<String>("当前没有权限访问" + ServiceCodeConstant.SERVICE_CODE_QUERY_STORE_USERS, HttpStatus.UNAUTHORIZED);
             context.setResponseEntity(responseEntity);
             return responseEntity;
         }
-        return callService(context,appService,paramIn);
+        return callService(context, appService, paramIn);
     }
 
     /**
      * 调用下游服务
+     *
      * @param context
      * @param appService 下游服务
      * @return
      */
-    protected ResponseEntity<String> callService(DataFlowContext context,AppService appService,Map paramIn){
+    protected ResponseEntity<String> callService(DataFlowContext context, AppService appService, Map paramIn) {
 
-        ResponseEntity responseEntity= null;
-        if(paramIn == null || paramIn.isEmpty()){
+        ResponseEntity responseEntity = null;
+        if (paramIn == null || paramIn.isEmpty()) {
             paramIn = context.getReqJson();
         }
 
-        RestTemplate tmpRestTemplate = appService.getServiceCode().startsWith("out.")?restTemplateNoLoadBalanced:restTemplate;
+        RestTemplate tmpRestTemplate = appService.getServiceCode().startsWith("out.") ? restTemplateNoLoadBalanced : restTemplate;
 
         String serviceUrl = appService.getUrl();
         HttpEntity<String> httpEntity = null;
         HttpHeaders header = new HttpHeaders();
-        for(String key : context.getRequestCurrentHeaders().keySet()){
-            if(CommonConstant.HTTP_SERVICE.toLowerCase().equals(key.toLowerCase())){
+        for (String key : context.getRequestCurrentHeaders().keySet()) {
+            if (CommonConstant.HTTP_SERVICE.toLowerCase().equals(key.toLowerCase())) {
                 continue;
             }
-            header.add(key,context.getRequestCurrentHeaders().get(key));
+            header.add(key, context.getRequestCurrentHeaders().get(key));
         }
-        header.add(CommonConstant.HTTP_SERVICE.toLowerCase(),appService.getServiceCode());
+        header.add(CommonConstant.HTTP_SERVICE.toLowerCase(), appService.getServiceCode());
         try {
             if (CommonConstant.HTTP_METHOD_GET.equals(appService.getMethod())) {
-                serviceUrl +="?";
-                for(Object key : paramIn.keySet()){
-                    serviceUrl +=( key+"="+paramIn.get(key)+"&");
+                serviceUrl += "?";
+                for (Object key : paramIn.keySet()) {
+                    serviceUrl += (key + "=" + paramIn.get(key) + "&");
                 }
 
-                if(serviceUrl.endsWith("&")){
-                    serviceUrl = serviceUrl.substring(0,serviceUrl.lastIndexOf("&"));
+                if (serviceUrl.endsWith("&")) {
+                    serviceUrl = serviceUrl.substring(0, serviceUrl.lastIndexOf("&"));
                 }
                 httpEntity = new HttpEntity<String>("", header);
                 responseEntity = tmpRestTemplate.exchange(serviceUrl, HttpMethod.GET, httpEntity, String.class);
@@ -119,32 +122,31 @@ public abstract class AbstractServiceApiDataFlowListener implements ServiceDataF
                 httpEntity = new HttpEntity<String>(JSONObject.toJSONString(paramIn), header);
                 responseEntity = tmpRestTemplate.exchange(serviceUrl, HttpMethod.POST, httpEntity, String.class);
             }
-        }catch (HttpStatusCodeException e){ //这里spring 框架 在4XX 或 5XX 时抛出 HttpServerErrorException 异常,需要重新封装一下
-            responseEntity = new ResponseEntity<String>("请求下游系统异常,"+e.getResponseBodyAsString(),e.getStatusCode());
+        } catch (HttpStatusCodeException e) { //这里spring 框架 在4XX 或 5XX 时抛出 HttpServerErrorException 异常,需要重新封装一下
+            responseEntity = new ResponseEntity<String>("请求下游系统异常," + e.getResponseBodyAsString(), e.getStatusCode());
         }
         return responseEntity;
     }
 
 
-
-
     /**
      * 请求落地方
+     *
      * @param dataFlowContext
      * @param service
      * @param httpEntity
      */
     protected void doRequest(DataFlowContext dataFlowContext, AppService service, HttpEntity<String> httpEntity) {
 
-        ResponseEntity responseEntity= null;
+        ResponseEntity responseEntity = null;
         //配置c_service 时请注意 如果是以out 开头的调用外部的地址
-        RestTemplate tmpRestTemplate = service.getServiceCode().startsWith("out.")?restTemplateNoLoadBalanced:restTemplate;
+        RestTemplate tmpRestTemplate = service.getServiceCode().startsWith("out.") ? restTemplateNoLoadBalanced : restTemplate;
 
         try {
             if (CommonConstant.HTTP_METHOD_GET.equals(service.getMethod())) {
                 String requestUrl = dataFlowContext.getRequestHeaders().get("REQUEST_URL");
                 if (!StringUtil.isNullOrNone(requestUrl)) {
-                    String param = requestUrl.contains("?") ? requestUrl.substring(requestUrl.indexOf("?")+1, requestUrl.length()) : "";
+                    String param = requestUrl.contains("?") ? requestUrl.substring(requestUrl.indexOf("?") + 1, requestUrl.length()) : "";
                     if (service.getUrl().contains("?")) {
                         requestUrl = service.getUrl() + "&" + param;
                     } else {
@@ -168,11 +170,11 @@ public abstract class AbstractServiceApiDataFlowListener implements ServiceDataF
             } else {
                 responseEntity = tmpRestTemplate.exchange(service.getUrl(), HttpMethod.POST, httpEntity, String.class);
             }
-        }catch (HttpStatusCodeException e){ //这里spring 框架 在4XX 或 5XX 时抛出 HttpServerErrorException 异常,需要重新封装一下
-            responseEntity = new ResponseEntity<String>("请求下游系统异常,"+e.getResponseBodyAsString(),e.getStatusCode());
+        } catch (HttpStatusCodeException e) { //这里spring 框架 在4XX 或 5XX 时抛出 HttpServerErrorException 异常,需要重新封装一下
+            responseEntity = new ResponseEntity<String>("请求下游系统异常," + e.getResponseBodyAsString(), e.getStatusCode());
         }
 
-        logger.debug("API 服务调用下游服务请求:{},返回为:{}",httpEntity,responseEntity);
+        logger.debug("API 服务调用下游服务请求:{},返回为:{}", httpEntity, responseEntity);
 
         dataFlowContext.setResponseEntity(responseEntity);
     }
@@ -180,72 +182,73 @@ public abstract class AbstractServiceApiDataFlowListener implements ServiceDataF
 
     /**
      * 处理返回报文信息
+     *
      * @param dataFlowContext
      */
     protected void doResponse(DataFlowContext dataFlowContext) {
         ResponseEntity<String> responseEntity = dataFlowContext.getResponseEntity();
         ResponseEntity<String> newResponseEntity = null;
-        if(responseEntity == null ||
+        if (responseEntity == null ||
                 responseEntity.getStatusCode() != HttpStatus.OK ||
                 StringUtil.isNullOrNone(responseEntity.getBody()) ||
-                !Assert.isJsonObject(responseEntity.getBody())){ //这里一般进不去
-            return ;
+                !Assert.isJsonObject(responseEntity.getBody())) { //这里一般进不去
+            return;
         }
         JSONObject resJson = JSONObject.parseObject(responseEntity.getBody());
 
-        if(!resJson.containsKey("orders")
-                || !ResponseConstant.RESULT_CODE_SUCCESS.equals(resJson.getJSONObject("orders").getJSONObject("response").getString("code"))){
-            return ;
+        if (!resJson.containsKey("orders")
+                || !ResponseConstant.RESULT_CODE_SUCCESS.equals(resJson.getJSONObject("orders").getJSONObject("response").getString("code"))) {
+            return;
         }
 
-        if(resJson.containsKey("business") && resJson.getJSONArray("business").size() == 1){
+        if (resJson.containsKey("business") && resJson.getJSONArray("business").size() == 1) {
             JSONObject busiJson = resJson.getJSONArray("business").getJSONObject(0);
-            if(busiJson.containsKey("orderTypeCd")){
+            if (busiJson.containsKey("orderTypeCd")) {
                 busiJson.remove("orderTypeCd");
             }
-            if(busiJson.containsKey("serviceCode")){
+            if (busiJson.containsKey("serviceCode")) {
                 busiJson.remove("serviceCode");
             }
-            if(busiJson.containsKey("response")){
+            if (busiJson.containsKey("response")) {
                 busiJson.remove("response");
             }
-            if(busiJson.containsKey("bId")){
+            if (busiJson.containsKey("bId")) {
                 busiJson.remove("bId");
             }
 
-            if(busiJson.containsKey("businessType")){
+            if (busiJson.containsKey("businessType")) {
                 busiJson.remove("businessType");
             }
 
-            if(busiJson.containsKey("dataFlowId")){
+            if (busiJson.containsKey("dataFlowId")) {
                 busiJson.remove("dataFlowId");
             }
             //这个一般是 center服务和下游系统之间交互的流水可以删掉,返回出去也没有啥意义
-            if(busiJson.containsKey("transactionId")){
+            if (busiJson.containsKey("transactionId")) {
                 busiJson.remove("transactionId");
             }
             //这里不直接把 下游系统返回的头信息直接扔给ResponseEntity 的原因是 下游系统的 header中的 Context-* 信息导致 客户端调用耗时很长,所以做一下处理
             //newResponseEntity = new ResponseEntity<String>(busiJson.toJSONString(),responseEntity.getHeaders(), HttpStatus.OK);
-            Map<String,String> headersMap = responseEntity.getHeaders().toSingleValueMap();
-            if(headersMap.containsKey("Content-Disposition")) {
+            Map<String, String> headersMap = responseEntity.getHeaders().toSingleValueMap();
+            if (headersMap.containsKey("Content-Disposition")) {
                 headersMap.remove("Content-Disposition");
             }
-            if(headersMap.containsKey("Content-Type")) {
+            if (headersMap.containsKey("Content-Type")) {
                 headersMap.remove("Content-Type");
             }
-            if(headersMap.containsKey("Content-Length")) {
+            if (headersMap.containsKey("Content-Length")) {
                 headersMap.remove("Content-Length");
             }
-            if(headersMap.containsKey("Accept-Charset")) {
+            if (headersMap.containsKey("Accept-Charset")) {
                 headersMap.remove("Accept-Charset");
             }
-            if(headersMap.containsKey("X-Application-Context")) {
+            if (headersMap.containsKey("X-Application-Context")) {
                 headersMap.remove("X-Application-Context");
             }
 
             HttpHeaders header = new HttpHeaders();
             header.setAll(headersMap);
-            newResponseEntity = new ResponseEntity<String>(busiJson.toJSONString(),header, HttpStatus.OK);
+            newResponseEntity = new ResponseEntity<String>(busiJson.toJSONString(), header, HttpStatus.OK);
 
 
             dataFlowContext.setResponseEntity(newResponseEntity);
@@ -255,56 +258,59 @@ public abstract class AbstractServiceApiDataFlowListener implements ServiceDataF
 
     /**
      * 将rest 协议转为 订单协议
+     *
      * @param business
      * @return
      */
-    protected JSONObject restToCenterProtocol(JSONObject business, Map<String,String> headers){
+    protected JSONObject restToCenterProtocol(JSONObject business, Map<String, String> headers) {
 
         JSONObject centerProtocol = JSONObject.parseObject("{\"orders\":{},\"business\":[]}");
-        freshOrderProtocol(centerProtocol.getJSONObject("orders"),headers);
+        freshOrderProtocol(centerProtocol.getJSONObject("orders"), headers);
         centerProtocol.getJSONArray("business").add(business);
         return centerProtocol;
     }
 
     /**
      * 将rest 协议转为 订单协议
+     *
      * @param businesses 多个业务
      * @return
      */
-    protected JSONObject restToCenterProtocol(JSONArray businesses, Map<String,String> headers){
+    protected JSONObject restToCenterProtocol(JSONArray businesses, Map<String, String> headers) {
 
         JSONObject centerProtocol = JSONObject.parseObject("{\"orders\":{},\"business\":[]}");
-        freshOrderProtocol(centerProtocol.getJSONObject("orders"),headers);
-        centerProtocol.put("business",businesses);
+        freshOrderProtocol(centerProtocol.getJSONObject("orders"), headers);
+        centerProtocol.put("business", businesses);
         return centerProtocol;
     }
 
     /**
      * 刷入order信息
-     * @param orders 订单信息
+     *
+     * @param orders  订单信息
      * @param headers 头部信息
      */
     protected void freshOrderProtocol(JSONObject orders, Map<String, String> headers) {
-        for(String key : headers.keySet()){
+        for (String key : headers.keySet()) {
 
-            if(CommonConstant.HTTP_APP_ID.equals(key)) {
+            if (CommonConstant.HTTP_APP_ID.equals(key)) {
                 orders.put("appId", headers.get(key));
             }
-            if(CommonConstant.HTTP_TRANSACTION_ID.equals(key)) {
+            if (CommonConstant.HTTP_TRANSACTION_ID.equals(key)) {
                 orders.put("transactionId", headers.get(key));
             }
-            if(CommonConstant.HTTP_SIGN.equals(key)) {
+            if (CommonConstant.HTTP_SIGN.equals(key)) {
                 orders.put("sign", headers.get(key));
             }
 
-            if(CommonConstant.HTTP_REQ_TIME.equals(key)) {
+            if (CommonConstant.HTTP_REQ_TIME.equals(key)) {
                 orders.put("requestTime", headers.get(key));
             }
-            if(CommonConstant.HTTP_ORDER_TYPE_CD.equals(key)){
-                orders.put("orderTypeCd",headers.get(key));
+            if (CommonConstant.HTTP_ORDER_TYPE_CD.equals(key)) {
+                orders.put("orderTypeCd", headers.get(key));
             }
-            if(CommonConstant.HTTP_USER_ID.equals(key)){
-                orders.put("userId",headers.get(key));
+            if (CommonConstant.HTTP_USER_ID.equals(key)) {
+                orders.put("userId", headers.get(key));
             }
         }
 
@@ -312,25 +318,26 @@ public abstract class AbstractServiceApiDataFlowListener implements ServiceDataF
 
     /**
      * 刷入order信息
+     *
      * @param httpHeaders http 头信息
-     * @param headers 头部信息
+     * @param headers     头部信息
      */
     protected void freshHttpHeader(HttpHeaders httpHeaders, Map<String, String> headers) {
-        for(String key : headers.keySet()){
+        for (String key : headers.keySet()) {
 
-            if(CommonConstant.HTTP_APP_ID.equals(key)) {
+            if (CommonConstant.HTTP_APP_ID.equals(key)) {
                 httpHeaders.add("app_id", headers.get(key));
             }
-            if(CommonConstant.HTTP_TRANSACTION_ID.equals(key)) {
+            if (CommonConstant.HTTP_TRANSACTION_ID.equals(key)) {
                 httpHeaders.add("transaction_id", headers.get(key));
             }
 
-            if(CommonConstant.HTTP_REQ_TIME.equals(key)) {
+            if (CommonConstant.HTTP_REQ_TIME.equals(key)) {
                 httpHeaders.add("req_time", headers.get(key));
             }
 
-            if(CommonConstant.HTTP_USER_ID.equals(key)){
-                httpHeaders.add("user_id",headers.get(key));
+            if (CommonConstant.HTTP_USER_ID.equals(key)) {
+                httpHeaders.add("user_id", headers.get(key));
             }
         }
 

+ 27 - 29
CodeService/src/main/java/com/java110/code/CodeServiceApplicationStart.java

@@ -19,6 +19,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.netflix.feign.EnableFeignClients;
 import org.springframework.context.ApplicationContext;
 
 import java.net.InetAddress;
@@ -34,17 +35,18 @@ import java.util.List;
  * @date 2016年8月6日
  * @tag
  */
-@SpringBootApplication(scanBasePackages = {"com.java110.service","com.java110.code","com.java110.core","com.java110.cache",
-"com.java110.config.properties.code"})
+@SpringBootApplication(scanBasePackages = {"com.java110.service", "com.java110.code", "com.java110.core", "com.java110.cache",
+        "com.java110.config.properties.code"})
 //@SpringBootApplication(scanBasePackages = {"com.java110.service","com.java110.code","com.java110.config.properties.code"})
 @EnableDiscoveryClient
+@EnableFeignClients(basePackages = {"com.java110.core.smo"})
 public class CodeServiceApplicationStart {
     protected final static Logger logger = LoggerFactory.getLogger(CodeServiceApplicationStart.class);
 
 
     public static void main(String[] args) throws Exception {
 
-        ApplicationContext context =  SpringApplication.run(CodeServiceApplicationStart.class, args);
+        ApplicationContext context = SpringApplication.run(CodeServiceApplicationStart.class, args);
 
         ServiceStartInit.initSystemConfig(context);
 
@@ -57,24 +59,24 @@ public class CodeServiceApplicationStart {
     /**
      * 加载 workId
      */
-    public static void loadWorkId() throws StartException{
-        ZookeeperProperties zookeeperProperties =  ApplicationContextFactory.getBean("zookeeperProperties",ZookeeperProperties.class);
+    public static void loadWorkId() throws StartException {
+        ZookeeperProperties zookeeperProperties = ApplicationContextFactory.getBean("zookeeperProperties", ZookeeperProperties.class);
 
-        if(zookeeperProperties == null){
-            throw new StartException(ResponseConstant.RESULT_CODE_ERROR,"系统启动失败,未加载zookeeper 配置信息");
+        if (zookeeperProperties == null) {
+            throw new StartException(ResponseConstant.RESULT_CODE_ERROR, "系统启动失败,未加载zookeeper 配置信息");
         }
 
         String host = null;
         try {
             host = InetAddress.getLocalHost().getHostAddress();
         } catch (UnknownHostException e) {
-            throw new StartException(ResponseConstant.RESULT_CODE_ERROR,"系统启动失败,获取host失败"+e);
+            throw new StartException(ResponseConstant.RESULT_CODE_ERROR, "系统启动失败,获取host失败" + e);
         }
 
-        ServiceInfoListener serviceInfoListener =  ApplicationContextFactory.getBean("serviceInfoListener",ServiceInfoListener.class);
+        ServiceInfoListener serviceInfoListener = ApplicationContextFactory.getBean("serviceInfoListener", ServiceInfoListener.class);
 
-        if(serviceInfoListener == null){
-            throw new StartException(ResponseConstant.RESULT_CODE_ERROR,"系统启动失败,获取服务监听端口失败");
+        if (serviceInfoListener == null) {
+            throw new StartException(ResponseConstant.RESULT_CODE_ERROR, "系统启动失败,获取服务监听端口失败");
         }
 
         serviceInfoListener.setServiceHost(host);
@@ -89,46 +91,42 @@ public class CodeServiceApplicationStart {
             });
 
 
+            Stat stat = zooKeeper.exists(zookeeperProperties.getWorkDir(), true);
 
-            Stat stat = zooKeeper.exists(zookeeperProperties.getWorkDir(),true);
-
-            if(stat == null){
+            if (stat == null) {
                 zooKeeper.create(zookeeperProperties.getWorkDir(), "".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
                         CreateMode.PERSISTENT);
             }
             String workDir = "";
-            List<String> workDirs = zooKeeper.getChildren(zookeeperProperties.getWorkDir(),true);
+            List<String> workDirs = zooKeeper.getChildren(zookeeperProperties.getWorkDir(), true);
 
-            if(workDirs != null && workDirs.size() > 0) {
-                for(String workDirTemp : workDirs){
-                    if(workDirTemp.startsWith(serviceInfoListener.getHostPort())){
+            if (workDirs != null && workDirs.size() > 0) {
+                for (String workDirTemp : workDirs) {
+                    if (workDirTemp.startsWith(serviceInfoListener.getHostPort())) {
                         workDir = workDirTemp;
                         break;
                     }
                 }
             }
-            if(StringUtil.isNullOrNone(workDir)) {
+            if (StringUtil.isNullOrNone(workDir)) {
                 workDir = zooKeeper.create(zookeeperProperties.getWorkDir() + "/" + serviceInfoListener.getHostPort(), "".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
                         CreateMode.PERSISTENT_SEQUENTIAL);
             }
 
             String[] pathTokens = workDir.split("/");
-            if (  pathTokens.length > 0
-                    && pathTokens[pathTokens.length -1].contains("-")
-                    && pathTokens[pathTokens.length -1].contains(":"))
-            {
-                String workId = pathTokens[pathTokens.length -1].substring(pathTokens[pathTokens.length -1].indexOf("-")+1);
+            if (pathTokens.length > 0
+                    && pathTokens[pathTokens.length - 1].contains("-")
+                    && pathTokens[pathTokens.length - 1].contains(":")) {
+                String workId = pathTokens[pathTokens.length - 1].substring(pathTokens[pathTokens.length - 1].indexOf("-") + 1);
                 serviceInfoListener.setWorkId(Long.parseLong(workId));
             }
 
-            Assert.hasLength(serviceInfoListener.getWorkId()+"","系统中加载workId 失败");
-        }catch (Exception e){
+            Assert.hasLength(serviceInfoListener.getWorkId() + "", "系统中加载workId 失败");
+        } catch (Exception e) {
             e.printStackTrace();
-            throw new StartException(ResponseConstant.RESULT_CODE_ERROR,"系统启动失败,链接zookeeper失败"+zookeeperProperties.getZookeeperConnectString());
+            throw new StartException(ResponseConstant.RESULT_CODE_ERROR, "系统启动失败,链接zookeeper失败" + zookeeperProperties.getZookeeperConnectString());
         }
 
 
-
-
     }
 }

+ 2 - 0
CommentService/src/main/java/com/java110/comment/CommentServiceApplicationStart.java

@@ -10,6 +10,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.web.client.RestTemplateBuilder;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.cloud.netflix.feign.EnableFeignClients;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.Bean;
 import org.springframework.http.converter.StringHttpMessageConverter;
@@ -31,6 +32,7 @@ import java.nio.charset.Charset;
 @EnableDiscoveryClient
 @Java110ListenerDiscovery(listenerPublishClass = BusinessServiceDataFlowEventPublishing.class,
         basePackages = {"com.java110.comment.listener"})
+@EnableFeignClients(basePackages = {"com.java110.core.smo"})
 public class CommentServiceApplicationStart {
     private final static Logger logger = LoggerFactory.getLogger(CommentServiceApplicationStart.class);
 

+ 2 - 0
CommunityService/src/main/java/com/java110/community/CommunityServiceApplicationStart.java

@@ -10,6 +10,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.web.client.RestTemplateBuilder;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.cloud.netflix.feign.EnableFeignClients;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.Bean;
 import org.springframework.http.converter.StringHttpMessageConverter;
@@ -31,6 +32,7 @@ import java.nio.charset.Charset;
 @EnableDiscoveryClient
 @Java110ListenerDiscovery(listenerPublishClass = BusinessServiceDataFlowEventPublishing.class,
         basePackages = {"com.java110.community.listener"})
+@EnableFeignClients(basePackages = {"com.java110.core.smo"})
 public class CommunityServiceApplicationStart {
 
     private final static Logger logger = LoggerFactory.getLogger(CommunityServiceApplicationStart.class);

+ 1 - 1
LogService/src/main/java/com/java110/log/LogServiceApplicationStart.java

@@ -23,7 +23,7 @@ import org.springframework.context.ApplicationContext;
 @SpringBootApplication(scanBasePackages = {"com.java110.service","com.java110.log",
 "com.java110.feign.code","com.java110.core","com.java110.cache"})
 @EnableDiscoveryClient
-@EnableFeignClients(basePackages = {"com.java110.feign.code"})
+@EnableFeignClients(basePackages = {"com.java110.core.smo"})
 public class LogServiceApplicationStart {
 
 

+ 12 - 8
OrderService/src/main/java/com/java110/order/OrderServiceApplicationStart.java

@@ -1,10 +1,10 @@
 package com.java110.order;
 
-import com.java110.order.smo.ICenterServiceCacheSMO;
 import com.java110.common.factory.ApplicationContextFactory;
 import com.java110.core.annotation.Java110ListenerDiscovery;
 import com.java110.core.client.RestTemplate;
 import com.java110.event.center.DataFlowEventPublishing;
+import com.java110.order.smo.ICenterServiceCacheSMO;
 import com.java110.service.init.ServiceStartInit;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -13,11 +13,11 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.web.client.RestTemplateBuilder;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.cloud.netflix.feign.EnableFeignClients;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.Bean;
 import org.springframework.http.converter.StringHttpMessageConverter;
 
-
 import java.nio.charset.Charset;
 
 
@@ -30,17 +30,19 @@ import java.nio.charset.Charset;
  * @date 2016年8月6日
  * @tag
  */
-@SpringBootApplication(scanBasePackages={"com.java110.service","com.java110.order","com.java110.core","com.java110.event.order","com.java110.cache"})
+@SpringBootApplication(scanBasePackages = {"com.java110.service", "com.java110.order", "com.java110.core", "com.java110.event.order", "com.java110.cache"})
 @EnableDiscoveryClient
 //@EnableConfigurationProperties(EventProperties.class)
 @Java110ListenerDiscovery(listenerPublishClass = DataFlowEventPublishing.class,
         basePackages = {"com.java110.order.listener"})
+@EnableFeignClients(basePackages = {"com.java110.core.smo"})
 public class OrderServiceApplicationStart {
 
-    private final static Logger logger = LoggerFactory.getLogger(OrderServiceApplicationStart.class);
+    private  static Logger logger = LoggerFactory.getLogger(OrderServiceApplicationStart.class);
 
     /**
      * 实例化RestTemplate,通过@LoadBalanced注解开启均衡负载能力.
+     *
      * @return restTemplate
      */
     @Bean
@@ -53,6 +55,7 @@ public class OrderServiceApplicationStart {
 
     /**
      * 实例化RestTemplate
+     *
      * @return restTemplate
      */
     @Bean
@@ -62,7 +65,7 @@ public class OrderServiceApplicationStart {
         return restTemplate;
     }
 
-    public static void main(String[] args) throws Exception{
+    public static void main(String[] args) throws Exception {
         ApplicationContext context = SpringApplication.run(OrderServiceApplicationStart.class, args);
 
         //服务启动加载
@@ -78,17 +81,18 @@ public class OrderServiceApplicationStart {
 
     /**
      * 刷新主要的缓存
+     *
      * @param args
      */
-    private static void flushMainCache(String []args) {
+    private static void flushMainCache(String[] args) {
 
-        logger.debug("判断是否需要刷新日志,参数 args 为 {}",args);
+        logger.debug("判断是否需要刷新日志,参数 args 为 {}", args);
         if (args == null || args.length == 0) {
             return;
         }
         for (int i = 0; i < args.length; i++) {
             if (args[i].equalsIgnoreCase("-Dcache")) {
-                logger.debug("开始刷新日志,入参为:{}",args[i]);
+                logger.debug("开始刷新日志,入参为:{}", args[i]);
                 ICenterServiceCacheSMO centerServiceCacheSMO = (ICenterServiceCacheSMO) ApplicationContextFactory.getBean("centerServiceCacheSMOImpl");
                 centerServiceCacheSMO.startFlush();
             }

+ 4 - 2
RuleService/src/main/java/com/java110/rule/AppSpringBootApplication.java

@@ -7,6 +7,7 @@ import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.netflix.feign.EnableFeignClients;
 
 
 /**
@@ -18,15 +19,16 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
  * @date 2016年8月6日
  * @tag
  */
-@SpringBootApplication(scanBasePackages="com.java110.service,com.java110.rule")
+@SpringBootApplication(scanBasePackages = "com.java110.service,com.java110.rule")
 @EnableDiscoveryClient
 @EnableConfigurationProperties(EventProperties.class)
+@EnableFeignClients(basePackages = {"com.java110.core.smo"})
 public class AppSpringBootApplication {
 
     private final static Logger logger = LoggerFactory.getLogger(AppSpringBootApplication.class);
 
 
-    public static void main(String[] args) throws Exception{
+    public static void main(String[] args) throws Exception {
         SpringApplication.run(AppSpringBootApplication.class, args);
     }
 }

+ 2 - 0
ShopService/src/main/java/com/java110/shop/ShopServiceApplicationStart.java

@@ -10,6 +10,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.web.client.RestTemplateBuilder;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.cloud.netflix.feign.EnableFeignClients;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.Bean;
 import org.springframework.http.converter.StringHttpMessageConverter;
@@ -31,6 +32,7 @@ import java.nio.charset.Charset;
 @EnableDiscoveryClient
 @Java110ListenerDiscovery(listenerPublishClass = BusinessServiceDataFlowEventPublishing.class,
         basePackages = {"com.java110.shop.listener"})
+@EnableFeignClients(basePackages = {"com.java110.core.smo"})
 public class ShopServiceApplicationStart {
 
     private final static Logger logger = LoggerFactory.getLogger(ShopServiceApplicationStart.class);

+ 2 - 0
StoreService/src/main/java/com/java110/store/StoreServiceApplicationStart.java

@@ -11,6 +11,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.web.client.RestTemplateBuilder;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.cloud.netflix.feign.EnableFeignClients;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.Bean;
 import org.springframework.http.converter.StringHttpMessageConverter;
@@ -32,6 +33,7 @@ import java.nio.charset.Charset;
 @EnableDiscoveryClient
 @Java110ListenerDiscovery(listenerPublishClass = BusinessServiceDataFlowEventPublishing.class,
         basePackages = {"com.java110.store.listener"})
+@EnableFeignClients(basePackages = {"com.java110.core.smo"})
 public class StoreServiceApplicationStart {
 
     private final static Logger logger = LoggerFactory.getLogger(StoreServiceApplicationStart.class);

+ 8 - 5
UserService/src/main/java/com/java110/user/UserServiceApplicationStart.java

@@ -18,6 +18,7 @@ import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletCon
 import org.springframework.boot.web.client.RestTemplateBuilder;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.cloud.netflix.feign.EnableFeignClients;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.Bean;
 import org.springframework.http.converter.StringHttpMessageConverter;
@@ -35,18 +36,20 @@ import java.nio.charset.Charset;
  * @date 2016年8月6日
  * @tag
  */
-@SpringBootApplication(scanBasePackages={"com.java110.service","com.java110.user","com.java110.core","com.java110.cache"})
+@SpringBootApplication(scanBasePackages = {"com.java110.service", "com.java110.user", "com.java110.core", "com.java110.cache"})
 @EnableDiscoveryClient
 @Java110ListenerDiscovery(listenerPublishClass = BusinessServiceDataFlowEventPublishing.class,
         basePackages = {"com.java110.user.listener"})
+@EnableFeignClients(basePackages = {"com.java110.core.smo"})
 public class UserServiceApplicationStart {
 
-    private final static Logger logger = LoggerFactory.getLogger(UserServiceApplicationStart.class);
+    private static Logger logger = LoggerFactory.getLogger(UserServiceApplicationStart.class);
 
-    private final static String LISTENER_PATH = "java110.UserService.listeners";
+    private static final String LISTENER_PATH = "java110.UserService.listeners";
 
     /**
      * 实例化RestTemplate,通过@LoadBalanced注解开启均衡负载能力.
+     *
      * @return restTemplate
      */
     @Bean
@@ -57,10 +60,10 @@ public class UserServiceApplicationStart {
         return restTemplate;
     }
 
-    public static void main(String[] args) throws Exception{
+    public static void main(String[] args) throws Exception {
         ApplicationContext context = SpringApplication.run(UserServiceApplicationStart.class, args);
         ServiceStartInit.initSystemConfig(context);
         //加载业务侦听
-       // SystemStartLoadBusinessConfigure.initSystemConfig(LISTENER_PATH);
+        // SystemStartLoadBusinessConfigure.initSystemConfig(LISTENER_PATH);
     }
 }

+ 2 - 4
java110-common/src/main/java/com/java110/common/constant/ServiceCodeConstant.java

@@ -108,7 +108,7 @@ public class ServiceCodeConstant {
     /**
      * 删除用户全部权限
      */
-    public static final String SERVICE_CODE_DELETE_USER_ALL_PRIVILEGE= "delete.user.allPrivilege";
+    public static final String SERVICE_CODE_DELETE_USER_ALL_PRIVILEGE = "delete.user.allPrivilege";
 
 
     /**
@@ -351,14 +351,12 @@ public class ServiceCodeConstant {
     public static final String SERVICE_CODE_DELETE_AGENT_USER = "delete.agent.user";
 
 
-
     //检查用户是否有权限
     public static final String SERVICE_CODE_CHECK_USER_HAS_PRIVILEGE = "check.user.hasPrivilege";
 
 
     //查询小区楼
-    public static final String SERVICE_CODE_QUERY_FLOOR="floor.queryFloors";
-
+    public static final String SERVICE_CODE_QUERY_FLOOR = "floor.queryFloors";
 
 
 }