SpringSecurity開發

RBAC

數據庫權限表結構設計與建立


sys_user表數據庫

CREATE TABLE sysuser
(id INT(10) unsigned PRIMARY KEY NOT NULL COMMENT '用戶ID' AUTO_INCREMENT,
 username VARCHAR(25) COMMENT '用戶名',
 realname VARCHAR(25) COMMENT '真實姓名',
 password VARCHAR(25) COMMENT '密碼',
 email    VARCHAR(50) COMMENT '郵箱',
 phone    VARCHAR(20) COMMENT '電話',

 createDate TIMESTAMP COMMENT '建立日期',
 lastLoginTime TIMESTAMP COMMENT '最後登陸時間',

 enabled VARCHAR(5) COMMENT '是否可用',
 accountNonExpired int(5) COMMENT '是否過時',
 accountNonLocked int(5) COMMENT '是否鎖定',
 credentialNonExpired int(5) COMMENT '證書是否過時'

)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

sys_role表設計

CREATE TABLE sys_role
(id INT(10) unsigned PRIMARY KEY NOT NULL COMMENT '角色ID' AUTO_INCREMENT,
 roleName VARCHAR(25) COMMENT '角色名',
 roleDesc VARCHAR(25) COMMENT '角色說明'
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

sys_permission表code

CREATE TABLE sys_permission
(id INT(10) unsigned PRIMARY KEY NOT NULL COMMENT '權限ID' AUTO_INCREMENT,
 permName VARCHAR(25) COMMENT '權限名',
 permTag VARCHAR(25) COMMENT '權限標識符'
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

sys_user_roleblog

CREATE TABLE sys_user_role
(
 user_id INT(10) COMMENT '用戶ID',
 role_id VARCHAR(25) COMMENT '角色ID'
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

sys_role_permissionio

CREATE TABLE sys_role_permission
(
  role_id INT(10) COMMENT '角色ID',
  permission_id VARCHAR(25) COMMENT '權限ID'
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
相關文章
相關標籤/搜索