Search in sources :

Example 6 with SysMenu

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

the class SysMenuServiceImpl method getMenuTreeList.

private List<SysMenu> getMenuTreeList(List<SysMenu> menuList, List<Integer> menuIdList) {
    List<SysMenu> subMenuList = Lists.newArrayList();
    List<SysMenu> menuTreeList = null;
    List<SysMenu> rootMenuList = null;
    for (SysMenu entity : menuList) {
        if (entity.getType() == SysMenuType.CATALOG.getValue()) {
            // 目录
            rootMenuList = listParentId(entity.getId(), menuIdList);
            if (ListUtilHelper.isNotEmpty(rootMenuList)) {
                menuTreeList = getMenuTreeList(rootMenuList, menuIdList);
                if (ListUtilHelper.isNotEmpty(menuTreeList)) {
                    entity.setChildrenList(menuTreeList);
                    // 有子菜单
                    entity.setOpen(true);
                    subMenuList.add(entity);
                }
            }
        } else {
            subMenuList.add(entity);
        }
    }
    return subMenuList;
}
Also used : SysMenu(com.cdeledu.model.rbac.SysMenu)

Example 7 with SysMenu

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

the class SysMenuServiceImpl method getMenuZTreeByParentId.

private List<Map<String, Object>> getMenuZTreeByParentId(int parentId, List<Integer> authIds) {
    List<Map<String, Object>> results = Lists.newArrayList();
    try {
        List<SysMenu> rootMenuList = getMenuPermsByParentCode(parentId);
        Map<String, Object> resultMap = null;
        Integer authId = null;
        for (SysMenu sysMenu : rootMenuList) {
            authId = sysMenu.getId();
            resultMap = Maps.newConcurrentMap();
            resultMap.put("id", authId);
            resultMap.put("name", sysMenu.getMenuName());
            if (authIds.indexOf(authId) > -1) {
                resultMap.put("checked", true);
            }
            if (hasChildren(authId)) {
                resultMap.put("children", getMenuZTreeByParentId(authId, authIds));
            } else {
                resultMap.put("open", true);
            }
            results.add(resultMap);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return results;
}
Also used : SysMenu(com.cdeledu.model.rbac.SysMenu) Map(java.util.Map)

Example 8 with SysMenu

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

the class MenuOperateController method createMenu.

/**
 * ----------------------------------------------------- Fields end
 */
@ResponseBody
@RequestMapping(value = "createMenu", method = RequestMethod.POST)
@SystemLog(desc = "创建权限菜单", opType = SysOpType.INSERT, tableName = "sys_menu")
public AjaxJson createMenu(ModelMap map, SysMenu menu) {
    AjaxJson ajaxJson = new AjaxJson();
    int resultCount = -1;
    try {
        if (menu.getType() == SysMenuType.BUTTON.getValue()) {
            SysMenu parentmMenu = new SysMenu();
            parentmMenu.setId(menu.getParentCode());
            if (sysMenuService.findOneForJdbc(parentmMenu).getType() == SysMenuType.MENU.getValue()) {
                resultCount = sysMenuService.insert(menu);
            } else {
                ajaxJson.setSuccess(false);
                ajaxJson.setMsg("禁止为菜单目录创建按钮权限");
            }
        } else {
            resultCount = sysMenuService.insert(menu);
        }
        if (resultCount == 1) {
            // 分配给超级管理员
            try {
                roleService.saveRoleAccess(1, menu.getId());
            } catch (Exception e) {
            }
        }
    } catch (Exception e) {
        ajaxJson.setSuccess(false);
        ajaxJson.setMsg(MessageConstant.MSG_OPERATION_SUCCESS);
    }
    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 9 with SysMenu

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

the class MenuOperateController method saveMenu.

@ResponseBody
@RequestMapping(value = "saveMenu")
@SystemLog(desc = "更新权限菜单", opType = SysOpType.INSERT, tableName = "sys_menu")
public AjaxJson saveMenu(SysMenu sysMenu) {
    AjaxJson ajaxJson = new AjaxJson();
    try {
        SysMenu menu = sysMenuService.findOneById(sysMenu.getId());
        if (menu != null && menu.getAllowEdit() == 1) {
            if (menu.getType() == sysMenu.getType()) {
                sysMenuService.update(sysMenu);
                ajaxJson.setMsg(MessageConstant.SUCCESS_UPDATE_MESSAGE);
            } else {
                if (!sysMenuService.hasChildren(sysMenu.getId())) {
                    sysMenuService.update(sysMenu);
                    ajaxJson.setMsg(MessageConstant.SUCCESS_UPDATE_MESSAGE);
                } else {
                    ajaxJson.setSuccess(false);
                    ajaxJson.setMsg(MessageConstant.MSG_HAS_CHILD);
                }
            }
        } else {
            ajaxJson.setSuccess(false);
            ajaxJson.setMsg("不支持更新操作");
        }
    } catch (Exception e) {
        ajaxJson.setMsg(MessageConstant.FAILURE_UPDATE_MESSAGE);
        ajaxJson.setSuccess(false);
    }
    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)

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