@Transactional(readOnly = false) public void saveRole(Role role) { if (role.getId() == null) { role.setUser(UserUtils.getUser()); } roleDao.save(role); systemRealm.clearAllCachedAuthorizationInfo(); }
@Transactional(readOnly = false) public void saveMenu(Menu menu) { menu.setParent(this.getMenu(menu.getParent().getId())); String oldParentIds = menu.getParentIds(); // 获取修改前的parentIds,用于更新子节点的parentIds menu.setParentIds(menu.getParent().getParentIds() + menu.getParent().getId() + ","); if (menu.getId() == null) { menu.setUser(UserUtils.getUser()); } menuDao.clear(); menuDao.save(menu); // 更新子节点 parentIds List<Menu> list = menuDao.findByParentIdsLike("%," + menu.getId() + ",%"); for (Menu e : list) { e.setParentIds(e.getParentIds().replace(oldParentIds, menu.getParentIds())); } menuDao.save(list); systemRealm.clearAllCachedAuthorizationInfo(); }
@Transactional(readOnly = false) public void deleteMenu(Long id) { menuDao.deleteById(id, "%," + id + ",%"); systemRealm.clearAllCachedAuthorizationInfo(); }
@Transactional(readOnly = false) public void deleteRole(Long id) { roleDao.deleteById(id); systemRealm.clearAllCachedAuthorizationInfo(); }
@Transactional(readOnly = false) public void updatePasswordById(Long id, String loginName, String newPassword) { userDao.updatePasswordById(entryptPassword(newPassword), id); systemRealm.clearCachedAuthorizationInfo(loginName); }
@Transactional(readOnly = false) public void saveUser(User user) { userDao.clear(); userDao.save(user); systemRealm.clearCachedAuthorizationInfo(user.getLoginName()); }