// @CacheEvict(value="SpringSecurityCache",allEntries=true) public void addUnRelatedPrivilegeR2s(String roleId, Collection<String> privilegeIds) { Role role = roleDao.findOne(roleId); Iterable<Privilege> privileges = privilegeDao.findAll(privilegeIds); for (Privilege privilege : privileges) { RoleR2Privilege r2 = new RoleR2Privilege(); r2.setRole(role); r2.setPrivilege(privilege); roleR2PrivilegeDao.save(r2); } }
// @CacheEvict(value="SpringSecurityCache",allEntries=true) public void deleteRelatedPrivilegeR2s(String roleId, Collection<String> r2Ids) { Role role = roleDao.findOne(roleId); Iterable<RoleR2Privilege> r2s = roleR2PrivilegeDao.findAll(r2Ids); for (RoleR2Privilege r2 : r2s) { // 确认检查传入的关联主键是否的确属于当前关联角色 if (r2.getRole().equals(role)) { roleR2PrivilegeDao.delete(r2); } } }
@Transactional(readOnly = true) public List<Role> findAllCached() { return roleDao.findAllCached(); }