Commit 3b685ad8 by fsn

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

parent 2d5fa421
package com.stylefeng.guns.common.node; package com.stylefeng.guns.common.node;
import com.stylefeng.guns.core.util.ToolUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
...@@ -250,14 +248,15 @@ public class MenuNode implements Comparable { ...@@ -250,14 +248,15 @@ public class MenuNode implements Comparable {
} }
/** /**
* 清除不包含子节点的节点 * 清除所有二级菜单
* *
* @date 2017年2月19日 下午11:18:19 * @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>(); ArrayList<MenuNode> results = new ArrayList<MenuNode>();
for (MenuNode node : nodes) { for (MenuNode node : nodes) {
if (ToolUtil.isNotEmpty(node.getChildren())) { Integer levels = node.getLevels();
if (levels.equals(1)) {
results.add(node); results.add(node);
} }
} }
...@@ -272,7 +271,7 @@ public class MenuNode implements Comparable { ...@@ -272,7 +271,7 @@ public class MenuNode implements Comparable {
public static List<MenuNode> buildTitle(List<MenuNode> nodes) { public static List<MenuNode> buildTitle(List<MenuNode> nodes) {
List<MenuNode> clearBtn = clearBtn(nodes); List<MenuNode> clearBtn = clearBtn(nodes);
new MenuNode().buildNodeTree(clearBtn); new MenuNode().buildNodeTree(clearBtn);
List<MenuNode> menuNodes = clearNoChild(clearBtn); List<MenuNode> menuNodes = clearLevelTwo(clearBtn);
//对菜单排序 //对菜单排序
Collections.sort(menuNodes); Collections.sort(menuNodes);
......
...@@ -40,7 +40,7 @@ public class NoticeController extends BaseController { ...@@ -40,7 +40,7 @@ public class NoticeController extends BaseController {
private NoticeDao noticeDao; private NoticeDao noticeDao;
/** /**
* 跳转到通知首页 * 跳转到通知列表首页
*/ */
@RequestMapping("") @RequestMapping("")
public String index() { public String index() {
...@@ -66,6 +66,16 @@ public class NoticeController extends BaseController { ...@@ -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") @RequestMapping(value = "/list")
......
...@@ -25,6 +25,14 @@ ...@@ -25,6 +25,14 @@
</li> </li>
@for(title in titles){ @for(title in titles){
@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> <li>
<a href="#"> <a href="#">
<i class="fa ${title.icon}"></i> <i class="fa ${title.icon}"></i>
...@@ -40,6 +48,7 @@ ...@@ -40,6 +48,7 @@
</ul> </ul>
</li> </li>
@} @}
@}
</ul> </ul>
</div> </div>
......
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