Commit 8c87411b authored by Sun's avatar Sun
Browse files

no commit message

parent 8ad33f02
......@@ -3,6 +3,7 @@
*/
package com.jeespring.modules.sys.entity;
import java.util.ArrayList;
import java.util.List;
import javax.validation.constraints.NotNull;
......@@ -32,9 +33,8 @@ public class Menu extends AbstractBaseEntity<Menu> {
private Integer sort; // 排序
private String isShow; // 是否在菜单中显示(1:显示;0:不显示)
private String permission; // 权限标识
private String userId;
public Menu(){
super();
this.sort = 30;
......@@ -44,10 +44,29 @@ public class Menu extends AbstractBaseEntity<Menu> {
public Menu(String id){
super(id);
}
private static List<Menu> allMenuCache;
@JsonBackReference
public static List<Menu> getAllMenu() {
return allMenuCache;
}
public static void setAllMenu(List<Menu> allMenu) {
Menu.allMenuCache = allMenu;
}
@JsonBackReference
@NotNull
public Menu getParent() {
List<Menu> menuList = getAllMenu();
if(menuList!=null){
for (Menu item:menuList) {
if(item.parent.getId()==this.getId()) {
parent=item;
break;
}
}
}
return parent;
}
......@@ -136,6 +155,7 @@ public class Menu extends AbstractBaseEntity<Menu> {
@JsonIgnore
public boolean hasChildren(){
children=this.getChildren();
if(children == null || children.size() == 0){
return false;
}
......@@ -205,6 +225,16 @@ public class Menu extends AbstractBaseEntity<Menu> {
}
public List<Menu> getChildren() {
this.children=new ArrayList<Menu>();
List<Menu> menuList = getAllMenu();
if(menuList!=null) {
for (Menu item : menuList) {
if(item.parent==null){continue;}
if (this.getId().equals(item.parent.getId())) {
this.children.add(item);
}
}
}
return children;
}
}
\ No newline at end of file
......@@ -54,6 +54,7 @@ public class SystemAuthorizingRealm extends AuthorizingRealm {
/**
* 认证回调函数, 登录时调用
* /admin/login
*/
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken) {
......
......@@ -180,6 +180,7 @@ public class UserUtils {
* @return
*/
public static Menu getTopMenu(){
Menu.setAllMenu(UserUtils.getMenuList());
@SuppressWarnings("unchecked")
Menu topMenu = menuDao.findUniqueByProperty("parent_id", "'0'");
return topMenu;
......
......@@ -13,10 +13,10 @@
<result property="isShow" column="isShow" />
<result property="permission" column="permission" />
<!-- 查询父模块-->
<association property="parent" column="parent_id" select="getParent" />
<!--association property="parent" column="parent_id" select="getParent" /-->
<!-- 查询子模块 -->
<collection property="children" column="id" select="getChildren" />
<!--collection property="children" column="id" select="getChildren" /-->
</resultMap>
<sql id="menuColumns">
......
Supports Markdown
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