Skip to content

Commit 3649c33

Browse files
committed
ok
1 parent 5285dd6 commit 3649c33

26 files changed

Lines changed: 1306 additions & 0 deletions

springboot-springSecurity4/pom.xml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.example</groupId>
8+
<artifactId>springboot-springSecurity4</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
<parent>
11+
<groupId>org.springframework.boot</groupId>
12+
<artifactId>spring-boot-starter-parent</artifactId>
13+
<version>1.3.0.RELEASE</version>
14+
</parent>
15+
16+
<properties>
17+
<start-class>com.us.Application</start-class>
18+
<maven.compiler.target>1.8</maven.compiler.target>
19+
<maven.compiler.source>1.8</maven.compiler.source>
20+
21+
<mybatis.version>3.4.0</mybatis.version>
22+
<mybatis-spring.version>1.3.0</mybatis-spring.version>
23+
</properties>
24+
25+
<dependencies>
26+
<!--springboot-->
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter-security</artifactId>
30+
</dependency>
31+
32+
<dependency>
33+
<groupId>org.springframework.boot</groupId>
34+
<artifactId>spring-boot-starter-thymeleaf</artifactId>
35+
</dependency>
36+
37+
38+
<dependency>
39+
<groupId>org.thymeleaf.extras</groupId>
40+
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
41+
</dependency>
42+
<!--db-->
43+
<dependency>
44+
<groupId>mysql</groupId>
45+
<artifactId>mysql-connector-java</artifactId>
46+
<version>6.0.5</version>
47+
</dependency>
48+
<dependency>
49+
<groupId>com.mchange</groupId>
50+
<artifactId>c3p0</artifactId>
51+
<version>0.9.5.2</version>
52+
</dependency>
53+
54+
<!--mybatis-->
55+
<dependency>
56+
<groupId>org.springframework</groupId>
57+
<artifactId>spring-jdbc</artifactId>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.mybatis</groupId>
61+
<artifactId>mybatis</artifactId>
62+
<version>${mybatis.version}</version>
63+
</dependency>
64+
<dependency>
65+
<groupId>org.mybatis</groupId>
66+
<artifactId>mybatis-spring</artifactId>
67+
<version>${mybatis-spring.version}</version>
68+
</dependency>
69+
70+
71+
</dependencies>
72+
73+
</project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.yy.example;
2+
3+
import org.springframework.boot.autoconfigure.SpringBootApplication;
4+
import org.springframework.context.ConfigurableApplicationContext;
5+
import org.springframework.context.annotation.ComponentScan;
6+
7+
import static org.springframework.boot.SpringApplication.run;
8+
9+
/**
10+
* Created by yangyibo on 17/1/17.
11+
*/
12+
13+
@ComponentScan(basePackages ="com.yy.example")
14+
@SpringBootApplication
15+
public class Application {
16+
public static void main(String[] args) {
17+
ConfigurableApplicationContext run = run(Application.class, args);
18+
}
19+
20+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.yy.example.bean;
2+
3+
4+
public class Permission {
5+
private Integer id;
6+
private String name;
7+
private String permissionUrl;
8+
private String method;
9+
private String description;
10+
11+
public Integer getId() {
12+
return id;
13+
}
14+
15+
public void setId(Integer id) {
16+
this.id = id;
17+
}
18+
19+
public String getName() {
20+
return name;
21+
}
22+
23+
public void setName(String name) {
24+
this.name = name;
25+
}
26+
27+
public String getPermissionUrl() {
28+
return permissionUrl;
29+
}
30+
31+
public void setPermissionUrl(String permissionUrl) {
32+
this.permissionUrl = permissionUrl;
33+
}
34+
35+
public String getMethod() {
36+
return method;
37+
}
38+
39+
public void setMethod(String method) {
40+
this.method = method;
41+
}
42+
43+
public String getDescription() {
44+
return description;
45+
}
46+
47+
public void setDescription(String description) {
48+
this.description = description;
49+
}
50+
51+
@Override
52+
public String toString() {
53+
return "Permission{" +
54+
"id=" + id +
55+
", name=" + name +
56+
", permissionUrl=" + permissionUrl +
57+
", method=" + method +
58+
", description=" + description +
59+
'}';
60+
}
61+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package com.yy.example.bean;
2+
3+
4+
5+
public class Role implements Comparable<Role>{
6+
private Integer id;
7+
private String name;
8+
private Integer roleLevel;
9+
private String description;
10+
private String menuItems;
11+
12+
public Integer getId() {
13+
return id;
14+
}
15+
public void setId(Integer id) {
16+
this.id = id;
17+
}
18+
public String getName() {
19+
return name;
20+
}
21+
public void setName(String name) {
22+
this.name = name;
23+
}
24+
public Integer getRoleLevel() {
25+
return roleLevel;
26+
}
27+
public void setRoleLevel(Integer roleLevel) {
28+
this.roleLevel = roleLevel;
29+
}
30+
public String getDescription() {
31+
return description;
32+
}
33+
public void setDescription(String description) {
34+
this.description = description;
35+
}
36+
public String getMenuItems() {
37+
return menuItems;
38+
}
39+
40+
public void setMenuItems(String menuItems) {
41+
this.menuItems = menuItems;
42+
}
43+
44+
@Override
45+
public int compareTo(Role o) {
46+
if(id == o.getId()){
47+
return 0;
48+
}else if(id > o.getId()){
49+
return 1;
50+
}else{
51+
return -1;
52+
}
53+
}
54+
55+
@Override
56+
public boolean equals(Object obj) {
57+
// TODO Auto-generated method stub
58+
if(obj instanceof Role){
59+
if(this.id == ((Role)obj).getId()){
60+
return true;
61+
}
62+
}
63+
return false;
64+
}
65+
@Override
66+
public String toString() {
67+
return "Role{" +
68+
"id=" + id +
69+
", name=" + name +
70+
", roleLevel=" + roleLevel +
71+
", description=" + description +
72+
'}';
73+
}
74+
}
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
package com.yy.example.bean;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnore;
4+
import org.springframework.security.core.GrantedAuthority;
5+
import org.springframework.security.core.userdetails.UserDetails;
6+
7+
import java.util.Collection;
8+
import java.util.List;
9+
10+
public class User implements UserDetails {
11+
private Integer id;
12+
private String cnname;
13+
private String username;
14+
@JsonIgnore
15+
private String password;
16+
private String rePassword;
17+
private String historyPassword;
18+
private String email;
19+
@JsonIgnore
20+
private String telephone;
21+
private String mobilePhone;
22+
private List<? extends GrantedAuthority> authorities;
23+
private Role role;
24+
private Integer roleId;
25+
26+
27+
@Override
28+
@JsonIgnore
29+
public boolean isAccountNonExpired() {
30+
return true;
31+
}
32+
33+
@Override
34+
@JsonIgnore
35+
public boolean isAccountNonLocked() {
36+
return true;
37+
}
38+
39+
@Override
40+
@JsonIgnore
41+
public boolean isCredentialsNonExpired() {
42+
return true;
43+
}
44+
45+
@Override
46+
@JsonIgnore
47+
public boolean isEnabled() {
48+
return true;
49+
}
50+
51+
public void setUsername(String username) {
52+
this.username = username;
53+
}
54+
55+
@JsonIgnore
56+
public Collection<? extends GrantedAuthority> getAuthorities() {
57+
return authorities;
58+
}
59+
60+
public void setGrantedAuthorities(List<? extends GrantedAuthority> authorities) {
61+
this.authorities = authorities;
62+
}
63+
64+
public Integer getId() {
65+
return id;
66+
}
67+
68+
public void setId(Integer id) {
69+
this.id = id;
70+
}
71+
72+
public String getCnname() {
73+
return cnname;
74+
}
75+
76+
public void setCnname(String cnname) {
77+
this.cnname = cnname;
78+
}
79+
80+
public String getUsername() {
81+
return username;
82+
}
83+
84+
public String getPassword() {
85+
return password;
86+
}
87+
88+
public void setPassword(String password) {
89+
this.password = password;
90+
}
91+
92+
public String getEmail() {
93+
return email;
94+
}
95+
96+
public void setEmail(String email) {
97+
this.email = email;
98+
}
99+
100+
public String getTelephone() {
101+
return telephone;
102+
}
103+
104+
public void setTelephone(String telephone) {
105+
this.telephone = telephone;
106+
}
107+
108+
public String getMobilePhone() {
109+
return mobilePhone;
110+
}
111+
112+
public void setMobilePhone(String mobilePhone) {
113+
this.mobilePhone = mobilePhone;
114+
}
115+
116+
public String getRePassword() {
117+
return rePassword;
118+
}
119+
120+
public void setRePassword(String rePassword) {
121+
this.rePassword = rePassword;
122+
}
123+
124+
public String getHistoryPassword() {
125+
return historyPassword;
126+
}
127+
128+
public void setHistoryPassword(String historyPassword) {
129+
this.historyPassword = historyPassword;
130+
}
131+
132+
public Role getRole() {
133+
return role;
134+
}
135+
136+
public void setRole(Role role) {
137+
this.role = role;
138+
}
139+
140+
public Integer getRoleId() {
141+
return roleId;
142+
}
143+
144+
public void setRoleId(Integer roleId) {
145+
this.roleId = roleId;
146+
}
147+
@Override
148+
public String toString() {
149+
return "User{" +
150+
"id=" + id +
151+
", cnname=" + cnname +
152+
", username=" + username +
153+
", password=" + password +
154+
", email=" + email +
155+
", telephone=" + telephone +
156+
", mobilePhone=" + mobilePhone +
157+
'}';
158+
}
159+
}

0 commit comments

Comments
 (0)