08 SSM integration case (enterprise rights management system): 08 access control

Basic introduction of 04.AdminLTE

Basic introduction 05.SSM integration case

06. Product Operation

07. Order Operation

08. Access Control

09. User Action

10. Control permissions associated with

11.AOP log

08. Access Control 

SSM permission to operate

 


 

 

 1. The database table structure

 1.1 user table 

User information table describes users

  oracle database

-- 1.1.2 sql语句
CREATE TABLE users(
id varchar2(32) default SYS_GUID() PRIMARY KEY,
email VARCHAR2(50) UNIQUE NOT NULL,
username VARCHAR2(50),
PASSWORD VARCHAR2(50),
phoneNum VARCHAR2(20),
STATUS INT
)

  Entity class

Package cn.bjut.ssm.domain; 

Import java.util.List; 

public  class the UserInfo {
     Private String ID;
     Private String username;
     Private String In Email;
     Private String password;
     Private String phoneNum;
     Private Integer Status;
     // ==== == member variables other entity class List <E> ================ 
    Private String statusStr;
     Private List <Role> Roles; 

    public String getStatusStr () {
         // state 0 1 open unopened 
        IF (status =! null ) {
            IF (Status == 0 ) 
                statusStr = "unopened" ;
             IF (Status ==. 1 ) 
                statusStr = "Open" ; 
        } 
        
        return statusStr; 
    } 

    public  void setStatusStr (String statusStr) {
         the this .statusStr = statusStr; 
    } 
    // = other ========= get / set methods ===============

 

 

 1.2 Role table 

 

-- 1.2.2 sql语句
CREATE TABLE role(
id varchar2(32) default SYS_GUID() PRIMARY KEY,
roleName VARCHAR2(50) ,
roleDesc VARCHAR2(50)
)

  

package cn.bjut.ssm.domain;

import org.springframework.security.core.userdetails.User;

import java.util.List;

    public class Role {
    private String id;
    private String roleName;
    private String roleDesc;
    private List<Permission> permissions;
    private List<User> users;
    //=====Role与User以及Permission都是多对多的关系

 

1.2.3  User roles associated with relations

Are many relationships between users and roles, we passed user_role to describe its associated table, the entity class User presence in the List , in Role there in List 

 

-- 用户与角色关联表
CREATE TABLE users_role(
userId varchar2(32),
roleId varchar2(32),
PRIMARY KEY(userId,roleId),
FOREIGN KEY (userId) REFERENCES users(id),
FOREIGN KEY (roleId) REFERENCES role(id)
)

 

 

1.3 Resource permissions table

 

 

-- 1.3.2 sql语句
CREATE TABLE permission(
id varchar2(32) default SYS_GUID() PRIMARY KEY,
permissionName VARCHAR2(50) ,
url VARCHAR2(50)
)

  

package cn.bjut.ssm.domain;

import java.util.List;

public class Permission {
    private String id;
    private String permissionName;
    private String url;
    private List<Role> roles;
    //=====存在一对多关系,则在一的实体类中的成员变量类型是多的List<E>
    //=====存在一对多关系,则在一的实体类中的成员变量名称是多的names

 1.3.3.权限资源与角色关联关系 

 权限资源与角色是多对多关系,我们使用role_permission表来描述。在实体类Permission中存在List,Role类中List

- permission resources and roles are many relationships 
the CREATE  TABLE role_permission ( 
permissionId VARCHAR2 ( 32 ), 
roleId VARCHAR2 ( 32 ),
 PRIMARY  KEY (permissionId, roleId),
 a FOREIGN  KEY (permissionId) the REFERENCES permission (the above mentioned id),
 a FOREIGN  KEY (roleId ) the REFERENCES Role (the above mentioned id) 
)

 

 


 

2.Spring Security Overview

 

 

 

 

 

 

 

 

===============

end

Guess you like

Origin www.cnblogs.com/MarlonKang/p/11570327.html