From 8c0b835bb2f99ca503879ec5052fe435dc6225be Mon Sep 17 00:00:00 2001 From: "wangiegie@gmail.com" Date: Wed, 15 Nov 2017 09:30:08 +0800 Subject: [PATCH] =?UTF-8?q?fixed=EF=BC=9A=20@CacheEvict(value=20=3D=20"men?= =?UTF-8?q?u=5Fdetails",allEntries=20=3D=20true)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/github/pig/admin/controller/MenuController.java | 3 +++ .../java/com/github/pig/admin/controller/RoleController.java | 2 +- .../com/github/pig/admin/service/impl/SysMenuServiceImpl.java | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pig-admin-service/src/main/java/com/github/pig/admin/controller/MenuController.java b/pig-admin-service/src/main/java/com/github/pig/admin/controller/MenuController.java index cac55198..f8e2cc6d 100644 --- a/pig-admin-service/src/main/java/com/github/pig/admin/controller/MenuController.java +++ b/pig-admin-service/src/main/java/com/github/pig/admin/controller/MenuController.java @@ -9,6 +9,7 @@ import com.github.pig.common.constant.CommonConstant; import com.github.pig.common.vo.MenuVo; import com.github.pig.common.web.BaseController; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; @@ -93,6 +94,7 @@ public class MenuController extends BaseController { * TODO 级联删除下级节点 */ @DeleteMapping("/{id}") + @CacheEvict(value = "menu_details",allEntries = true) public Boolean menuDel(@PathVariable Integer id) { // 删除当前节点 SysMenu condition1 = new SysMenu(); @@ -110,6 +112,7 @@ public class MenuController extends BaseController { } @PutMapping + @CacheEvict(value = "menu_details",allEntries = true) public Boolean menuUpdate(@RequestBody SysMenu sysMenu) { return menuService.updateById(sysMenu); } diff --git a/pig-admin-service/src/main/java/com/github/pig/admin/controller/RoleController.java b/pig-admin-service/src/main/java/com/github/pig/admin/controller/RoleController.java index 7ba62f57..593b11cb 100644 --- a/pig-admin-service/src/main/java/com/github/pig/admin/controller/RoleController.java +++ b/pig-admin-service/src/main/java/com/github/pig/admin/controller/RoleController.java @@ -104,7 +104,7 @@ public class RoleController extends BaseController { * @return success、false */ @PutMapping("/roleMenuUpd") - @CacheEvict(value = "menu_details", key = "#role +'_menu'") + @CacheEvict(value = "menu_details",allEntries = true) public Boolean roleMenuUpd(Integer roleId, @RequestParam("menuIds[]") Integer[] menuIds) { SysRoleMenu condition = new SysRoleMenu(); condition.setRoleId(roleId); diff --git a/pig-admin-service/src/main/java/com/github/pig/admin/service/impl/SysMenuServiceImpl.java b/pig-admin-service/src/main/java/com/github/pig/admin/service/impl/SysMenuServiceImpl.java index cb1ff598..bfe7726d 100644 --- a/pig-admin-service/src/main/java/com/github/pig/admin/service/impl/SysMenuServiceImpl.java +++ b/pig-admin-service/src/main/java/com/github/pig/admin/service/impl/SysMenuServiceImpl.java @@ -7,6 +7,7 @@ import com.github.pig.admin.service.SysMenuService; import com.github.pig.common.vo.MenuVo; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import java.util.HashSet; @@ -26,7 +27,7 @@ public class SysMenuServiceImpl extends ServiceImpl impl private SysMenuMapper sysMenuMapper; @Override - //@Cacheable(value = "menu_details", key = "#role +'_menu'") + @Cacheable(value = "menu_details", key = "#role + #type + '_menu'") public Set findMenuByRole(String role, Integer type) { return sysMenuMapper.findMenuByRoleName(role, type); }