Search in sources :

Example 1 with SysMenu

use of com.cdeledu.model.rbac.SysMenu in project wechat by dllwh.

the class SysMenuServiceImpl method findOneById.

@Override
public SysMenu findOneById(Integer id) throws Exception {
    SysMenu sysMenu = new SysMenu();
    sysMenu.setId(id);
    return findOneForJdbc(sysMenu);
}
Also used : SysMenu(com.cdeledu.model.rbac.SysMenu)

Example 2 with SysMenu

use of com.cdeledu.model.rbac.SysMenu in project wechat by dllwh.

the class SysMenuServiceImpl method getMenuEasyUITreeByParentId.

private List<TreeNode> getMenuEasyUITreeByParentId(int parentId) {
    List<TreeNode> results = Lists.newArrayList();
    try {
        List<SysMenu> rootMenuList = getMenuByParentCode(parentId);
        TreeNode treeNode = null;
        for (SysMenu sysMenu : rootMenuList) {
            int treeId = sysMenu.getId();
            treeNode = new TreeNode();
            treeNode.setId(treeId);
            treeNode.setText(sysMenu.getMenuName());
            if (hasChildren(treeId) && sysMenu.getType() == SysMenuType.CATALOG.getValue()) {
                treeNode.setState("closed");
                treeNode.setChildren(getMenuEasyUITreeByParentId(treeId));
            } else {
                treeNode.setIconCls("fa fa-leaf");
                treeNode.setState("open");
            }
            results.add(treeNode);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return results;
}
Also used : SysMenu(com.cdeledu.model.rbac.SysMenu) TreeNode(com.cdeledu.common.plugs.easyui.TreeNode)

Example 3 with SysMenu

use of com.cdeledu.model.rbac.SysMenu in project wechat by dllwh.

the class MenuOperateController method delMenu.

/**
 * @方法描述: 删除菜单,根据ID,但是删除权限的时候,需要查询是否有赋予给角色,如果有角色在使用,那么就不能删除。
 * @param menu
 * @return
 */
@ResponseBody
@RequestMapping(value = "del")
@SystemLog(desc = "删除权限菜单", opType = SysOpType.DEL, tableName = "sys_menu,sys_role_menu")
public AjaxJson delMenu(SysMenu sysMenu) {
    AjaxJson ajaxJson = new AjaxJson();
    try {
        Integer id = sysMenu.getId();
        SysMenu menu = sysMenuService.findOneById(id);
        if (menu != null && menu.getAllowDelete() == 1) {
            // 删除权限菜单时先删除权限菜单与角色之间关联表信息
            if (sysMenuService.hasRole(id)) {
                ajaxJson.setSuccess(false);
                ajaxJson.setMsg(MessageConstant.MSG_HAS_CHILD);
            } else {
                if (sysMenuService.hasChildren(id)) {
                    // 子节点
                    ajaxJson.setSuccess(false);
                    ajaxJson.setMsg(MessageConstant.MSG_HAS_CHILD);
                } else {
                    sysMenuService.delete(id);
                    ajaxJson.setMsg(MessageConstant.SUCCESS_DELETE_MESSAGE);
                }
            }
        } else {
            ajaxJson.setSuccess(false);
            ajaxJson.setMsg(MessageConstant.SUCCESS_DELETE_MESSAGE);
        }
    } catch (Exception e) {
        ajaxJson.setSuccess(false);
        ajaxJson.setResultCode(500);
        ajaxJson.setMsg(MessageConstant.FAILURE_DELETE_MESSAGE);
    }
    return ajaxJson;
}
Also used : SysMenu(com.cdeledu.model.rbac.SysMenu) AjaxJson(com.cdeledu.common.base.AjaxJson) SystemLog(com.cdeledu.core.annotation.SystemLog) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with SysMenu

use of com.cdeledu.model.rbac.SysMenu in project wechat by dllwh.

the class SysMenuServiceImpl method listParentId.

private List<SysMenu> listParentId(Integer parentId, List<Integer> menuIdList) {
    List<SysMenu> rootMenuList = null;
    try {
        rootMenuList = getMenuByParentCode(parentId);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
    if (menuIdList == null) {
        return rootMenuList;
    }
    List<SysMenu> userMenuList = Lists.newArrayList();
    for (SysMenu menu : rootMenuList) {
        if (menuIdList.contains(menu.getId())) {
            if (menu.getType() == SysMenuType.MENU.getValue()) {
                // 是菜单
                if (StringUtils.isNotBlank(menu.getMenuUrl())) {
                    userMenuList.add(menu);
                }
            } else {
                userMenuList.add(menu);
            }
        }
    }
    return userMenuList;
}
Also used : SysMenu(com.cdeledu.model.rbac.SysMenu)

Example 5 with SysMenu

use of com.cdeledu.model.rbac.SysMenu in project wechat by dllwh.

the class SysMenuServiceImpl method getAllMenuList.

/**
 * ----------------------------------------------------- privateMethod start
 */
/**
 * @方法描述: 获取所有菜单列表
 * @param menuIdList
 * @return
 */
private List<SysMenu> getAllMenuList(List<Integer> menuIdList) {
    try {
        // 2. 获取根菜单列表
        List<SysMenu> userMenuList = listParentId(-1, menuIdList);
        // 3. 递归获取子菜单
        List<SysMenu> resultList = getMenuTreeList(userMenuList, menuIdList);
        SysMenu homePage = new SysMenu();
        homePage.setOpen(false);
        homePage.setMenuUrl(GlobalConstants.getHomePageUrl());
        homePage.setMenuName("系统首页");
        homePage.setIconClass("icon-dashboard");
        resultList.add(0, homePage);
        return resultList;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : SysMenu(com.cdeledu.model.rbac.SysMenu)

Aggregations

SysMenu (com.cdeledu.model.rbac.SysMenu)9 AjaxJson (com.cdeledu.common.base.AjaxJson)3 SystemLog (com.cdeledu.core.annotation.SystemLog)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 TreeNode (com.cdeledu.common.plugs.easyui.TreeNode)1 Map (java.util.Map)1