月球大数据地理空间分析展示平台-【后端】-月球后台服务
13693261870
2023-08-08 3b1af08ca296f9cecc1944dd282031cc684fba23
图层控制器、角色图层控制器添加缓存功能
已修改5个文件
70 ■■■■■ 文件已修改
src/main/java/com/moon/server/controller/sys/LayerController.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/moon/server/controller/sys/RoleLayerController.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/moon/server/controller/sys/RoleResController.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/moon/server/entity/all/RedisCacheKey.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/moon/server/service/all/PermsService.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/moon/server/controller/sys/LayerController.java
@@ -5,6 +5,7 @@
import com.moon.server.entity.all.ResponseMsg;
import com.moon.server.entity.sys.LayerEntity;
import com.moon.server.entity.sys.UserEntity;
import com.moon.server.service.all.PermsService;
import com.moon.server.service.sys.LayerService;
import com.moon.server.service.sys.TokenService;
import io.swagger.annotations.Api;
@@ -30,6 +31,9 @@
    @Autowired
    TokenService tokenService;
    @Autowired
    PermsService permsService;
    @SysLog()
    @ApiOperation(value = "分页查询并返回记录数")
@@ -101,6 +105,9 @@
            }
            int count = layerService.insert(entity);
            if (count > 0) {
                permsService.clearLayerCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -124,6 +131,9 @@
            }
            int count = layerService.inserts(list);
            if (count > 0) {
                permsService.clearLayerCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -140,6 +150,9 @@
    public ResponseMsg<Integer> delete(int id) {
        try {
            int count = layerService.delete(id);
            if (count > 0) {
                permsService.clearLayerCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -160,6 +173,9 @@
            }
            int count = layerService.deletes(ids);
            if (count > 0) {
                permsService.clearLayerCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -182,6 +198,9 @@
            }
            int count = layerService.update(entity);
            if (count > 0) {
                permsService.clearLayerCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -206,6 +225,9 @@
            }
            int count = layerService.updates(list);
            if (count > 0) {
                permsService.clearLayerCache();
            }
            return success(count);
        } catch (Exception ex) {
src/main/java/com/moon/server/controller/sys/RoleLayerController.java
@@ -6,6 +6,7 @@
import com.moon.server.entity.sys.RoleLayerEntity;
import com.moon.server.entity.sys.RoleResEntity;
import com.moon.server.entity.sys.UserEntity;
import com.moon.server.service.all.PermsService;
import com.moon.server.service.sys.RoleLayerService;
import com.moon.server.service.sys.TokenService;
import io.swagger.annotations.Api;
@@ -22,7 +23,7 @@
 * 角色-图层
 * @author WWW
 */
@Api(tags = "运维管理\\角色-图层")
@Api(tags = "运维管理\\角色图层")
@RestController
@RequestMapping("/roleLayer")
public class RoleLayerController extends BaseController {
@@ -31,6 +32,9 @@
    @Autowired
    TokenService tokenService;
    @Autowired
    PermsService permsService;
    @SysLog()
    @ApiOperation(value = "根据角色ID查询资源")
@@ -105,6 +109,9 @@
            }
            int count = roleLayerService.insert(entity);
            if (count > 0) {
                permsService.clearLayerCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -128,6 +135,9 @@
            }
            int count = roleLayerService.inserts(list);
            if (count > 0) {
                permsService.clearLayerCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -144,6 +154,9 @@
    public ResponseMsg<Integer> delete(int id) {
        try {
            int count = roleLayerService.delete(id);
            if (count > 0) {
                permsService.clearLayerCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -164,6 +177,9 @@
            }
            int count = roleLayerService.deletes(ids);
            if (count > 0) {
                permsService.clearLayerCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -186,6 +202,9 @@
            }
            int count = roleLayerService.update(entity);
            if (count > 0) {
                permsService.clearLayerCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -210,6 +229,9 @@
            }
            int count = roleLayerService.updates(list);
            if (count > 0) {
                permsService.clearLayerCache();
            }
            return success(count);
        } catch (Exception ex) {
src/main/java/com/moon/server/controller/sys/RoleResController.java
@@ -64,6 +64,7 @@
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            int count = roleResService.selectCount(roleid);
            if (count == 0) {
                return success(0, null);
src/main/java/com/moon/server/entity/all/RedisCacheKey.java
@@ -41,6 +41,13 @@
    }
    /**
     * 图层授权键
     */
    public static String permsLayerKey(String key) {
        return "perms:layer:" + key;
    }
    /**
     * 菜单授权键
     */
    public static String permsMenusKey(String key) {
src/main/java/com/moon/server/service/all/PermsService.java
@@ -96,14 +96,30 @@
        return permsMapper.selectMenuRecursive(id, uid);
    }
    /**
     * 清除资源缓存
     */
    public void clearResCache() {
        redisService.clearKeys(RedisCacheKey.permsResKey(""));
    }
    /**
     * 清除图层缓存
     */
    public void clearLayerCache() {
        redisService.clearKeys(RedisCacheKey.permsLayerKey(""));
    }
    /**
     * 清除权限缓存
     */
    public void clearPermsCache() {
        redisService.clearKeys(RedisCacheKey.permsRootKey());
    }
    /**
     * 清除所有缓存
     */
    public void clearAllCache() {
        redisService.clearAll();
    }