/* * 保存角色权限 * @see com.cxstock.biz.power.RoleBiz#saveRoleMenu(java.lang.Integer, java.lang.String) */ public void saveRoleMenu(Integer roleid, String menuids) { String hql = "select t.menu from Rolemenu as t where t.role.roleid=" + roleid; // 数据库角色权限 List<Menu> rmList = baseDao.findByHql(hql); // 页面勾选权限id String[] mids = menuids.split(","); // 页面存在数据库不存在就添加 if (mids.length > 0) { for (String menuid : mids) { if (this.isContain(rmList, menuid)) { Rolemenu rolemenu = new Rolemenu(); rolemenu.setId(new RolemenuId(roleid, Integer.valueOf(menuid))); baseDao.saveOrUpdate(rolemenu); } } } // 数据库存在而页面不存在就删除 for (Menu menu : rmList) { String menuid = menu.getMenuid().toString(); if (this.isContain(mids, menuid)) { baseDao.deleteById(Rolemenu.class, new RolemenuId(roleid, menu.getMenuid())); } } }
/* * 删除角色 * @see com.cxstock.biz.power.RoleBiz#deleteRole(java.lang.Integer) */ public boolean deleteRole(Integer roleid) { String hql = "select count(userid) from Users where role.roleid =" + roleid; int count = baseDao.countQuery(hql); if (count > 0) { return false; } else { baseDao.deleteById(Role.class, roleid); return true; } }