fixed: @CacheEvict(value = "menu_details",allEntries = true)

This commit is contained in:
wangiegie@gmail.com 2017-11-15 09:30:08 +08:00
parent fb5489d617
commit 8c0b835bb2
3 changed files with 6 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import com.github.pig.common.constant.CommonConstant;
import com.github.pig.common.vo.MenuVo; import com.github.pig.common.vo.MenuVo;
import com.github.pig.common.web.BaseController; import com.github.pig.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -93,6 +94,7 @@ public class MenuController extends BaseController {
* TODO 级联删除下级节点 * TODO 级联删除下级节点
*/ */
@DeleteMapping("/{id}") @DeleteMapping("/{id}")
@CacheEvict(value = "menu_details",allEntries = true)
public Boolean menuDel(@PathVariable Integer id) { public Boolean menuDel(@PathVariable Integer id) {
// 删除当前节点 // 删除当前节点
SysMenu condition1 = new SysMenu(); SysMenu condition1 = new SysMenu();
@ -110,6 +112,7 @@ public class MenuController extends BaseController {
} }
@PutMapping @PutMapping
@CacheEvict(value = "menu_details",allEntries = true)
public Boolean menuUpdate(@RequestBody SysMenu sysMenu) { public Boolean menuUpdate(@RequestBody SysMenu sysMenu) {
return menuService.updateById(sysMenu); return menuService.updateById(sysMenu);
} }

View File

@ -104,7 +104,7 @@ public class RoleController extends BaseController {
* @return successfalse * @return successfalse
*/ */
@PutMapping("/roleMenuUpd") @PutMapping("/roleMenuUpd")
@CacheEvict(value = "menu_details", key = "#role +'_menu'") @CacheEvict(value = "menu_details",allEntries = true)
public Boolean roleMenuUpd(Integer roleId, @RequestParam("menuIds[]") Integer[] menuIds) { public Boolean roleMenuUpd(Integer roleId, @RequestParam("menuIds[]") Integer[] menuIds) {
SysRoleMenu condition = new SysRoleMenu(); SysRoleMenu condition = new SysRoleMenu();
condition.setRoleId(roleId); condition.setRoleId(roleId);

View File

@ -7,6 +7,7 @@ import com.github.pig.admin.service.SysMenuService;
import com.github.pig.common.vo.MenuVo; import com.github.pig.common.vo.MenuVo;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashSet; import java.util.HashSet;
@ -26,7 +27,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
private SysMenuMapper sysMenuMapper; private SysMenuMapper sysMenuMapper;
@Override @Override
//@Cacheable(value = "menu_details", key = "#role +'_menu'") @Cacheable(value = "menu_details", key = "#role + #type + '_menu'")
public Set<MenuVo> findMenuByRole(String role, Integer type) { public Set<MenuVo> findMenuByRole(String role, Integer type) {
return sysMenuMapper.findMenuByRoleName(role, type); return sysMenuMapper.findMenuByRoleName(role, type);
} }