Skip to content

Commit 4412a27

Browse files
committed
add shiro
1 parent 62394fa commit 4412a27

47 files changed

Lines changed: 1446 additions & 235 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pom.xml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@
3434
<artifactId>shiro-core</artifactId>
3535
<version>1.2.2</version>
3636
</dependency>
37-
<dependency>
38-
<groupId>org.apache.shiro</groupId>
39-
<artifactId>shiro-ehcache</artifactId>
40-
<version>1.2.2</version>
41-
</dependency>
4237
<dependency>
4338
<groupId>org.apache.shiro</groupId>
4439
<artifactId>shiro-web</artifactId>
@@ -153,11 +148,17 @@
153148
<artifactId>log4j</artifactId>
154149
<version>1.2.17</version>
155150
</dependency>
151+
<dependency>
152+
<groupId>org.apache.logging.log4j</groupId>
153+
<artifactId>log4j-core</artifactId>
154+
<version>2.3</version>
155+
</dependency>
156156
<dependency>
157157
<groupId>org.slf4j</groupId>
158158
<artifactId>slf4j-log4j12</artifactId>
159159
<version>1.7.14</version>
160160
</dependency>
161+
161162
<dependency>
162163
<groupId>ognl</groupId>
163164
<artifactId>ognl</artifactId>
@@ -168,11 +169,7 @@
168169
<artifactId>javassist</artifactId>
169170
<version>3.20.0-GA</version>
170171
</dependency>
171-
<dependency>
172-
<groupId>org.apache.logging.log4j</groupId>
173-
<artifactId>log4j-core</artifactId>
174-
<version>2.3</version>
175-
</dependency>
172+
176173
<dependency>
177174
<groupId>org.apache.commons</groupId>
178175
<artifactId>commons-pool2</artifactId>

src/main/java/com/giit/www/college/dao/OrderBookDao.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<result property="dateOfPrinting" column="date_of_printing"/>
4141
<result property="author" column="author"/>
4242
<result property="press" column="press"/>
43-
<collection property="countList" column="count" ofType="Integer"/>
43+
<result property="count" column="count"/>
4444
</resultMap>
4545

4646
<insert id="add" parameterType="OrderBook">
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
package com.giit.www.entity;
2+
3+
import java.io.Serializable;
4+
5+
/**
6+
* <p>User: Zhang Kaitao
7+
* <p>Date: 14-1-28
8+
* <p>Version: 1.0
9+
*/
10+
public class Resource implements Serializable {
11+
private Long id; //编号
12+
private String name; //资源名称
13+
private ResourceType type = ResourceType.menu; //资源类型
14+
private String url; //资源路径
15+
private String permission; //权限字符串
16+
private Long parentId; //父编号
17+
private String parentIds; //父编号列表
18+
private Boolean available = Boolean.FALSE;
19+
20+
public static enum ResourceType {
21+
menu("菜单"), button("按钮");
22+
23+
private final String info;
24+
private ResourceType(String info) {
25+
this.info = info;
26+
}
27+
28+
public String getInfo() {
29+
return info;
30+
}
31+
}
32+
33+
34+
35+
public Long getId() {
36+
return id;
37+
}
38+
39+
public void setId(Long id) {
40+
this.id = id;
41+
}
42+
43+
public String getName() {
44+
return name;
45+
}
46+
47+
public void setName(String name) {
48+
this.name = name;
49+
}
50+
51+
public ResourceType getType() {
52+
return type;
53+
}
54+
55+
public void setType(ResourceType type) {
56+
this.type = type;
57+
}
58+
59+
public String getUrl() {
60+
return url;
61+
}
62+
63+
public void setUrl(String url) {
64+
this.url = url;
65+
}
66+
67+
public String getPermission() {
68+
return permission;
69+
}
70+
71+
public void setPermission(String permission) {
72+
this.permission = permission;
73+
}
74+
75+
public Long getParentId() {
76+
return parentId;
77+
}
78+
79+
public void setParentId(Long parentId) {
80+
this.parentId = parentId;
81+
}
82+
83+
public String getParentIds() {
84+
return parentIds;
85+
}
86+
87+
public void setParentIds(String parentIds) {
88+
this.parentIds = parentIds;
89+
}
90+
91+
public Boolean getAvailable() {
92+
return available;
93+
}
94+
95+
public void setAvailable(Boolean available) {
96+
this.available = available;
97+
}
98+
99+
public boolean isRootNode() {
100+
return parentId == 0;
101+
}
102+
103+
public String makeSelfAsParentIds() {
104+
return getParentIds() + getId() + "/";
105+
}
106+
@Override
107+
public boolean equals(Object o) {
108+
if (this == o) return true;
109+
if (o == null || getClass() != o.getClass()) return false;
110+
111+
Resource resource = (Resource) o;
112+
113+
if (id != null ? !id.equals(resource.id) : resource.id != null) return false;
114+
115+
return true;
116+
}
117+
118+
@Override
119+
public int hashCode() {
120+
return id != null ? id.hashCode() : 0;
121+
}
122+
123+
@Override
124+
public String toString() {
125+
return "Resource{" +
126+
"id=" + id +
127+
", name='" + name + '\'' +
128+
", type=" + type +
129+
", permission='" + permission + '\'' +
130+
", parentId=" + parentId +
131+
", parentIds='" + parentIds + '\'' +
132+
", available=" + available +
133+
'}';
134+
}
135+
}
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
package com.giit.www.entity;
2+
3+
import org.springframework.util.CollectionUtils;
4+
import org.springframework.util.StringUtils;
5+
6+
import java.io.Serializable;
7+
import java.util.ArrayList;
8+
import java.util.List;
9+
10+
/**
11+
* <p>User: Zhang Kaitao
12+
* <p>Date: 14-1-28
13+
* <p>Version: 1.0
14+
*/
15+
public class Role implements Serializable {
16+
private Long id; //编号
17+
private String role; //角色标识 程序中判断使用,如"admin"
18+
private String description; //角色描述,UI界面显示使用
19+
private List<Long> resourceIds; //拥有的资源
20+
private String resourceIdsStr; //拥有的资源
21+
private Boolean available = Boolean.FALSE; //是否可用,如果不可用将不会添加给用户
22+
23+
public Role() {
24+
}
25+
26+
public Role(String role, String description, Boolean available) {
27+
this.role = role;
28+
this.description = description;
29+
this.available = available;
30+
}
31+
32+
public Long getId() {
33+
return id;
34+
}
35+
36+
public void setId(Long id) {
37+
this.id = id;
38+
}
39+
40+
public String getRole() {
41+
return role;
42+
}
43+
44+
public void setRole(String role) {
45+
this.role = role;
46+
}
47+
48+
public String getDescription() {
49+
return description;
50+
}
51+
52+
public void setDescription(String description) {
53+
this.description = description;
54+
}
55+
56+
public List<Long> getResourceIds() {
57+
if (resourceIds == null) {
58+
resourceIds = new ArrayList<Long>();
59+
}
60+
return resourceIds;
61+
}
62+
63+
public void setResourceIds(List<Long> resourceIds) {
64+
this.resourceIds = resourceIds;
65+
this.resourceIdsStr = parseScrToStr();
66+
}
67+
68+
public String parseScrToStr() {
69+
if (CollectionUtils.isEmpty(resourceIds)) {
70+
return "";
71+
}
72+
StringBuilder s = new StringBuilder();
73+
for (Long resourceId : resourceIds) {
74+
s.append(resourceId);
75+
s.append(",");
76+
}
77+
return s.toString();
78+
}
79+
80+
public String getResourceIdsStr() {
81+
return resourceIdsStr;
82+
}
83+
84+
public void setResourceIdsStr(String resourceIdsStr) {
85+
this.resourceIdsStr = resourceIdsStr;
86+
}
87+
88+
public void parseScrToLongList(String resourceIdsStr) {
89+
if (StringUtils.isEmpty(resourceIdsStr)) {
90+
return;
91+
}
92+
String[] resourceIdStrs = resourceIdsStr.split(",");
93+
for (String resourceIdStr : resourceIdStrs) {
94+
if (StringUtils.isEmpty(resourceIdStr)) {
95+
continue;
96+
}
97+
getResourceIds().add(Long.valueOf(resourceIdStr));
98+
}
99+
}
100+
101+
public Boolean getAvailable() {
102+
return available;
103+
}
104+
105+
public void setAvailable(Boolean available) {
106+
this.available = available;
107+
}
108+
109+
@Override
110+
public boolean equals(Object o) {
111+
if (this == o) return true;
112+
if (o == null || getClass() != o.getClass()) return false;
113+
114+
Role role = (Role) o;
115+
116+
if (id != null ? !id.equals(role.id) : role.id != null) return false;
117+
118+
return true;
119+
}
120+
121+
@Override
122+
public int hashCode() {
123+
return id != null ? id.hashCode() : 0;
124+
}
125+
126+
@Override
127+
public String toString() {
128+
return "Role{" +
129+
"id=" + id +
130+
", role='" + role + '\'' +
131+
", description='" + description + '\'' +
132+
", resourceIds=" + resourceIds +
133+
", available=" + available +
134+
'}';
135+
}
136+
}

0 commit comments

Comments
 (0)