예제 #1
0
 /**
  * 选择上一级菜单。
  *
  * @return List<Map<String, Object>
  */
 @RequestMapping(value = "menuManage.do", params = "initSelectParentTree")
 @ResponseBody
 public List<Map<String, Object>> initSelectParentTree() {
   String rootCode = this.getUser().getOrgId();
   List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
   PMap pm = new PMap();
   if ((!StringUtil.isEmpty(rootCode)) && (!"244000000".equals(rootCode))) {
     pm.add("sjssjgDm", rootCode);
   } else {
     HashMap<String, Object> mtop = new HashMap<String, Object>();
     mtop.put("name", "菜单树");
     mtop.put("id", "0");
     mtop.put("pId", "");
     mtop.put("sortNo", 1);
     mtop.put("open", true);
     list.add(mtop);
   }
   List<Menu> menuList = this.menuService.findBy(pm, Order.ASC("sortNo"), Order.ASC("name"));
   for (Menu menu : menuList) {
     HashMap<String, Object> m = new HashMap<String, Object>();
     m.put("name", menu.getName());
     m.put("id", menu.getId());
     if ((menu.getParentId() != null) && (!"".equals(menu.getParentId()))) {
       m.put("pId", menu.getParentId());
     } else {
       m.put("pId", "0");
     }
     m.put("sortNo", menu.getSortNo());
     list.add(m);
   }
   return list;
 }
예제 #2
0
 /**
  * 获取菜单详细信息。
  *
  * @param id String
  * @return Menu
  */
 @RequestMapping(value = "menuManage.do", params = "getMenuDetail", produces = "application/json")
 @ResponseBody
 public Menu getMenuDetile(@RequestParam String id) {
   if (!"0".equals(id)) {
     Menu menu = this.menuService.find(id);
     if (!"0".equals(menu.getParentId()) && menu.getParentId() != null) {
       Menu parent = this.menuService.find(menu.getParentId());
       if (parent != null) {
         menu.setParentName(parent.getName());
         menu.setParentSjssjgDm(parent.getSjssjgDm());
       }
     } else {
       menu.setParentName("菜单树");
     }
     return menu;
   }
   return null;
 }
예제 #3
0
 /**
  * 菜单管理入口。
  *
  * @param map ModelMap
  * @return String
  */
 @RequestMapping("menuManage.do")
 public String init(ModelMap map) {
   List<Menu> menuList = this.menuService.list(Order.ASC("sortNo"), Order.ASC("name"));
   List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
   HashMap<String, Object> mtop = new HashMap<String, Object>();
   mtop.put("name", "菜单树");
   mtop.put("id", "0");
   mtop.put("pId", "");
   mtop.put("sortNo", 1);
   mtop.put("open", true);
   list.add(mtop);
   String rootCode = this.getUser().getOrgId();
   String userCode = this.getUser().getLoginId();
   for (Menu menu : menuList) {
     if (rootCode.equals(menu.getSjssjgDm())
         || StringUtil.isEmpty(menu.getSjssjgDm())
         || "1".equals(menu.getSjssjgDm())
         || "supadmin".equals(userCode)
         || "244000000".equals(rootCode)) {
       HashMap<String, Object> m = new HashMap<String, Object>();
       m.put("name", menu.getName());
       m.put("id", menu.getId());
       if ((menu.getParentId() != null) && (!"".equals(menu.getParentId()))) {
         m.put("pId", menu.getParentId());
       } else {
         m.put("pId", "0");
       }
       m.put("sortNo", menu.getSortNo());
       list.add(m);
     }
   }
   map.put("treeList", list);
   map.put("rootCode", rootCode);
   map.put("userCode", userCode);
   map.put("menu", new Menu());
   return "admin/menuManage";
 }
예제 #4
0
  /**
   * 保存菜单设置。
   *
   * @param menu Menu
   * @return String
   */
  @RequestMapping(value = "menuManage.do", params = "save")
  @ResponseBody
  public Map<String, Object> ok(@ModelAttribute Menu menu) {
    Map<String, Object> returnMap = new HashMap<String, Object>();
    if ("1".equals(menu.getVisible())) {
      menu.setVisible(BaseConstants.YESORNO_TYPE_YES);
    } else {
      menu.setVisible(BaseConstants.YESORNO_TYPE_NO);
    }

    menu.setContextRelative(BaseConstants.YESORNO_TYPE_YES);
    try {
      if ((menu.getParentId() == null) || ("0".equals(menu.getParentId()))) {
        menu.setParentId("");
      }
      if ((menu.getId() == null) || ("".equals(menu.getId()))) {
        menu.setSjssjgDm(this.getUser().getOrgId());
      }
      this.menuService.saveOrUpdate(menu);
      returnMap.put("returnCode", "1");
      Map<String, Object> treeNode = new HashMap<String, Object>();
      treeNode.put("name", menu.getName());
      treeNode.put("id", menu.getId());
      if (StringUtils.hasLength(menu.getParentId())) {
        treeNode.put("pId", menu.getParentId());
      } else {
        treeNode.put("pId", "0");
      }
      treeNode.put("sortNo", menu.getSortNo());
      returnMap.put("returnNode", treeNode);
    } catch (Exception e) {
      log.error("菜单更新失败", e);
      returnMap.put("returnCode", "0");
    }
    return returnMap;
  }