authorization

master
bseayin 2019-09-01 19:50:02 +08:00
parent 702cf6e2a4
commit ea667b0258
4 changed files with 12 additions and 29 deletions

View File

@ -60,8 +60,8 @@ public class ShiroConfig {
public ShiroRealm shiroRealm(){ public ShiroRealm shiroRealm(){
ShiroRealm shiroRealm = new ShiroRealm(); ShiroRealm shiroRealm = new ShiroRealm();
return shiroRealm; return shiroRealm;
} }
/** /**
* cookie * cookie
* @return * @return

View File

@ -4,6 +4,7 @@ import lombok.Data;
import org.hibernate.annotations.Proxy; import org.hibernate.annotations.Proxy;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -15,7 +16,9 @@ import java.util.List;
@Entity @Entity
@Table(name="T_PERMISSION") @Table(name="T_PERMISSION")
@Proxy(lazy = false) @Proxy(lazy = false)
public class Permission { public class Permission implements Serializable {
final static long serialVersionUID=23434243325424l;
@Id @Id
@Column(length = 50) @Column(length = 50)
@ -25,13 +28,7 @@ public class Permission {
//url描述 //url描述
private String name; 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<Role> roles=new ArrayList<>();
public String getId() { public String getId() {
@ -58,11 +55,5 @@ public class Permission {
this.name = name; this.name = name;
} }
public List<Role> getRoles() {
return roles;
}
public void setRoles(List<Role> roles) {
this.roles = roles;
}
} }

View File

@ -4,6 +4,7 @@ import lombok.Data;
import org.hibernate.annotations.Proxy; import org.hibernate.annotations.Proxy;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -18,7 +19,8 @@ import java.util.Set;
@Table(name="T_ROLE") @Table(name="T_ROLE")
@Proxy(lazy = false) @Proxy(lazy = false)
public class Role { public class Role implements Serializable {
final static long serialVersionUID=234345424l;
@Id @Id
@Column(length = 50) @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<User> users=new ArrayList<User>();
public String getId() { public String getId() {
@ -77,11 +75,4 @@ public class Role {
this.permissions = permissions; this.permissions = permissions;
} }
public List<User> getUsers() {
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
} }

View File

@ -15,6 +15,7 @@ import javax.persistence.*;
@Proxy(lazy = false) @Proxy(lazy = false)
public class User implements Serializable{ public class User implements Serializable{
final static long serialVersionUID=23424l;
@Id @Id
@Column(length = 50) @Column(length = 50)
private String id; private String id;