cdaaddf01e54fed21383beecd5670d76579234bd.svn-base
3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/**
* Copyright © 2015-2018 ODM All rights reserved.
*/
package com.thinkgem.jeesite.modules.sys.entity;
import java.util.List;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.thinkgem.jeesite.common.persistence.DataEntity;
/**
* 菜单Entity
* @author ThinkGem
* @version 2013-05-15
*/
public class Menu extends DataEntity<Menu> {
private static final long serialVersionUID = 1L;
private Menu parent; // 父级菜单
private String parentIds; // 所有父级编号
private String name; // 名称
private String href; // 链接
private String target; // 目标( mainFrame、_blank、_self、_parent、_top)
private String icon; // 图标
private Integer sort; // 排序
private String isShow; // 是否在菜单中显示(1:显示;0:不显示)
private String permission; // 权限标识
private String userId;
public Menu(){
super();
this.sort = 30;
this.isShow = "1";
}
public Menu(String id){
super(id);
}
@JsonBackReference
@NotNull
public Menu getParent() {
return parent;
}
public void setParent(Menu parent) {
this.parent = parent;
}
@Length(min=1, max=2000)
public String getParentIds() {
return parentIds;
}
public void setParentIds(String parentIds) {
this.parentIds = parentIds;
}
@Length(min=1, max=100)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Length(min=0, max=2000)
public String getHref() {
return href;
}
public void setHref(String href) {
this.href = href;
}
@Length(min=0, max=20)
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
@Length(min=0, max=100)
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
@NotNull
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
@Length(min=1, max=1)
public String getIsShow() {
return isShow;
}
public void setIsShow(String isShow) {
this.isShow = isShow;
}
@Length(min=0, max=200)
public String getPermission() {
return permission;
}
public void setPermission(String permission) {
this.permission = permission;
}
public String getParentId() {
return parent != null && parent.getId() != null ? parent.getId() : "0";
}
@JsonIgnore
public static void sortList(List<Menu> list, List<Menu> sourcelist, String parentId, boolean cascade){
for (int i=0; i<sourcelist.size(); i++){
Menu e = sourcelist.get(i);
if (e.getParent()!=null && e.getParent().getId()!=null
&& e.getParent().getId().equals(parentId)){
list.add(e);
if (cascade){
// 判断是否还有子节点, 有则继续获取子节点
for (int j=0; j<sourcelist.size(); j++){
Menu child = sourcelist.get(j);
if (child.getParent()!=null && child.getParent().getId()!=null
&& child.getParent().getId().equals(e.getId())){
sortList(list, sourcelist, e.getId(), true);
break;
}
}
}
}
}
}
@JsonIgnore
public static String getRootId(){
return "1";
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
@Override
public String toString() {
return name;
}
}