管道基础大数据平台系统开发-【后端】-Server
13693261870
2023-08-28 d565e050f3188fc729cb8178be7d5cc04844ce0d
修改清除缓存策略
已修改5个文件
106 ■■■■ 文件已修改
src/main/java/com/lf/server/controller/sys/ResController.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/sys/RoleResController.java 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/entity/all/StaticData.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/all/PermsService.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/all/TestService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/sys/ResController.java
@@ -151,10 +151,8 @@
                entity.setCreateUser(ue.getId());
            }
            permsService.clearPermsCache();
            int count = resService.insertRes(entity);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -177,10 +175,8 @@
                }
            }
            permsService.clearPermsCache();
            int count = resService.insertRess(list);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -196,10 +192,8 @@
    @GetMapping(value = "/deleteRes")
    public ResponseMsg<Integer> deleteRes(int id) {
        try {
            permsService.clearPermsCache();
            int count = resService.deleteRes(id);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -219,10 +213,8 @@
                return fail("id数组不能为空", -1);
            }
            permsService.clearPermsCache();
            int count = resService.deleteRess(ids);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -244,10 +236,8 @@
                entity.setUpdateUser(ue.getId());
            }
            permsService.clearPermsCache();
            int count = resService.updateRes(entity);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
src/main/java/com/lf/server/controller/sys/RoleResController.java
@@ -140,10 +140,8 @@
                entity.setCreateUser(ue.getId());
            }
            permsService.clearPermsCache();
            int count = roleResService.insert(entity);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -166,10 +164,8 @@
                }
            }
            permsService.clearPermsCache();
            int count = roleResService.inserts(list);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -185,10 +181,8 @@
    @GetMapping(value = "/delete")
    public ResponseMsg<Integer> delete(int id) {
        try {
            permsService.clearPermsCache();
            int count = roleResService.delete(id);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -208,10 +202,8 @@
                return fail("id数组不能为空", -1);
            }
            permsService.clearPermsCache();
            int count = roleResService.deletes(ids);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -233,10 +225,8 @@
                entity.setUpdateUser(ue.getId());
            }
            permsService.clearPermsCache();
            int count = roleResService.update(entity);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -260,10 +250,8 @@
                }
            }
            permsService.clearPermsCache();
            int count = roleResService.updates(list);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
src/main/java/com/lf/server/entity/all/StaticData.java
@@ -68,41 +68,20 @@
    public static final int I4490 = 4490;
    /**
     * 字符1
     */
    public final static String S1 = "1";
    /**
     * 等号
     */
    public final static String EQ = "=";
    /**
     * 字符点
     */
    public final static String POINT = ".";
    /**
     * 逗号
     */
    public final static String COMMA = ",";
    /**
     * 波浪号
     */
    public final static String TILDE = "~";
    /**
     * 单引号
     */
    public final static String SINGLE_QUOTES = "'";
    public final static String BBOREHOLE = "bborehole";
    /**
     * 正斜杠
     */
    public final static String SLASH = "/";
    public final static String IN = "in";
@@ -141,53 +120,26 @@
    public final static String SYS_META = "sysmeta";
    /**
     * 版本号
     */
    public final static String VERSION = "1.0.0";
    /**
     * 令牌键
     */
    public final static String TOKEN_KEY = "token";
    /**
     * Cookie中令牌键
     */
    public final static String TOKEN_COOKIE_KEY = "token";
    /**
     * 文本编码方式
     */
    public final static String TEXT_ENCODER = "UTF-8";
    /**
     * 总质检
     */
    public final static String CHECK_MAIN = "checkMain";
    /**
     * Object对象
     */
    public final static String OBJECT = "java.lang.Object";
    /**
     * Cookie中druid键
     */
    public final static String DRUID_COOKIE_KEY = "JSESSIONID";
    public final static String YES = "YES";
    public final static String NO = "NO";
    /**
     * 线路
     */
    public final static String ROUTE = "线路";
    /**
     * 穿跨越
     */
    public final static String CROSSING = "穿跨越";
    public final static String LINESTRING = "LINESTRING";
src/main/java/com/lf/server/service/all/PermsService.java
@@ -100,13 +100,17 @@
        redisService.clearKeys(RedisCacheKey.permsResKey(""));
    }
    /**
     * 清除授权缓存
     */
    public void clearPermsCache() {
        redisService.clearKeys(RedisCacheKey.permsMenusKey(""));
        redisService.clearKeys(RedisCacheKey.permsPermsKey(""));
        redisService.clearKeys(RedisCacheKey.permsPermsEntityKey(""));
        redisService.clearKeys(RedisCacheKey.permsRootKey());
    }
    /**
     * 清除所有缓存
     */
    public void clearAllCache() {
        redisService.clearKeys(RedisCacheKey.permsRootKey());
        redisService.clearAll();
    }
}
src/main/java/com/lf/server/service/all/TestService.java
@@ -197,7 +197,7 @@
        List<PermsAuthEntity> pauList = permsService.selectPermsEntity("admin");
        List<PermsAuthEntity> pauList2 = permsService.selectPermsEntity("admin");
        permsService.clearResCache();
        // permsService.clearResCache()
        permsService.clearPermsCache();
        raeList = permsService.selectRes("admin");