From ea667b025814171241a7b13dbb9cf671a7fcb477 Mon Sep 17 00:00:00 2001 From: bseayin Date: Sun, 1 Sep 2019 19:50:02 +0800 Subject: [PATCH] authorization --- .../main/java/com/zz/config/ShiroConfig.java | 4 ++-- .../main/java/com/zz/entity/Permission.java | 19 +++++-------------- .../src/main/java/com/zz/entity/Role.java | 17 ++++------------- .../src/main/java/com/zz/entity/User.java | 1 + 4 files changed, 12 insertions(+), 29 deletions(-) diff --git a/SpringBootShiroAuthorization/src/main/java/com/zz/config/ShiroConfig.java b/SpringBootShiroAuthorization/src/main/java/com/zz/config/ShiroConfig.java index 364af32..80161b7 100644 --- a/SpringBootShiroAuthorization/src/main/java/com/zz/config/ShiroConfig.java +++ b/SpringBootShiroAuthorization/src/main/java/com/zz/config/ShiroConfig.java @@ -60,8 +60,8 @@ public class ShiroConfig { public ShiroRealm shiroRealm(){ ShiroRealm shiroRealm = new ShiroRealm(); return shiroRealm; - } - + } + /** * cookie对象 * @return diff --git a/SpringBootShiroAuthorization/src/main/java/com/zz/entity/Permission.java b/SpringBootShiroAuthorization/src/main/java/com/zz/entity/Permission.java index 138a30a..ed82df7 100644 --- a/SpringBootShiroAuthorization/src/main/java/com/zz/entity/Permission.java +++ b/SpringBootShiroAuthorization/src/main/java/com/zz/entity/Permission.java @@ -4,6 +4,7 @@ import lombok.Data; import org.hibernate.annotations.Proxy; import javax.persistence.*; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -15,7 +16,9 @@ import java.util.List; @Entity @Table(name="T_PERMISSION") @Proxy(lazy = false) -public class Permission { +public class Permission implements Serializable { + + final static long serialVersionUID=23434243325424l; @Id @Column(length = 50) @@ -25,13 +28,7 @@ public class Permission { //url描述 private String name; - // @ManyToMany注释表示Teacher是多对多关系的一端。 - // @JoinTable描述了多对多关系的数据表关系。name属性指定中间表名称,joinColumns定义中间表与Teacher表的外键关系。 - // 中间表Teacher_Student的Teacher_ID列是Teacher表的主键列对应的外键列,inverseJoinColumns属性定义了中间表与另外一端(Student)的外键关系。 - @ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER) - @JoinTable(name = "T_ROLE_PERMISSION", joinColumns = { @JoinColumn(name = "p_id") }, inverseJoinColumns = { - @JoinColumn(name = "r_id") }) - private List roles=new ArrayList<>(); + public String getId() { @@ -58,11 +55,5 @@ public class Permission { this.name = name; } - public List getRoles() { - return roles; - } - public void setRoles(List roles) { - this.roles = roles; - } } diff --git a/SpringBootShiroAuthorization/src/main/java/com/zz/entity/Role.java b/SpringBootShiroAuthorization/src/main/java/com/zz/entity/Role.java index d092d64..ca34619 100644 --- a/SpringBootShiroAuthorization/src/main/java/com/zz/entity/Role.java +++ b/SpringBootShiroAuthorization/src/main/java/com/zz/entity/Role.java @@ -4,6 +4,7 @@ import lombok.Data; import org.hibernate.annotations.Proxy; import javax.persistence.*; +import java.io.Serializable; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -18,7 +19,8 @@ import java.util.Set; @Table(name="T_ROLE") @Proxy(lazy = false) -public class Role { +public class Role implements Serializable { + final static long serialVersionUID=234345424l; @Id @Column(length = 50) @@ -38,11 +40,7 @@ public class Role { - @ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER) - @JoinTable(name = "T_USER_ROLE", joinColumns = { @JoinColumn(name = "r_id") }, - inverseJoinColumns = { - @JoinColumn(name = "u_id") }) - private List users=new ArrayList(); + public String getId() { @@ -77,11 +75,4 @@ public class Role { this.permissions = permissions; } - public List getUsers() { - return users; - } - - public void setUsers(List users) { - this.users = users; - } } diff --git a/SpringBootShiroAuthorization/src/main/java/com/zz/entity/User.java b/SpringBootShiroAuthorization/src/main/java/com/zz/entity/User.java index 2db706e..181cfc7 100644 --- a/SpringBootShiroAuthorization/src/main/java/com/zz/entity/User.java +++ b/SpringBootShiroAuthorization/src/main/java/com/zz/entity/User.java @@ -15,6 +15,7 @@ import javax.persistence.*; @Proxy(lazy = false) public class User implements Serializable{ + final static long serialVersionUID=23424l; @Id @Column(length = 50) private String id;