66650499069abb37d98a920a1f1787cfd4eace87.svn-base
6.03 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
/**
* Copyright © 2015-2018 ODM All rights reserved.
*/
package com.thinkgem.jeesite.modules.sys.entity;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.Length;
import com.google.common.collect.Lists;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.DataEntity;
/**
* 角色Entity
* @author ThinkGem
* @version 2013-12-05
*/
public class Role extends DataEntity<Role> {
private static final long serialVersionUID = 1L;
private Office office; // 归属机构
private String name; // 角色名称
private String enname; // 英文名称
private String roleType;// 权限类型
private String dataScope;// 数据范围
private String oldName; // 原角色名称
private String oldEnname; // 原英文名称
private String sysData; //是否是系统数据
private String useable; //是否是可用
private User user; // 根据用户ID查询角色列表
// private List<User> userList = Lists.newArrayList(); // 拥有用户列表
private List<Menu> menuList = Lists.newArrayList(); // 拥有菜单列表
private List<Office> officeList = Lists.newArrayList(); // 按明细设置数据范围
// 数据范围(1:所有数据;2:所在公司及以下数据;3:所在公司数据;4:所在部门及以下数据;5:所在部门数据;8:仅本人数据;9:按明细设置)
public static final String DATA_SCOPE_ALL = "1";
public static final String DATA_SCOPE_COMPANY_AND_CHILD = "2";
public static final String DATA_SCOPE_COMPANY = "3";
public static final String DATA_SCOPE_OFFICE_AND_CHILD = "4";
public static final String DATA_SCOPE_OFFICE = "5";
public static final String DATA_SCOPE_SELF = "8";
public static final String DATA_SCOPE_CUSTOM = "9";
public Role() {
super();
this.dataScope = DATA_SCOPE_SELF;
this.useable=Global.YES;
}
public Role(String id){
super(id);
}
public Role(User user) {
this();
this.user = user;
}
public String getUseable() {
return useable;
}
public void setUseable(String useable) {
this.useable = useable;
}
public String getSysData() {
return sysData;
}
public void setSysData(String sysData) {
this.sysData = sysData;
}
public Office getOffice() {
return office;
}
public void setOffice(Office office) {
this.office = office;
}
@Length(min=1, max=100)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Length(min=1, max=100)
public String getEnname() {
return enname;
}
public void setEnname(String enname) {
this.enname = enname;
}
@Length(min=1, max=100)
public String getRoleType() {
return roleType;
}
public void setRoleType(String roleType) {
this.roleType = roleType;
}
public String getDataScope() {
return dataScope;
}
public void setDataScope(String dataScope) {
this.dataScope = dataScope;
}
public String getOldName() {
return oldName;
}
public void setOldName(String oldName) {
this.oldName = oldName;
}
public String getOldEnname() {
return oldEnname;
}
public void setOldEnname(String oldEnname) {
this.oldEnname = oldEnname;
}
// public List<User> getUserList() {
// return userList;
// }
//
// public void setUserList(List<User> userList) {
// this.userList = userList;
// }
//
// public List<String> getUserIdList() {
// List<String> nameIdList = Lists.newArrayList();
// for (User user : userList) {
// nameIdList.add(user.getId());
// }
// return nameIdList;
// }
//
// public String getUserIds() {
// return StringUtils.join(getUserIdList(), ",");
// }
public List<Menu> getMenuList() {
return menuList;
}
public void setMenuList(List<Menu> menuList) {
this.menuList = menuList;
}
public List<String> getMenuIdList() {
List<String> menuIdList = Lists.newArrayList();
for (Menu menu : menuList) {
menuIdList.add(menu.getId());
}
return menuIdList;
}
public void setMenuIdList(List<String> menuIdList) {
menuList = Lists.newArrayList();
for (String menuId : menuIdList) {
Menu menu = new Menu();
menu.setId(menuId);
menuList.add(menu);
}
}
public String getMenuIds() {
return StringUtils.join(getMenuIdList(), ",");
}
public void setMenuIds(String menuIds) {
menuList = Lists.newArrayList();
if (menuIds != null){
String[] ids = StringUtils.split(menuIds, ",");
setMenuIdList(Lists.newArrayList(ids));
}
}
public List<Office> getOfficeList() {
return officeList;
}
public void setOfficeList(List<Office> officeList) {
this.officeList = officeList;
}
public List<String> getOfficeIdList() {
List<String> officeIdList = Lists.newArrayList();
for (Office office : officeList) {
officeIdList.add(office.getId());
}
return officeIdList;
}
public void setOfficeIdList(List<String> officeIdList) {
officeList = Lists.newArrayList();
for (String officeId : officeIdList) {
Office office = new Office();
office.setId(officeId);
officeList.add(office);
}
}
public String getOfficeIds() {
return StringUtils.join(getOfficeIdList(), ",");
}
public void setOfficeIds(String officeIds) {
officeList = Lists.newArrayList();
if (officeIds != null){
String[] ids = StringUtils.split(officeIds, ",");
setOfficeIdList(Lists.newArrayList(ids));
}
}
/**
* 获取权限字符串列表
*/
public List<String> getPermissions() {
List<String> permissions = Lists.newArrayList();
for (Menu menu : menuList) {
if (menu.getPermission()!=null && !"".equals(menu.getPermission())){
permissions.add(menu.getPermission());
}
}
return permissions;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
// public boolean isAdmin(){
// return isAdmin(this.id);
// }
//
// public static boolean isAdmin(String id){
// return id != null && "1".equals(id);
// }
// @Transient
// public String getMenuNames() {
// List<String> menuNameList = Lists.newArrayList();
// for (Menu menu : menuList) {
// menuNameList.add(menu.getName());
// }
// return StringUtils.join(menuNameList, ",");
// }
}