forked from cmzalvin/giit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRole.java
More file actions
136 lines (111 loc) · 3.38 KB
/
Role.java
File metadata and controls
136 lines (111 loc) · 3.38 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
package com.giit.www.entity;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* <p>User: Zhang Kaitao
* <p>Date: 14-1-28
* <p>Version: 1.0
*/
public class Role implements Serializable {
private Long id; //编号
private String role; //角色标识 程序中判断使用,如"admin"
private String description; //角色描述,UI界面显示使用
private List<Long> resourceIds; //拥有的资源
private String resourceIdsStr; //拥有的资源
private Boolean available = Boolean.FALSE; //是否可用,如果不可用将不会添加给用户
public Role() {
}
public Role(String role, String description, Boolean available) {
this.role = role;
this.description = description;
this.available = available;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<Long> getResourceIds() {
if (resourceIds == null) {
resourceIds = new ArrayList<Long>();
}
return resourceIds;
}
public void setResourceIds(List<Long> resourceIds) {
this.resourceIds = resourceIds;
this.resourceIdsStr = parseScrToStr();
}
public String parseScrToStr() {
if (CollectionUtils.isEmpty(resourceIds)) {
return "";
}
StringBuilder s = new StringBuilder();
for (Long resourceId : resourceIds) {
s.append(resourceId);
s.append(",");
}
return s.toString();
}
public String getResourceIdsStr() {
return resourceIdsStr;
}
public void setResourceIdsStr(String resourceIdsStr) {
this.resourceIdsStr = resourceIdsStr;
}
public void parseScrToLongList(String resourceIdsStr) {
if (StringUtils.isEmpty(resourceIdsStr)) {
return;
}
String[] resourceIdStrs = resourceIdsStr.split(",");
for (String resourceIdStr : resourceIdStrs) {
if (StringUtils.isEmpty(resourceIdStr)) {
continue;
}
getResourceIds().add(Long.valueOf(resourceIdStr));
}
}
public Boolean getAvailable() {
return available;
}
public void setAvailable(Boolean available) {
this.available = available;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Role role = (Role) o;
if (id != null ? !id.equals(role.id) : role.id != null) return false;
return true;
}
@Override
public int hashCode() {
return id != null ? id.hashCode() : 0;
}
@Override
public String toString() {
return "Role{" +
"id=" + id +
", role='" + role + '\'' +
", description='" + description + '\'' +
", resourceIds=" + resourceIds +
", available=" + available +
'}';
}
}