示例#1
0
  /*
   * 保存角色权限
   * @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()));
      }
    }
  }
示例#2
0
 /*
  * 查询角色菜单
  * @see com.cxstock.biz.power.RoleBiz#findRoleMenu()
  */
 public List findRoleMenu(Integer roleid) {
   String hql = "from Menu order by ordernum";
   List menuList = baseDao.findByHql(hql);
   hql = "select t.menu from Rolemenu as t where t.role.roleid=" + roleid;
   List roleMenuList = baseDao.findByHql(hql);
   List treeNodeList = this.getTreeNode(0, menuList, roleMenuList);
   return treeNodeList;
 }
示例#3
0
 /*
  * 分页查询角色列表
  * @see com.cxstock.biz.power.RoleBiz#findPageRole(com.cxstock.utils.system.Page)
  */
 public void findPageRole(Page page) {
   String hql = "from Role order by roleid";
   List list = baseDao.findByHql(hql, page.getStart(), page.getLimit());
   List dtoList = RoleDTO.createDtos(list);
   int total = baseDao.countAll("Role");
   page.setRoot(dtoList);
   page.setTotal(total);
 }
示例#4
0
 /*
  * 保存/修改角色
  * @see com.cxstock.biz.power.RoleBiz#saveOrUpdateRole(com.cxstock.biz.power.dto.RoleDTO)
  */
 public void saveOrUpdateRole(RoleDTO dto) {
   Role role = new Role();
   if (dto.getRoleid() != null) {
     role = (Role) baseDao.loadById(Role.class, dto.getRoleid());
   }
   role.setRolename(dto.getRolename());
   role.setBz(dto.getBz());
   baseDao.saveOrUpdate(role);
 }
示例#5
0
 /*
  * 删除角色
  * @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;
   }
 }
示例#6
0
 /*
  * 角色下拉数据
  * @see com.cxstock.biz.power.RoleBiz#deleteRole(java.lang.Integer)
  */
 public List findRoleType() {
   List list = new ArrayList();
   List<Role> roleList = baseDao.listAll("Role");
   for (Role role : roleList) {
     ComboData dto = new ComboData();
     dto.setValue(role.getRoleid().toString());
     dto.setText(role.getRolename());
     list.add(dto);
   }
   return list;
 }