java110 5 vuotta sitten
vanhempi
commit
17764bd12c
26 muutettua tiedostoa jossa 489 lisäystä ja 256 poistoa
  1. 1 1
      Readme.md
  2. 2 2
      java110-core/pom.xml
  3. 4 23
      java110-core/src/main/java/com/java110/core/base/AppBase.java
  4. 45 16
      java110-core/src/main/java/com/java110/core/base/controller/BaseController.java
  5. 4 1
      java110-core/src/main/java/com/java110/core/cache/Java110RedisCacheWriter.java
  6. 45 5
      java110-core/src/main/java/com/java110/core/cache/Java110RedisConfig.java
  7. 0 53
      java110-core/src/main/java/com/java110/core/cache/RedisConfiguration.java
  8. 11 29
      java110-core/src/main/java/com/java110/core/component/BaseComponentSMO.java
  9. 4 1
      java110-core/src/main/java/com/java110/core/factory/CallApiServiceFactory.java
  10. 27 0
      java110-core/src/main/java/com/java110/core/smo/IGetCommunityStoreInfoSMO.java
  11. 80 0
      java110-core/src/main/java/com/java110/core/smo/impl/GetCommunityStoreInfoSMOImpl.java
  12. 6 0
      java110-db/src/main/resources/mapper/center/CenterServiceDAOImplMapper.xml
  13. 26 28
      java110-db/src/main/resources/mapper/community/MenuServiceDaoImplMapper.xml
  14. 2 1
      java110-interface/src/main/java/com/java110/intf/community/IMenuInnerServiceSMO.java
  15. 19 0
      java110-utils/src/main/java/com/java110/utils/cache/CommonCache.java
  16. 54 0
      java110-utils/src/main/java/com/java110/utils/cache/PrivilegeCache.java
  17. 6 0
      java110-utils/src/main/java/com/java110/utils/constant/CommonConstant.java
  18. 8 22
      service-api/src/main/java/com/java110/api/listener/basePrivilege/CheckUserHasResourceListener.java
  19. 1 1
      service-community/src/main/java/com/java110/community/dao/IMenuServiceDao.java
  20. 3 5
      service-community/src/main/java/com/java110/community/dao/impl/MenuServiceDaoImpl.java
  21. 2 1
      service-community/src/main/java/com/java110/community/smo/impl/MenuInnerServiceSMOImpl.java
  22. 7 4
      service-front/src/main/java/com/java110/front/FrontServiceApplicationStart.java
  23. 10 2
      service-front/src/main/java/com/java110/front/smo/impl/PrivilegeServiceSMOImpl.java
  24. 8 0
      service-order/src/main/java/com/java110/order/dao/ICenterServiceDAO.java
  25. 6 0
      service-order/src/main/java/com/java110/order/dao/impl/CenterServiceDAOImpl.java
  26. 108 61
      service-order/src/main/java/com/java110/order/smo/impl/CenterServiceCacheSMOImpl.java

+ 1 - 1
Readme.md

@@ -54,7 +54,7 @@
    
    主要系统功能请查看
      
-   [http://www.homecommunity.cn//document/#/func/funcation](http://www.homecommunity.cn//document/#/func/funcation)
+   [http://www.homecommunity.cn/devDoc/#/func/funcation](http://www.homecommunity.cn/devDoc/#/func/funcation)
   
 
 ### 演示地址(demo)

+ 2 - 2
java110-core/pom.xml

@@ -30,8 +30,8 @@
         </dependency>
 
         <dependency>
-            <groupId>org.springframework.data</groupId>
-            <artifactId>spring-data-redis</artifactId>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-cache</artifactId>
         </dependency>
 
 

+ 4 - 23
java110-core/src/main/java/com/java110/core/base/AppBase.java

@@ -3,14 +3,13 @@ package com.java110.core.base;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.context.IPageData;
+import com.java110.core.factory.CallApiServiceFactory;
 import com.java110.utils.cache.BaseCache;
-import com.java110.utils.constant.CommonConstant;
 import com.java110.utils.log.LoggerEngine;
-import com.java110.utils.util.StringUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.http.*;
-import org.springframework.web.client.HttpStatusCodeException;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.client.RestTemplate;
 
 import java.util.List;
@@ -123,25 +122,7 @@ public class AppBase extends BaseCache {
      * @return
      */
     protected ResponseEntity<String> callCenterService(RestTemplate restTemplate, IPageData pd, String param, String url, HttpMethod httpMethod) {
-        ResponseEntity<String> responseEntity = null;
-        HttpHeaders header = new HttpHeaders();
-        header.add(CommonConstant.HTTP_APP_ID.toLowerCase(), CommonConstant.HC_WEB_APP_ID);
-        header.add(CommonConstant.HTTP_USER_ID.toLowerCase(), StringUtil.isEmpty(pd.getUserId()) ? CommonConstant.ORDER_DEFAULT_USER_ID : pd.getUserId());
-        header.add(CommonConstant.HTTP_TRANSACTION_ID.toLowerCase(), pd.getTransactionId());
-        header.add(CommonConstant.HTTP_REQ_TIME.toLowerCase(), pd.getRequestTime());
-        header.add(CommonConstant.HTTP_SIGN.toLowerCase(), "");
-        HttpEntity<String> httpEntity = new HttpEntity<String>(param, header);
-        //logger.debug("请求中心服务信息,{}", httpEntity);
-        try {
-            responseEntity = restTemplate.exchange(url, httpMethod, httpEntity, String.class);
-        } catch (HttpStatusCodeException e) { //这里spring 框架 在4XX 或 5XX 时抛出 HttpServerErrorException 异常,需要重新封装一下
-            responseEntity = new ResponseEntity<String>( e.getResponseBodyAsString(), e.getStatusCode());
-        } catch (Exception e) {
-            responseEntity = new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
-        } finally {
-            logger.debug("请求地址为,{} 请求中心服务信息,{},中心服务返回信息,{}", url, httpEntity, responseEntity);
-            return responseEntity;
-        }
+        return CallApiServiceFactory.callCenterService(restTemplate, pd, param, url, httpMethod);
 
     }
 

+ 45 - 16
java110-core/src/main/java/com/java110/core/base/controller/BaseController.java

@@ -1,21 +1,22 @@
 package com.java110.core.base.controller;
 
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.base.AppBase;
-import com.java110.core.cache.Java110RedisConfig;
 import com.java110.core.context.BusinessServiceDataFlow;
 import com.java110.core.context.IPageData;
 import com.java110.core.context.PageData;
 import com.java110.core.factory.DataFlowFactory;
+import com.java110.core.smo.IGetCommunityStoreInfoSMO;
+import com.java110.dto.basePrivilege.BasePrivilegeDto;
+import com.java110.utils.cache.PrivilegeCache;
 import com.java110.utils.constant.CommonConstant;
 import com.java110.utils.constant.ResponseConstant;
-import com.java110.utils.constant.ServiceConstant;
 import com.java110.utils.exception.NoAuthorityException;
 import com.java110.utils.util.StringUtil;
-import org.springframework.cache.annotation.Cacheable;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
+import com.java110.vo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 import org.springframework.ui.Model;
 import org.springframework.web.client.RestTemplate;
@@ -30,6 +31,9 @@ import java.util.*;
  */
 public class BaseController extends AppBase {
 
+    @Autowired
+    private IGetCommunityStoreInfoSMO getCommunityStoreInfoSMOImpl;
+
 
     /**
      * 检查用户登录
@@ -282,22 +286,47 @@ public class BaseController extends AppBase {
             return;
         }
         JSONObject paramIn = new JSONObject();
-        paramIn.put("resource", resource);
+        //paramIn.put("resource", resource);
         paramIn.put("userId", pd.getUserId());
 
-        responseEntity = checkUserHasResourceListener(restTemplate, pd, paramIn, resource + pd.getUserId());
-        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+        //校验资源路劲是否定义权限
+        List<BasePrivilegeDto> basePrivilegeDtos = PrivilegeCache.getPrivileges();
+        String tmpResource = null;
+        boolean hasPrivilege = false;
+        for (BasePrivilegeDto privilegeDto : basePrivilegeDtos) {
+            if (resource.equals(privilegeDto.getResource())) {
+                hasPrivilege = true;
+            }
+        }
+        if (!hasPrivilege) { //权限没有配置,直接跳过
+            return;
+        }
+
+        ResultVo resultVo = getCommunityStoreInfoSMOImpl.checkUserHasResourceListener(restTemplate, pd, paramIn, pd.getUserId());
+        if (resultVo == null || resultVo.getCode() != ResultVo.CODE_OK) {
+            throw new UnsupportedOperationException("用户没有权限操作");
+        }
+        JSONArray privileges = JSONArray.parseArray(resultVo.getMsg());
+
+        if (basePrivilegeDtos == null || basePrivilegeDtos.size() < 1) {
+            return;
+        }
+        hasPrivilege = false;
+        if (privileges == null || privileges.size() < 1) {
+            throw new UnsupportedOperationException("用户没有权限操作");
+        }
+        for (int privilegeIndex = 0; privilegeIndex < privileges.size(); privilegeIndex++) {
+            tmpResource = privileges.getJSONObject(privilegeIndex).getString("resource");
+            if (resource.equals(tmpResource)) {
+                hasPrivilege = true;
+                break;
+            }
+        }
+        if (!hasPrivilege) {
             throw new UnsupportedOperationException("用户没有权限操作");
         }
-    }
 
-    @Cacheable(value = "checkUserHasResourceListener" + Java110RedisConfig.DEFAULT_EXPIRE_TIME_KEY, key = "#cacheKey")
-    private ResponseEntity<String> checkUserHasResourceListener(RestTemplate restTemplate, IPageData pd, JSONObject paramIn, String cacheKey) {
-        ResponseEntity<String> responseEntity = null;
-        responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(),
-                ServiceConstant.SERVICE_API_URL + "/api/basePrivilege.CheckUserHasResourceListener",
-                HttpMethod.POST);
-        return responseEntity;
     }
 
+
 }

+ 4 - 1
java110-core/src/main/java/com/java110/core/cache/Java110RedisCacheWriter.java

@@ -53,7 +53,9 @@ public class Java110RedisCacheWriter implements RedisCacheWriter {
 
         Assert.notNull(name, "Name must not be null!");
         Assert.notNull(key, "Key must not be null!");
-        Assert.notNull(value, "Value must not be null!");
+        if (value == null) {
+            return;
+        }
 
         execute(name, connection -> {
 
@@ -77,6 +79,7 @@ public class Java110RedisCacheWriter implements RedisCacheWriter {
             return "OK";
         });
     }
+
     /*
      * (non-Javadoc)
      * @see org.springframework.data.redis.cache.RedisCacheWriter#get(java.lang.String, byte[])

+ 45 - 5
java110-core/src/main/java/com/java110/core/cache/Java110RedisConfig.java

@@ -1,7 +1,8 @@
 package com.java110.core.cache;
 
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.cache.CacheManager;
 import org.springframework.cache.annotation.CachingConfigurerSupport;
 import org.springframework.cache.annotation.EnableCaching;
@@ -13,13 +14,18 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
 import org.springframework.data.redis.serializer.RedisSerializationContext;
+import org.springframework.util.StringUtils;
+import redis.clients.jedis.JedisPool;
+import redis.clients.jedis.JedisPoolConfig;
 
 import java.time.Duration;
 
+/**
+ * Created by wuxw on 2017/7/23.
+ */
 @Configuration
-@EnableCaching //开启缓存,默认是rendis缓存,继承CachingConfigurerSupport ,直接重写里面的方法
-@ConditionalOnBean(Java110RedisCacheWriter.class)
-public class Java110RedisConfig extends CachingConfigurerSupport {
+@EnableCaching
+public class Java110RedisConfig extends CachingConfigurerSupport  {
 
     public final static String REDIS_EXPIRE_TIME_KEY = "#key_expire_time";
 
@@ -30,12 +36,44 @@ public class Java110RedisConfig extends CachingConfigurerSupport {
     @Autowired
     private RedisTemplate redisTemplate;
 
+    @Bean(name= "jedisPool")
+    @Autowired
+    public JedisPool jedisPool(@Qualifier("jedis.pool.config") JedisPoolConfig config,
+                               @Value("${jedis.pool.host}")String host,
+                               @Value("${jedis.pool.port}")int port,
+                               @Value("${jedis.pool.timeout}")int timeout,
+                               @Value("${jedis.pool.password}") String password) {
+        //没有配置改为默认值
+        if(timeout == 0){
+            timeout = 2000;
+        }
+
+        if(StringUtils.isEmpty(password)) {
+            return new JedisPool(config, host, port,timeout);
+        }else{
+            return new JedisPool(config,host,port,timeout,password);
+        }
+    }
+
+    @Bean(name= "jedis.pool.config")
+    public JedisPoolConfig jedisPoolConfig (@Value("${jedis.pool.config.maxTotal}")int maxTotal,
+                                            @Value("${jedis.pool.config.maxIdle}")int maxIdle,
+                                            @Value("${jedis.pool.config.maxWaitMillis}")int maxWaitMillis) {
+        JedisPoolConfig config = new JedisPoolConfig();
+        config.setMaxTotal(maxTotal);
+        config.setMaxIdle(maxIdle);
+        config.setMaxWaitMillis(maxWaitMillis);
+
+        return config;
+    }
+
+
+
     @Override
     @Bean
     public CacheManager cacheManager() {
 
         RedisConnectionFactory connectionFactory = redisTemplate.getConnectionFactory();
-        System.out.printf("123123");
         //上面实现的缓存读写
         Java110RedisCacheWriter java110RedisCacheWriter
                 = new Java110RedisCacheWriter(connectionFactory);
@@ -55,4 +93,6 @@ public class Java110RedisConfig extends CachingConfigurerSupport {
 
         return configuration;
     }
+
+
 }

+ 0 - 53
java110-core/src/main/java/com/java110/core/cache/RedisConfiguration.java

@@ -1,53 +0,0 @@
-package com.java110.core.cache;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.cache.annotation.CachingConfigurerSupport;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.util.StringUtils;
-import redis.clients.jedis.JedisPool;
-import redis.clients.jedis.JedisPoolConfig;
-
-/**
- * Created by wuxw on 2017/7/23.
- */
-@Configuration
-public class RedisConfiguration extends CachingConfigurerSupport  {
-
-    @Bean(name= "jedisPool")
-    @Autowired
-    public JedisPool jedisPool(@Qualifier("jedis.pool.config") JedisPoolConfig config,
-                               @Value("${jedis.pool.host}")String host,
-                               @Value("${jedis.pool.port}")int port,
-                               @Value("${jedis.pool.timeout}")int timeout,
-                               @Value("${jedis.pool.password}") String password) {
-        //没有配置改为默认值
-        if(timeout == 0){
-            timeout = 2000;
-        }
-
-        if(StringUtils.isEmpty(password)) {
-            return new JedisPool(config, host, port,timeout);
-        }else{
-            return new JedisPool(config,host,port,timeout,password);
-        }
-    }
-
-    @Bean(name= "jedis.pool.config")
-    public JedisPoolConfig jedisPoolConfig (@Value("${jedis.pool.config.maxTotal}")int maxTotal,
-                                            @Value("${jedis.pool.config.maxIdle}")int maxIdle,
-                                            @Value("${jedis.pool.config.maxWaitMillis}")int maxWaitMillis) {
-        JedisPoolConfig config = new JedisPoolConfig();
-        config.setMaxTotal(maxTotal);
-        config.setMaxIdle(maxIdle);
-        config.setMaxWaitMillis(maxWaitMillis);
-
-        return config;
-    }
-
-
-
-
-}

+ 11 - 29
java110-core/src/main/java/com/java110/core/component/BaseComponentSMO.java

@@ -3,11 +3,9 @@ package com.java110.core.component;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.base.smo.BaseServiceSMO;
-import com.java110.core.cache.Java110RedisConfig;
 import com.java110.core.context.IPageData;
+import com.java110.core.smo.IGetCommunityStoreInfoSMO;
 import com.java110.entity.component.ComponentValidateResult;
-import com.java110.utils.cache.MappingCache;
-import com.java110.utils.constant.MappingConstant;
 import com.java110.utils.constant.ResponseConstant;
 import com.java110.utils.constant.ServiceCodeConstant;
 import com.java110.utils.constant.ServiceConstant;
@@ -15,9 +13,10 @@ import com.java110.utils.exception.SMOException;
 import com.java110.utils.factory.ApplicationContextFactory;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.StringUtil;
+import com.java110.vo.ResultVo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.cache.annotation.Cacheable;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpMethod;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
@@ -35,6 +34,9 @@ public class BaseComponentSMO extends BaseServiceSMO {
 
     protected static final int MAX_ROW = 50;
 
+    @Autowired(required = false)
+    private IGetCommunityStoreInfoSMO getCommunityStoreInfoSMOImpl;
+
     /**
      * 调用组件
      *
@@ -152,19 +154,6 @@ public class BaseComponentSMO extends BaseServiceSMO {
 
     }
 
-    /**
-     * 查询商户信息
-     *
-     * @return
-     */
-    @Cacheable(value = "getStoreInfo" + Java110RedisConfig.GET_STORE_INFO_EXPIRE_TIME_KEY, key = "#userId")
-    protected ResponseEntity<String> getStoreInfo(IPageData pd, RestTemplate restTemplate, String userId) {
-        Assert.hasLength(pd.getUserId(), "用户未登录请先登录");
-        ResponseEntity<String> responseEntity = null;
-        responseEntity = this.callCenterService(restTemplate, pd, "", ServiceConstant.SERVICE_API_URL + "/api/query.store.byuser?userId=" + userId, HttpMethod.GET);
-
-        return responseEntity;
-    }
 
     /**
      * 查询商户信息
@@ -174,21 +163,14 @@ public class BaseComponentSMO extends BaseServiceSMO {
     protected ResponseEntity<String> getStoreInfo(IPageData pd, RestTemplate restTemplate) {
         Assert.hasLength(pd.getUserId(), "用户未登录请先登录");
 
-        return getStoreInfo(pd, restTemplate, pd.getUserId());
-//        ResponseEntity<String> responseEntity = null;
-//        responseEntity = this.callCenterService(restTemplate, pd, "", ServiceConstant.SERVICE_API_URL + "/api/query.store.byuser?userId=" + pd.getUserId(), HttpMethod.GET);
-//
-//        return responseEntity;
+        ResultVo resultVo = getCommunityStoreInfoSMOImpl.getStoreInfo(pd, restTemplate, pd.getUserId());
+
+        return new ResponseEntity<String>(resultVo.getMsg(), resultVo.getCode() == ResultVo.CODE_OK ? HttpStatus.OK : HttpStatus.BAD_REQUEST);
     }
 
-    @Cacheable(value = "getStoreEnterCommunitys" + Java110RedisConfig.GET_STORE_ENTER_COMMUNITYS_EXPIRE_TIME_KEY, key = "#storeId")
     private ResponseEntity<String> getStoreEnterCommunitys(IPageData pd, String storeId, String storeTypeCd, RestTemplate restTemplate) {
-        ResponseEntity<String> responseEntity = null;
-        responseEntity = this.callCenterService(restTemplate, pd, "",
-                ServiceConstant.SERVICE_API_URL + "/api/query.myCommunity.byMember?memberId=" + storeId + "&memberTypeCd="
-                        + MappingCache.getValue(MappingConstant.DOMAIN_STORE_TYPE_2_COMMUNITY_MEMBER_TYPE, storeTypeCd), HttpMethod.GET);
-
-        return responseEntity;
+        ResultVo resultVo = getCommunityStoreInfoSMOImpl.getStoreEnterCommunitys(pd, storeId, storeTypeCd, restTemplate);
+        return new ResponseEntity<String>(resultVo.getMsg(), resultVo.getCode() == ResultVo.CODE_OK ? HttpStatus.OK : HttpStatus.BAD_REQUEST);
     }
 
     /**

+ 4 - 1
java110-core/src/main/java/com/java110/core/factory/CallApiServiceFactory.java

@@ -198,7 +198,7 @@ public class CallApiServiceFactory {
         return list;
     }
 
-    private static ResponseEntity<String> callCenterService(RestTemplate restTemplate, IPageData pd, String param, String url, HttpMethod httpMethod) {
+    public static ResponseEntity<String> callCenterService(RestTemplate restTemplate, IPageData pd, String param, String url, HttpMethod httpMethod) {
         ResponseEntity<String> responseEntity = null;
         HttpHeaders header = new HttpHeaders();
         header.add(CommonConstant.HTTP_APP_ID.toLowerCase(), pd.getAppId());
@@ -221,6 +221,9 @@ public class CallApiServiceFactory {
 
     }
 
+
+
+
     /**
      * map 参数转 url get 参数 非空值转为get参数 空值忽略
      *

+ 27 - 0
java110-core/src/main/java/com/java110/core/smo/IGetCommunityStoreInfoSMO.java

@@ -0,0 +1,27 @@
+package com.java110.core.smo;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.context.IPageData;
+import com.java110.vo.ResultVo;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.RestTemplate;
+
+public interface IGetCommunityStoreInfoSMO {
+
+    ResultVo getStoreInfo(IPageData pd, RestTemplate restTemplate, String userId);
+
+    ResultVo getStoreEnterCommunitys(IPageData pd, String storeId, String storeTypeCd, RestTemplate restTemplate);
+
+    /**
+     * 查询用户权限
+     * @param pd
+     * @param storeId
+     * @param storeTypeCd
+     * @param restTemplate
+     * @return
+     */
+    ResultVo getUserPrivileges(IPageData pd, String storeId, String storeTypeCd, RestTemplate restTemplate);
+
+
+    ResultVo checkUserHasResourceListener(RestTemplate restTemplate, IPageData pd, JSONObject paramIn, String cacheKey);
+}

+ 80 - 0
java110-core/src/main/java/com/java110/core/smo/impl/GetCommunityStoreInfoSMOImpl.java

@@ -0,0 +1,80 @@
+package com.java110.core.smo.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.cache.Java110RedisConfig;
+import com.java110.core.context.IPageData;
+import com.java110.core.factory.CallApiServiceFactory;
+import com.java110.core.smo.IGetCommunityStoreInfoSMO;
+import com.java110.utils.cache.CommonCache;
+import com.java110.utils.cache.MappingCache;
+import com.java110.utils.constant.MappingConstant;
+import com.java110.utils.constant.ServiceConstant;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.StringUtil;
+import com.java110.vo.ResultVo;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+@Service
+public class GetCommunityStoreInfoSMOImpl implements IGetCommunityStoreInfoSMO {
+
+    private static final String BASE_PRIVILEGE = "JAVA110_BASE_PRIVILEGE";
+
+    @Override
+    @Cacheable(value = "getStoreInfo" + Java110RedisConfig.GET_STORE_INFO_EXPIRE_TIME_KEY, key = "#userId")
+    public ResultVo getStoreInfo(IPageData pd, RestTemplate restTemplate, String userId) {
+
+
+        Assert.hasLength(pd.getUserId(), "用户未登录请先登录");
+        ResponseEntity<String> responseEntity = null;
+        responseEntity = CallApiServiceFactory.callCenterService(restTemplate, pd, "", ServiceConstant.SERVICE_API_URL + "/api/query.store.byuser?userId=" + userId, HttpMethod.GET);
+
+        return new ResultVo(responseEntity.getStatusCode() == HttpStatus.OK ? ResultVo.CODE_OK : ResultVo.CODE_ERROR, responseEntity.getBody());
+    }
+
+    @Override
+    @Cacheable(value = "getStoreEnterCommunitys" + Java110RedisConfig.GET_STORE_ENTER_COMMUNITYS_EXPIRE_TIME_KEY, key = "#storeId")
+    public ResultVo getStoreEnterCommunitys(IPageData pd, String storeId, String storeTypeCd, RestTemplate restTemplate) {
+        ResponseEntity<String> responseEntity = null;
+        responseEntity = CallApiServiceFactory.callCenterService(restTemplate, pd, "",
+                ServiceConstant.SERVICE_API_URL + "/api/query.myCommunity.byMember?memberId=" + storeId + "&memberTypeCd="
+                        + MappingCache.getValue(MappingConstant.DOMAIN_STORE_TYPE_2_COMMUNITY_MEMBER_TYPE, storeTypeCd), HttpMethod.GET);
+
+        return new ResultVo(responseEntity.getStatusCode() == HttpStatus.OK ? ResultVo.CODE_OK : ResultVo.CODE_ERROR, responseEntity.getBody());
+    }
+
+    @Override
+    @Cacheable(value = "getUserPrivileges" + Java110RedisConfig.DEFAULT_EXPIRE_TIME_KEY, key = "#staffId")
+    public ResultVo getUserPrivileges(IPageData pd, String staffId, String storeTypeCd, RestTemplate restTemplate) {
+
+        ResponseEntity<String> privilegeGroup = CallApiServiceFactory.callCenterService(restTemplate, pd, "",
+                ServiceConstant.SERVICE_API_URL + "/api/query.user.privilege?userId=" + staffId + "&domain=" + storeTypeCd, HttpMethod.GET);
+
+        return new ResultVo(privilegeGroup.getStatusCode() == HttpStatus.OK ? ResultVo.CODE_OK : ResultVo.CODE_ERROR, privilegeGroup.getBody());
+
+    }
+
+    @Cacheable(value = "checkUserHasResourceListener" + Java110RedisConfig.DEFAULT_EXPIRE_TIME_KEY, key = "#cacheKey")
+    public ResultVo checkUserHasResourceListener(RestTemplate restTemplate, IPageData pd, JSONObject paramIn, String cacheKey) {
+        ResponseEntity<String> responseEntity = null;
+        responseEntity = CallApiServiceFactory.callCenterService(restTemplate, pd, paramIn.toJSONString(),
+                ServiceConstant.SERVICE_API_URL + "/api/basePrivilege.CheckUserHasResourceListener",
+                HttpMethod.POST);
+
+        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+            return null;
+        }
+
+        JSONObject data = JSONObject.parseObject(responseEntity.getBody());
+
+        JSONArray privileges = data.getJSONArray("privileges");
+
+        return new ResultVo(responseEntity.getStatusCode() == HttpStatus.OK ? ResultVo.CODE_OK : ResultVo.CODE_ERROR, privileges.toJSONString());
+
+    }
+}

+ 6 - 0
java110-db/src/main/resources/mapper/center/CenterServiceDAOImplMapper.xml

@@ -253,6 +253,12 @@
         ]]>
     </select>
 
+    <select id="getPrivilegeAll" resultType="com.java110.dto.basePrivilege.BasePrivilegeDto">
+        <![CDATA[
+              select t.p_id pId,t.name,t.domain,t.resource,t.description,t.create_time createTime from p_privilege t where t.status_cd = '0'
+        ]]>
+    </select>
+
     <select id="judgeAllBusinessCompleted" parameterType="map" resultType="map">
         SELECT co.* FROM c_orders co WHERE co.`o_id` = #{oId} and not exists (
         SELECT 1 FROM c_business cb WHERE cb.`o_id` = co.`o_id`

+ 26 - 28
java110-db/src/main/resources/mapper/community/MenuServiceDaoImplMapper.xml

@@ -3,7 +3,7 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="menuServiceDaoImpl">
-    
+
 
     <!-- 保存路由信息至 instance表中 add by wuxw 2018-07-03 -->
     <insert id="saveMenuGroupInfo" parameterType="Map">
@@ -55,7 +55,7 @@
                 t.status_cd = #{statusCd},
             </if>
             <if test="name !=null and name != ''">
-                 t.name= #{name},
+                t.name= #{name},
             </if>
             <if test="icon !=null and icon != ''">
                 t.icon= #{icon},
@@ -103,10 +103,6 @@
     </select>
 
 
-
-
-
-
     <!-- 保存路由信息至 instance表中 add by wuxw 2018-07-03 -->
     <insert id="saveBasePrivilegeRelInfo" parameterType="Map">
         insert into p_privilege_rel(
@@ -118,7 +114,6 @@
     </insert>
 
 
-
     <!-- 保存路由信息至 instance表中 add by wuxw 2018-07-03 -->
     <insert id="saveBasePrivilegeInfo" parameterType="Map">
         insert into p_privilege(
@@ -199,7 +194,6 @@
     </update>
 
 
-
     <!-- 查询路由数量 add by wuxw 2018-07-03 -->
     <select id="queryBasePrivilegesCount" parameterType="Map" resultType="Map">
         select count(1) count
@@ -226,13 +220,12 @@
     </select>
 
 
-
     <!-- 保存路由信息至 instance表中 add by wuxw 2018-07-03 -->
     <insert id="saveMenuInfo" parameterType="Map">
         insert into m_menu(
-           m_id,name,g_id,url,seq,p_id,description,is_show
+        m_id,name,g_id,url,seq,p_id,description,is_show
         ) values (
-            #{mId},#{name},#{gId},#{url},#{seq},'-1',#{description},#{isShow}
+        #{mId},#{name},#{gId},#{url},#{seq},'-1',#{description},#{isShow}
         )
     </insert>
 
@@ -415,24 +408,29 @@
 
     <select id="checkUserHasResource" parameterType="Map" resultType="Map">
         SELECT pp.*,'-1' AS pg_id,'' AS pg_name FROM p_privilege_user ppu,p_privilege pp
-            WHERE ppu.`p_id` = pp.`p_id`
-                AND pp.`resource` = #{resource}
-                AND ppu.`privilege_flag` = '0'
-                AND ppu.`user_id` = #{userId}
-                AND ppu.`status_cd` = '0'
-                AND pp.`status_cd` = '0'
+        WHERE ppu.`p_id` = pp.`p_id`
+        <if test="resource != null and resource != ''">
+            AND pp.`resource` = #{resource}
+        </if>
+        AND ppu.`privilege_flag` = '0'
+        AND ppu.`user_id` = #{userId}
+        AND ppu.`status_cd` = '0'
+        AND pp.`status_cd` = '0'
         UNION
-        SELECT pp.*,ppg.pg_id,ppg.name pg_name FROM p_privilege_user ppu,p_privilege_group ppg,p_privilege pp,p_privilege_rel ppr
-            WHERE ppu.`p_id` = ppr.pg_id
-                AND ppr.pg_id = ppg.pg_id
-                AND ppr.p_id = pp.`p_id`
-                AND pp.`resource` = #{resource}
-                AND ppu.`privilege_flag` = '1'
-                AND ppu.`user_id` = #{userId}
-                AND ppu.`status_cd` = '0'
-                AND pp.`status_cd` = '0'
-                AND ppg.status_cd = '0'
-                AND ppr.status_cd = '0'
+        SELECT pp.*,ppg.pg_id,ppg.name pg_name FROM p_privilege_user ppu,p_privilege_group ppg,p_privilege
+        pp,p_privilege_rel ppr
+        WHERE ppu.`p_id` = ppr.pg_id
+        AND ppr.pg_id = ppg.pg_id
+        AND ppr.p_id = pp.`p_id`
+        <if test="resource != null and resource != ''">
+            AND pp.`resource` = #{resource}
+        </if>
+        AND ppu.`privilege_flag` = '1'
+        AND ppu.`user_id` = #{userId}
+        AND ppu.`status_cd` = '0'
+        AND pp.`status_cd` = '0'
+        AND ppg.status_cd = '0'
+        AND ppr.status_cd = '0'
     </select>
 
 

+ 2 - 1
java110-interface/src/main/java/com/java110/intf/community/IMenuInnerServiceSMO.java

@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @ClassName IMenuGroupInnerServiceSMO
@@ -97,7 +98,7 @@ public interface IMenuInnerServiceSMO {
      * @return 小区下的小区楼记录数
      */
     @RequestMapping(value = "/checkUserHasResource", method = RequestMethod.POST)
-    boolean checkUserHasResource(@RequestBody BasePrivilegeDto routeDto);
+    List<Map> checkUserHasResource(@RequestBody BasePrivilegeDto routeDto);
 
 
     /**

+ 19 - 0
java110-utils/src/main/java/com/java110/utils/cache/CommonCache.java

@@ -70,6 +70,25 @@ public class CommonCache extends BaseCache {
 
     }
 
+
+    /**
+     * 保存数据
+     *
+     * @param key
+     */
+    public static void setValue(String key, String value) {
+        Jedis redis = null;
+        try {
+            redis = getJedis();
+            redis.set(key, value);
+        } finally {
+            if (redis != null) {
+                redis.close();
+            }
+        }
+
+    }
+
     /**
      * 删除记录
      *

+ 54 - 0
java110-utils/src/main/java/com/java110/utils/cache/PrivilegeCache.java

@@ -0,0 +1,54 @@
+package com.java110.utils.cache;
+
+import com.java110.dto.basePrivilege.BasePrivilegeDto;
+import com.java110.utils.util.SerializeUtil;
+import redis.clients.jedis.Jedis;
+
+import java.util.List;
+
+/**
+ * 映射缓存工具类
+ * Created by wuxw on 2018/4/14.
+ */
+public class PrivilegeCache extends BaseCache {
+
+    //后缀 用来刷缓存时删除 所有以这个为后缀的数据
+    public final static String DEFAULT_PRIVILEGE = "JAVA110_PRIVILEGE";
+
+
+    /**
+     * 获取 基础权限
+     *
+     * @return
+     */
+    public static List<BasePrivilegeDto> getPrivileges() {
+        Jedis redis = null;
+        try {
+            redis = getJedis();
+            return SerializeUtil.unserializeList(redis.get((DEFAULT_PRIVILEGE).getBytes()), BasePrivilegeDto.class);
+        } finally {
+            if (redis != null) {
+                redis.close();
+            }
+        }
+    }
+
+    /**
+     * 保存list 数据
+     *
+     * @param basePrivilegeDtos
+     */
+    public static void setValue(List<BasePrivilegeDto> basePrivilegeDtos) {
+        Jedis redis = null;
+        try {
+            redis = getJedis();
+            redis.set((DEFAULT_PRIVILEGE).getBytes(), SerializeUtil.serializeList(basePrivilegeDtos));
+        } finally {
+            if (redis != null) {
+                redis.close();
+            }
+        }
+    }
+
+
+}

+ 6 - 0
java110-utils/src/main/java/com/java110/utils/constant/CommonConstant.java

@@ -116,6 +116,12 @@ public class CommonConstant {
      */
     public final static String CACHE_MAPPING = "MAPPING";
 
+    /**
+     * 映射 缓存常量
+     */
+    public final static String CACHE_PRIVILEGE = "PRIVILEGE";
+
+
     /**
      * 映射 缓存常量
      */

+ 8 - 22
service-api/src/main/java/com/java110/api/listener/basePrivilege/CheckUserHasResourceListener.java

@@ -5,11 +5,10 @@ import com.java110.api.listener.AbstractServiceApiDataFlowListener;
 import com.java110.core.annotation.Java110Listener;
 import com.java110.core.context.DataFlowContext;
 import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.intf.community.IMenuInnerServiceSMO;
 import com.java110.dto.basePrivilege.BasePrivilegeDto;
 import com.java110.entity.center.AppService;
+import com.java110.intf.community.IMenuInnerServiceSMO;
 import com.java110.utils.constant.ServiceCodeConstant;
-import com.java110.utils.util.Assert;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -17,6 +16,9 @@ import org.springframework.http.HttpMethod;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * 检查用户是否有资源
  */
@@ -43,32 +45,16 @@ public class CheckUserHasResourceListener extends AbstractServiceApiDataFlowList
         DataFlowContext dataFlowContext = event.getDataFlowContext();
         AppService service = event.getAppService();
         JSONObject data = dataFlowContext.getReqJson();
-        Assert.hasKeyAndValue(data, "resource", "请求报文中未包含资源路径");
         logger.debug("请求信息:{}", data);
-        //Assert.hasKeyAndValue(data, "userId", "请求报文中未包含userId节点");
         ResponseEntity<String> responseEntity = null;
-
-        //判断资源路径是否配置权限 ,没有配置权限则都能访问
         BasePrivilegeDto basePrivilegeDto = new BasePrivilegeDto();
         basePrivilegeDto.setResource(data.getString("resource"));
-        int count = menuInnerServiceSMOImpl.queryBasePrivilegesCount(basePrivilegeDto);
-        //没有配置权限,都能访问
-        if (count < 1) {
-            responseEntity = new ResponseEntity<String>("校验成功,该资源路径未配置权限,建议开发者账户配置权限", HttpStatus.OK);
-            dataFlowContext.setResponseEntity(responseEntity);
-            return;
-        }
         basePrivilegeDto.setUserId(data.getString("userId"));
-        boolean checkFlag = menuInnerServiceSMOImpl.checkUserHasResource(basePrivilegeDto);
-
-        if (!checkFlag) {
-            responseEntity = new ResponseEntity<String>("没有权限操作", HttpStatus.UNAUTHORIZED);
-        } else {
-
-            responseEntity = new ResponseEntity<String>("成功", HttpStatus.OK);
-
-        }
+        List<Map> privileges = menuInnerServiceSMOImpl.checkUserHasResource(basePrivilegeDto);
 
+        data = new JSONObject();
+        data.put("privileges", privileges);
+        responseEntity = new ResponseEntity<String>(data.toJSONString(), HttpStatus.OK);
         dataFlowContext.setResponseEntity(responseEntity);
     }
 

+ 1 - 1
service-community/src/main/java/com/java110/community/dao/IMenuServiceDao.java

@@ -91,7 +91,7 @@ public interface IMenuServiceDao {
      */
     int queryBasePrivilegesCount(Map info);
 
-    boolean checkUserHasResource(Map info);
+    List<Map> checkUserHasResource(Map info);
 
 
     /**

+ 3 - 5
service-community/src/main/java/com/java110/community/dao/impl/MenuServiceDaoImpl.java

@@ -185,14 +185,12 @@ public class MenuServiceDaoImpl extends BaseServiceDao implements IMenuServiceDa
     }
 
     @Override
-    public boolean checkUserHasResource(Map info) {
+    public List<Map> checkUserHasResource(Map info) {
         logger.debug("查询路由信息 入参 info : {}", info);
 
         List<Map> businessBasePrivilegeInfos = sqlSessionTemplate.selectList("menuServiceDaoImpl.checkUserHasResource", info);
-        if (businessBasePrivilegeInfos != null && businessBasePrivilegeInfos.size() > 0) {
-            return true;
-        }
-        return false;
+
+        return businessBasePrivilegeInfos;
     }
 
 

+ 2 - 1
service-community/src/main/java/com/java110/community/smo/impl/MenuInnerServiceSMOImpl.java

@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @ClassName FloorInnerServiceSMOImpl
@@ -125,7 +126,7 @@ public class MenuInnerServiceSMOImpl extends BaseServiceSMO implements IMenuInne
      * @return 小区下的小区楼记录数
      */
     @RequestMapping(value = "/checkUserHasResource", method = RequestMethod.POST)
-    public boolean checkUserHasResource(@RequestBody BasePrivilegeDto basePrivilegeDto) {
+    public List<Map> checkUserHasResource(@RequestBody BasePrivilegeDto basePrivilegeDto) {
         return menuServiceDaoImpl.checkUserHasResource(BeanConvertUtil.beanCovertMap(basePrivilegeDto));
     }
 

+ 7 - 4
service-front/src/main/java/com/java110/front/FrontServiceApplicationStart.java

@@ -30,6 +30,11 @@ import java.nio.charset.Charset;
  * @mail 928255095@qq.com
  * @date 2016年8月6日
  * @tag
+ *
+ * , excludeFilters =
+ *         {
+ *                 @ComponentScan.Filter(type = FilterType.REGEX,pattern = "com.java110.core.smo.*")
+ *         }
  */
 @SpringBootApplication
 @ComponentScan(basePackages = { "com.java110.service.configuration",
@@ -37,13 +42,11 @@ import java.nio.charset.Charset;
         "com.java110.front",
         "com.java110.core",
         "com.java110.config.properties.code",
-        "com.java110.report"},excludeFilters =
-        {
-                @ComponentScan.Filter(type = FilterType.REGEX,pattern = "com.java110.core.smo.*")
-        })
+        "com.java110.report"})
 @EnableDiscoveryClient
 //@EnableConfigurationProperties(EventProperties.class)
 @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
+@EnableCaching
 public class FrontServiceApplicationStart {
 
     private static Logger logger = LoggerFactory.getLogger(FrontServiceApplicationStart.class);

+ 10 - 2
service-front/src/main/java/com/java110/front/smo/impl/PrivilegeServiceSMOImpl.java

@@ -4,10 +4,12 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.component.BaseComponentSMO;
 import com.java110.core.context.IPageData;
+import com.java110.core.smo.IGetCommunityStoreInfoSMO;
 import com.java110.front.smo.IPrivilegeServiceSMO;
 import com.java110.utils.constant.ServiceConstant;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.StringUtil;
+import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpMethod;
 import org.springframework.http.HttpStatus;
@@ -21,6 +23,9 @@ public class PrivilegeServiceSMOImpl extends BaseComponentSMO implements IPrivil
     @Autowired
     private RestTemplate restTemplate;
 
+    @Autowired
+    private IGetCommunityStoreInfoSMO getCommunityStoreInfoSMOImpl;
+
     /**
      * 查询 权限组
      *
@@ -339,8 +344,11 @@ public class PrivilegeServiceSMOImpl extends BaseComponentSMO implements IPrivil
         String storeId = storeInfoObj.getString("storeId");
         privilegeInfoObj.put("storeId", storeId);
 
-        ResponseEntity<String> privilegeGroup = super.callCenterService(restTemplate, pd, "",
-                ServiceConstant.SERVICE_API_URL + "/api/query.user.privilege?userId=" + privilegeInfoObj.getString("staffId") + "&domain=" + storeInfoObj.getString("storeTypeCd"), HttpMethod.GET);
+//        ResponseEntity<String> privilegeGroup = super.callCenterService(restTemplate, pd, "",
+//                ServiceConstant.SERVICE_API_URL + "/api/query.user.privilege?userId=" + privilegeInfoObj.getString("staffId") + "&domain=" + storeInfoObj.getString("storeTypeCd"), HttpMethod.GET);
+
+        ResultVo resultVo = getCommunityStoreInfoSMOImpl.getUserPrivileges(pd, privilegeInfoObj.getString("staffId"), storeInfoObj.getString("storeTypeCd"), restTemplate);
+        ResponseEntity<String> privilegeGroup = new ResponseEntity<>(resultVo.getMsg(), resultVo.getCode() == ResultVo.CODE_OK ? HttpStatus.OK : HttpStatus.BAD_REQUEST);
         if (privilegeGroup.getStatusCode() != HttpStatus.OK) {
             return privilegeGroup;
         }

+ 8 - 0
service-order/src/main/java/com/java110/order/dao/ICenterServiceDAO.java

@@ -1,5 +1,6 @@
 package com.java110.order.dao;
 
+import com.java110.dto.basePrivilege.BasePrivilegeDto;
 import com.java110.utils.exception.DAOException;
 import com.java110.entity.mapping.Mapping;
 
@@ -203,6 +204,13 @@ public interface ICenterServiceDAO {
      */
     public List<Mapping> getMappingInfoAll();
 
+    /**
+     * 查询映射表
+     *
+     * @return
+     */
+    public List<BasePrivilegeDto> getPrivilegeAll();
+
     /**
      * 查询业主 添加 修改 删除订单
      *

+ 6 - 0
service-order/src/main/java/com/java110/order/dao/impl/CenterServiceDAOImpl.java

@@ -2,6 +2,7 @@ package com.java110.order.dao.impl;
 
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.base.dao.BaseServiceDao;
+import com.java110.dto.basePrivilege.BasePrivilegeDto;
 import com.java110.entity.mapping.Mapping;
 import com.java110.order.dao.ICenterServiceDAO;
 import com.java110.utils.constant.ResponseConstant;
@@ -350,6 +351,11 @@ public class CenterServiceDAOImpl extends BaseServiceDao implements ICenterServi
         return sqlSessionTemplate.selectList("centerServiceDAOImpl.getMappingInfoAll");
     }
 
+    @Override
+    public List<BasePrivilegeDto> getPrivilegeAll() {
+        return sqlSessionTemplate.selectList("centerServiceDAOImpl.getPrivilegeAll");
+    }
+
     /**
      * 查询业主订单
      *

+ 108 - 61
service-order/src/main/java/com/java110/order/smo/impl/CenterServiceCacheSMOImpl.java

@@ -1,23 +1,21 @@
 package com.java110.order.smo.impl;
 
 import com.alibaba.fastjson.JSONObject;
-import com.java110.utils.cache.ServiceBusinessCache;
+import com.java110.core.factory.DataTransactionFactory;
+import com.java110.db.dao.IQueryServiceDAO;
+import com.java110.dto.basePrivilege.BasePrivilegeDto;
+import com.java110.entity.center.AppRoute;
+import com.java110.entity.mapping.Mapping;
 import com.java110.entity.order.ServiceBusiness;
+import com.java110.entity.service.ServiceSql;
 import com.java110.order.dao.ICenterServiceDAO;
 import com.java110.order.smo.ICenterServiceCacheSMO;
-import com.java110.utils.cache.AppRouteCache;
-import com.java110.utils.cache.MappingCache;
-import com.java110.utils.cache.ServiceSqlCache;
+import com.java110.service.context.DataQuery;
+import com.java110.utils.cache.*;
 import com.java110.utils.constant.CommonConstant;
 import com.java110.utils.constant.ResponseConstant;
 import com.java110.utils.exception.SMOException;
 import com.java110.utils.util.Assert;
-import com.java110.core.factory.DataTransactionFactory;
-import com.java110.entity.center.AppRoute;
-import com.java110.entity.mapping.Mapping;
-import com.java110.service.context.DataQuery;
-import com.java110.entity.service.ServiceSql;
-import com.java110.db.dao.IQueryServiceDAO;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -44,8 +42,7 @@ public class CenterServiceCacheSMOImpl implements ICenterServiceCacheSMO {
     IQueryServiceDAO queryServiceDAOImpl;
 
     @Override
-    public void flush(DataQuery dataQuery) throws SMOException{
-
+    public void flush(DataQuery dataQuery) throws SMOException {
 
 
         //1.0 封装 AppRoute
@@ -60,14 +57,18 @@ public class CenterServiceCacheSMOImpl implements ICenterServiceCacheSMO {
         //4.0 刷新业务信息
         flushServiceBusiness(dataQuery);
 
-        dataQuery.setResponseInfo(DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_SUCCESS,"刷新成功"));
+        //5.0 刷新基础权限
+        flushPrivilege(dataQuery);
+
+        dataQuery.setResponseInfo(DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_SUCCESS, "刷新成功"));
     }
 
     /**
      * 根据缓存类别刷新缓存
+     *
      * @param headers 缓存类别
      */
-    public void flush(Map<String,String> headers) throws SMOException{
+    public void flush(Map<String, String> headers) throws SMOException {
 
         flushAppRoute(headers);
 
@@ -78,6 +79,9 @@ public class CenterServiceCacheSMOImpl implements ICenterServiceCacheSMO {
 
         //4.0 刷新业务信息
         flushServiceBusiness(headers);
+
+        //5.0 刷新基础权限
+        flushPrivilege(headers);
     }
 
     /**
@@ -95,22 +99,27 @@ public class CenterServiceCacheSMOImpl implements ICenterServiceCacheSMO {
         doFlushServiceSql();
 
         doFlushServiceBusiness();
+
+        //5.0 刷新全新
+        doFlushPrivilege();
     }
 
-    private void checkCacheParam(DataQuery dataQuery) throws SMOException{
+
+    private void checkCacheParam(DataQuery dataQuery) throws SMOException {
         JSONObject params = dataQuery.getRequestParams();
-        if(params == null || !params.containsKey(CommonConstant.CACHE_PARAM_NAME)){
-            throw new SMOException(ResponseConstant.RESULT_PARAM_ERROR,"请求报文错误,未包含字段 "+CommonConstant.CACHE_PARAM_NAME);
+        if (params == null || !params.containsKey(CommonConstant.CACHE_PARAM_NAME)) {
+            throw new SMOException(ResponseConstant.RESULT_PARAM_ERROR, "请求报文错误,未包含字段 " + CommonConstant.CACHE_PARAM_NAME);
         }
     }
+
     /**
      * 3.0 分装 ServiceSql
      */
     private void flushServiceSql(DataQuery dataQuery) {
 
         JSONObject params = dataQuery.getRequestParams();
-        if(!CommonConstant.CACHE_SERVICE_SQL.equals(params.getString(CommonConstant.CACHE_PARAM_NAME))){
-            return ;
+        if (!CommonConstant.CACHE_SERVICE_SQL.equals(params.getString(CommonConstant.CACHE_PARAM_NAME))) {
+            return;
         }
         // 刷新
         doFlushServiceSql();
@@ -119,8 +128,8 @@ public class CenterServiceCacheSMOImpl implements ICenterServiceCacheSMO {
     private void flushServiceBusiness(DataQuery dataQuery) {
 
         JSONObject params = dataQuery.getRequestParams();
-        if(!CommonConstant.CACHE_SERVICE_BUSINESS.equals(params.getString(CommonConstant.CACHE_PARAM_NAME))){
-            return ;
+        if (!CommonConstant.CACHE_SERVICE_BUSINESS.equals(params.getString(CommonConstant.CACHE_PARAM_NAME))) {
+            return;
         }
         // 刷新
         doFlushServiceBusiness();
@@ -129,12 +138,12 @@ public class CenterServiceCacheSMOImpl implements ICenterServiceCacheSMO {
     /**
      * 3.0 分装 ServiceSql
      */
-    private void flushServiceSql(Map<String,String> headers) {
+    private void flushServiceSql(Map<String, String> headers) {
 
-        Assert.hasKey(headers,CommonConstant.CACHE_PARAM,"未包含cache参数"+headers.toString());
-        if(!CommonConstant.CACHE_SERVICE_SQL.equals(headers.get(CommonConstant.CACHE_PARAM))
-                && !CommonConstant.CACHE_ALL.equals(headers.get(CommonConstant.CACHE_PARAM))){
-            return ;
+        Assert.hasKey(headers, CommonConstant.CACHE_PARAM, "未包含cache参数" + headers.toString());
+        if (!CommonConstant.CACHE_SERVICE_SQL.equals(headers.get(CommonConstant.CACHE_PARAM))
+                && !CommonConstant.CACHE_ALL.equals(headers.get(CommonConstant.CACHE_PARAM))) {
+            return;
         }
         // 刷新
         doFlushServiceSql();
@@ -143,12 +152,12 @@ public class CenterServiceCacheSMOImpl implements ICenterServiceCacheSMO {
     /**
      * 3.0 分装 ServiceSql
      */
-    private void flushServiceBusiness(Map<String,String> headers) {
+    private void flushServiceBusiness(Map<String, String> headers) {
 
-        Assert.hasKey(headers,CommonConstant.CACHE_PARAM,"未包含cache参数"+headers.toString());
-        if(!CommonConstant.CACHE_SERVICE_BUSINESS.equals(headers.get(CommonConstant.CACHE_PARAM))
-                && !CommonConstant.CACHE_ALL.equals(headers.get(CommonConstant.CACHE_PARAM))){
-            return ;
+        Assert.hasKey(headers, CommonConstant.CACHE_PARAM, "未包含cache参数" + headers.toString());
+        if (!CommonConstant.CACHE_SERVICE_BUSINESS.equals(headers.get(CommonConstant.CACHE_PARAM))
+                && !CommonConstant.CACHE_ALL.equals(headers.get(CommonConstant.CACHE_PARAM))) {
+            return;
         }
         // 刷新
         doFlushServiceBusiness();
@@ -160,22 +169,22 @@ public class CenterServiceCacheSMOImpl implements ICenterServiceCacheSMO {
 
         List<ServiceSql> serviceSqls = queryServiceDAOImpl.qureyServiceSqlAll();
 
-        if(serviceSqls == null || serviceSqls.size() == 0){
+        if (serviceSqls == null || serviceSqls.size() == 0) {
             return;
         }
         //删除原始数据
         ServiceSqlCache.removeData(ServiceSqlCache._SUFFIX_SERVICE_SQL);
 
-        for(ServiceSql serviceSql: serviceSqls){
+        for (ServiceSql serviceSql : serviceSqls) {
             ServiceSqlCache.setServiceSql(serviceSql);
         }
     }
 
-    private void doFlushServiceBusiness(){
+    private void doFlushServiceBusiness() {
         logger.debug("开始刷新 ServiceBusiness数据到redis数据库中");
         List<ServiceBusiness> serviceBusinesses = queryServiceDAOImpl.qureyServiceBusiness();
 
-        if(serviceBusinesses == null || serviceBusinesses.size() == 0){
+        if (serviceBusinesses == null || serviceBusinesses.size() == 0) {
             return;
         }
         //删除原始数据
@@ -193,23 +202,53 @@ public class CenterServiceCacheSMOImpl implements ICenterServiceCacheSMO {
 
         JSONObject params = dataQuery.getRequestParams();
 
-        if(!CommonConstant.CACHE_MAPPING.equals(params.getString(CommonConstant.CACHE_PARAM_NAME))){
-            return ;
+        if (!CommonConstant.CACHE_MAPPING.equals(params.getString(CommonConstant.CACHE_PARAM_NAME))) {
+            return;
         }
 
         doFlushMapping();
     }
 
+
+    /**
+     * 刷新 Mapping 数据
+     */
+    private void flushPrivilege(DataQuery dataQuery) {
+
+        JSONObject params = dataQuery.getRequestParams();
+
+        if (!CommonConstant.CACHE_PRIVILEGE.equals(params.getString(CommonConstant.CACHE_PARAM_NAME))) {
+            return;
+        }
+
+        doFlushPrivilege();
+    }
+
+    /**
+     * 刷新 Mapping 数据
+     */
+    private void flushPrivilege(Map<String, String> headers) {
+
+        Assert.hasKey(headers, CommonConstant.CACHE_PARAM, "未包含cache参数" + headers.toString());
+
+        if (!CommonConstant.CACHE_PRIVILEGE.equals(headers.get(CommonConstant.CACHE_PARAM))
+                && !CommonConstant.CACHE_ALL.equals(headers.get(CommonConstant.CACHE_PARAM))) {
+            return;
+        }
+
+        doFlushPrivilege();
+    }
+
     /**
      * 刷新 Mapping 数据
      */
-    private void flushMapping(Map<String,String> headers) {
+    private void flushMapping(Map<String, String> headers) {
 
-        Assert.hasKey(headers,CommonConstant.CACHE_PARAM,"未包含cache参数"+headers.toString());
+        Assert.hasKey(headers, CommonConstant.CACHE_PARAM, "未包含cache参数" + headers.toString());
 
-        if(!CommonConstant.CACHE_MAPPING.equals(headers.get(CommonConstant.CACHE_PARAM))
-                && !CommonConstant.CACHE_ALL.equals(headers.get(CommonConstant.CACHE_PARAM))){
-            return ;
+        if (!CommonConstant.CACHE_MAPPING.equals(headers.get(CommonConstant.CACHE_PARAM))
+                && !CommonConstant.CACHE_ALL.equals(headers.get(CommonConstant.CACHE_PARAM))) {
+            return;
         }
 
         doFlushMapping();
@@ -220,20 +259,20 @@ public class CenterServiceCacheSMOImpl implements ICenterServiceCacheSMO {
         List<Mapping> mappings = centerServiceDAOImpl.getMappingInfoAll();
         //删除原始数据
         MappingCache.removeData(MappingCache._SUFFIX_MAPPING);
-        for(Mapping mapping : mappings){
+        for (Mapping mapping : mappings) {
             MappingCache.setVaule(mapping);
         }
 
-        Map<String,List<Mapping>> mappingMap = new HashMap<String,List<Mapping>>();
+        Map<String, List<Mapping>> mappingMap = new HashMap<String, List<Mapping>>();
         List<Mapping> mappingsNew = null;
-        for(Mapping mapping : mappings){
-            if(mappingMap.containsKey(mapping.getDomain())){
+        for (Mapping mapping : mappings) {
+            if (mappingMap.containsKey(mapping.getDomain())) {
                 mappingsNew = mappingMap.get(mapping.getDomain());
                 mappingsNew.add(mapping);
-            }else{
+            } else {
                 mappingsNew = new ArrayList<Mapping>();
                 mappingsNew.add(mapping);
-                mappingMap.put(mapping.getDomain(),mappingsNew);
+                mappingMap.put(mapping.getDomain(), mappingsNew);
             }
         }
 
@@ -242,15 +281,23 @@ public class CenterServiceCacheSMOImpl implements ICenterServiceCacheSMO {
         }
     }
 
+    private void doFlushPrivilege() {
+        logger.debug("开始刷新 Mapping数据到redis数据库中");
+        List<BasePrivilegeDto> basePrivilegeDtos = centerServiceDAOImpl.getPrivilegeAll();
+        //删除原始数据
+        PrivilegeCache.removeData(PrivilegeCache.DEFAULT_PRIVILEGE);
+        PrivilegeCache.setValue(basePrivilegeDtos);
+    }
+
     /**
      * 刷新AppRoute数据
      */
-    private void flushAppRoute(DataQuery dataQuery){
+    private void flushAppRoute(DataQuery dataQuery) {
 
         JSONObject params = dataQuery.getRequestParams();
 
-        if(!CommonConstant.CACHE_APP_ROUTE_SERVICE.equals(params.getString(CommonConstant.CACHE_PARAM_NAME))){
-            return ;
+        if (!CommonConstant.CACHE_APP_ROUTE_SERVICE.equals(params.getString(CommonConstant.CACHE_PARAM_NAME))) {
+            return;
         }
         doFlushAppRoute();
 
@@ -259,13 +306,13 @@ public class CenterServiceCacheSMOImpl implements ICenterServiceCacheSMO {
     /**
      * 刷新AppRoute数据
      */
-    private void flushAppRoute(Map<String,String> headers){
+    private void flushAppRoute(Map<String, String> headers) {
 
-        Assert.hasKey(headers,CommonConstant.CACHE_PARAM,"未包含cache参数"+headers.toString());
+        Assert.hasKey(headers, CommonConstant.CACHE_PARAM, "未包含cache参数" + headers.toString());
 
-        if(!CommonConstant.CACHE_APP_ROUTE_SERVICE.equals(headers.get(CommonConstant.CACHE_PARAM))
-                && !CommonConstant.CACHE_ALL.equals(headers.get(CommonConstant.CACHE_PARAM))){
-            return ;
+        if (!CommonConstant.CACHE_APP_ROUTE_SERVICE.equals(headers.get(CommonConstant.CACHE_PARAM))
+                && !CommonConstant.CACHE_ALL.equals(headers.get(CommonConstant.CACHE_PARAM))) {
+            return;
         }
         doFlushAppRoute();
 
@@ -274,16 +321,16 @@ public class CenterServiceCacheSMOImpl implements ICenterServiceCacheSMO {
     private void doFlushAppRoute() {
         logger.debug("开始刷新 AppRoute数据到redis数据库中");
         List<Map> appInfos = centerServiceDAOImpl.getAppRouteAndServiceInfoAll();
-        Map<String,List<AppRoute>> appRoustsMap = new HashMap<String,List<AppRoute>>();
+        Map<String, List<AppRoute>> appRoustsMap = new HashMap<String, List<AppRoute>>();
         List<AppRoute> appRoutes = null;
-        for(Map appInfo : appInfos){
-            if(appRoustsMap.containsKey(appInfo.get("app_id").toString())){
+        for (Map appInfo : appInfos) {
+            if (appRoustsMap.containsKey(appInfo.get("app_id").toString())) {
                 appRoutes = appRoustsMap.get(appInfo.get("app_id").toString());
                 appRoutes.add(AppRoute.newInstance().builder(appInfo));
-            }else{
+            } else {
                 appRoutes = new ArrayList<AppRoute>();
                 appRoutes.add(AppRoute.newInstance().builder(appInfo));
-                appRoustsMap.put(appInfo.get("app_id").toString(),appRoutes);
+                appRoustsMap.put(appInfo.get("app_id").toString(), appRoutes);
             }
         }
         //删除原始数据