Browse Source

Merge branch 'master' of http://git.zthymaoyi.com/gongdc/gubi

achao 1 year ago
parent
commit
f47804eefd

+ 3 - 0
unimall-admin-api/src/main/java/com/iotechn/unimall/admin/api/gubi/IGubiTypeInfoService.java

@@ -21,6 +21,9 @@ import java.util.List;
  */
 @HttpOpenApi(group = "admin.gubi.gubiTypeInfo", description = "一级分类")
 public interface IGubiTypeInfoService {
+    @HttpMethod(description = "清缓存")
+    public void clearCache();
+
     @HttpMethod(description = "新增")
     public Boolean add(@NotNull @HttpParam(name = "gubiTypeInfo", type = HttpParamType.COMMON, description = "一级分类") GubiTypeInfo gubiTypeInfo,
                        @HttpParam(name = "adminId", type = HttpParamType.ADMIN_ID, description = "adminId") Long adminId) throws ServiceException;

+ 20 - 0
unimall-admin-api/src/main/java/com/iotechn/unimall/admin/api/gubi/impl/GubiTypeInfoServiceImpl.java

@@ -2,10 +2,13 @@ package com.iotechn.unimall.admin.api.gubi.impl;
 
 import java.util.List;
 
+import com.alibaba.fastjson.JSONObject;
+import com.iotechn.unimall.data.component.CacheComponent;
 import com.iotechn.unimall.data.domain.gubi.GubiTypeSecond;
 import com.iotechn.unimall.data.domain.gubi.GubiTypeThree;
 import com.iotechn.unimall.data.mapper.gubi.GubiTypeSecondMapper;
 import com.iotechn.unimall.data.mapper.gubi.GubiTypeThreeMapper;
+import com.iotechn.unimall.data.util.Const;
 import org.apache.ibatis.session.RowBounds;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -39,7 +42,18 @@ public class GubiTypeInfoServiceImpl implements IGubiTypeInfoService {
     private GubiTypeSecondMapper gubiTypeSecondMapper;
     @Autowired
     private GubiTypeThreeMapper gubiTypeThreeMapper;
+    @Autowired
+    private CacheComponent cacheComponent;
+
 
+    //清理所有Redis缓存
+    public void clearCache() {
+        cacheComponent.delPrefixKey(Const.SELF_WAREHOUSE);
+        cacheComponent.delPrefixKey(Const.ADMIN_WEIGHINGINFO);
+        cacheComponent.delPrefixKey(Const.ADMIN_WEIGHINGINFO_NUM);
+        cacheComponent.delPrefixKey(Const.ADMIN_CONTRACTINFO);
+        cacheComponent.delPrefixKey(Const.ADMIN_BI_INFO);
+    }
     @Override
     public Boolean add(GubiTypeInfo gubiTypeInfo, Long adminId) throws ServiceException {
         Date now = new Date();
@@ -86,6 +100,10 @@ public class GubiTypeInfoServiceImpl implements IGubiTypeInfoService {
     }
 
     public List<GubiTypeInfo> listInfo() {
+        List<GubiTypeInfo> listRedis = cacheComponent.getObjList(Const.ADMIN_BI_INFO, GubiTypeInfo.class);
+        if (listRedis != null && listRedis.size() > 0) {
+            return listRedis;
+        }
         List<GubiTypeInfo> list = gubiTypeInfoMapper.selectList(new EntityWrapper<GubiTypeInfo>()
                 .eq("delete_flag", "0")
                 .orderBy("postion"));
@@ -108,6 +126,8 @@ public class GubiTypeInfoServiceImpl implements IGubiTypeInfoService {
             }
 
         }
+        cacheComponent.putRaw(Const.ADMIN_BI_INFO , JSONObject.toJSONString(list), 60 * 60);
+
         return list;
     }
 

+ 47 - 0
unimall-data/src/main/java/com/iotechn/unimall/data/util/Const.java

@@ -0,0 +1,47 @@
+package com.iotechn.unimall.data.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created with IntelliJ IDEA.
+ * Description:
+ * User: rize
+ * Date: 2018-08-11
+ * Time: 下午11:43
+ */
+public class Const {
+
+    public static  List<Class> IGNORE_PARAM_LIST = new ArrayList<>();
+
+    static {
+        IGNORE_PARAM_LIST.add(Integer.class);
+        IGNORE_PARAM_LIST.add(Long.class);
+        IGNORE_PARAM_LIST.add(String.class);
+        IGNORE_PARAM_LIST.add(Float.class);
+        IGNORE_PARAM_LIST.add(Double.class);
+        IGNORE_PARAM_LIST.add(Boolean.class);
+    }
+
+    public static  Integer CACHE_ONE_DAY = 60 * 60 * 24;
+
+
+    public static final String USER_ACCESS_TOKEN = "ACCESSTOKEN";
+
+    public static final String USER_REDIS_PREFIX = "USER_SESSION_";
+
+    public static final String ADMIN_ACCESS_TOKEN = "ADMINTOKEN";
+
+    public static final String ADMIN_REDIS_PREFIX = "ADMIN_SESSION_";
+
+    public static final String SELF_WAREHOUSE = "SELF_WAREHOUSE_";
+
+    public static final String ADMIN_CONTRACTINFO = "ADMIN_CONTRACTINFO_";
+    public static final String ADMIN_WEIGHINGINFO = "ADMIN_WEIGHINGINFO_";
+    public static final String ADMIN_WEIGHINGINFO_NUM = "ADMIN_WEIGHINGINFO_NUM_";
+    public static final String ADMIN_BI_INFO = "ADMIN_BI_INFO_";
+    public static final String ADMIN_WAREHOUSEINFO = "ADMIN_WAREHOUSEINFO_";
+    public static final String ADMIN_WAREHOUSEINFO_NUM = "ADMIN_WAREHOUSEINFO_NUM_";
+    public static final String ADMIN_WAREHOUSEINFOCHAR = "ADMIN_WAREHOUSEINFOCHAR_";
+    public static final String ADMIN_WAREHOUSEINFOFORM = "ADMIN_WAREHOUSEINFOFORM_";
+}