Commit 3b685ad8 by fsn

修复一级菜单没有子菜单不能显示的问题

parent 2d5fa421
package com.stylefeng.guns.common.node;
import com.stylefeng.guns.core.util.ToolUtil;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
......@@ -250,14 +248,15 @@ public class MenuNode implements Comparable {
}
/**
* 清除不包含子节点的节点
* 清除所有二级菜单
*
* @date 2017年2月19日 下午11:18:19
*/
public static List<MenuNode> clearNoChild(List<MenuNode> nodes) {
public static List<MenuNode> clearLevelTwo(List<MenuNode> nodes) {
ArrayList<MenuNode> results = new ArrayList<MenuNode>();
for (MenuNode node : nodes) {
if (ToolUtil.isNotEmpty(node.getChildren())) {
Integer levels = node.getLevels();
if (levels.equals(1)) {
results.add(node);
}
}
......@@ -272,7 +271,7 @@ public class MenuNode implements Comparable {
public static List<MenuNode> buildTitle(List<MenuNode> nodes) {
List<MenuNode> clearBtn = clearBtn(nodes);
new MenuNode().buildNodeTree(clearBtn);
List<MenuNode> menuNodes = clearNoChild(clearBtn);
List<MenuNode> menuNodes = clearLevelTwo(clearBtn);
//对菜单排序
Collections.sort(menuNodes);
......
......@@ -40,7 +40,7 @@ public class NoticeController extends BaseController {
private NoticeDao noticeDao;
/**
* 跳转到通知首页
* 跳转到通知列表首页
*/
@RequestMapping("")
public String index() {
......@@ -66,6 +66,16 @@ public class NoticeController extends BaseController {
}
/**
* 跳转到首页通知
*/
@RequestMapping("/hello")
public String hello() {
List<Map<String, Object>> notices = noticeDao.list(null);
super.setAttr("noticeList",notices);
return "blackboard.html";
}
/**
* 获取通知列表
*/
@RequestMapping(value = "/list")
......
......@@ -25,22 +25,31 @@
</li>
@for(title in titles){
<li>
<a href="#">
<i class="fa ${title.icon}"></i>
<span class="nav-label">${title.name}</span>
<span class="fa arrow"></span>
</a>
<ul class="nav nav-second-level">
@for(subTitle in title.children){
<li>
<a class="J_menuItem" href="${ctxPath}${subTitle.url}">${subTitle.name}</a>
</li>
@}
</ul>
</li>
@if(tool.isEmpty(title.children)){
<li>
<a class="J_menuItem" href="${ctxPath}${title.url}">
<i class="fa ${title.icon}"></i>
<span class="nav-label">${title.name}</span>
</a>
</li>
@}else{
<li>
<a href="#">
<i class="fa ${title.icon}"></i>
<span class="nav-label">${title.name}</span>
<span class="fa arrow"></span>
</a>
<ul class="nav nav-second-level">
@for(subTitle in title.children){
<li>
<a class="J_menuItem" href="${ctxPath}${subTitle.url}">${subTitle.name}</a>
</li>
@}
</ul>
</li>
@}
@}
</ul>
</div>
</nav>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment