Esempio n. 1
0
 @Transactional(readOnly = false)
 public void saveMenu(Menu menu) {
   if (StringUtils.isEmpty(menu.getParent().getId())) {
     menu.setParent(this.get("1"));
   } else {
     menu.setParent(this.getMenu(menu.getParent().getId()));
   }
   String oldParentIds = menu.getParentIds(); // 获取修改前的parentIds,用于更新子节点的parentIds
   menu.setParentIds(menu.getParent().getParentIds() + menu.getParent().getId() + ",");
   dao.clear();
   dao.save(menu);
   // 更新子节点 parentIds
   List<Menu> list = dao.findByParentIdsLike("%," + menu.getId() + ",%");
   for (Menu e : list) {
     e.setParentIds(e.getParentIds().replace(oldParentIds, menu.getParentIds()));
   }
   dao.clear();
   dao.save(list);
   systemRealm.clearAllCachedAuthorizationInfo();
   Users.removeCache(Users.CACHE_MENU_LIST);
 }
Esempio n. 2
0
 @Transactional(readOnly = false)
 public void deleteMenu(String id) {
   dao.deleteById(id, "%," + id + ",%");
   systemRealm.clearAllCachedAuthorizationInfo();
   Users.removeCache(Users.CACHE_MENU_LIST);
 }