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); }