Java Enterprise Rights Management project notes (d) - - - rights management system core table design

The reason as to why you want to write their own set of rights management system?

  1. Be configured to meet the requirements of the frame
  2. No interface operation and viewing
  3. Expect more detailed management

The company where the author, rights management system used in the project is not using SpringSecurity or SpringShiro this framework, the reason: both of the above three reasons, the most important point, these two frameworks for developers not very friendly, and therefore, permission to use their own development projects management. And it is the main developer of the rights management system, but due to the demand of the project permissions system, so learning a lesson Mu courses, in-depth understanding of the core rights management, increase the corresponding capacity.

First, the rights management project to be developed content

Functional Configuration Management

Permission to intercept Functional

Auxiliary Functional: buffer (Redis), various tree structures generated

Second, the functional components:

1, Configuration Management features:

  • User permissions, role management interface (with extensions: department, authority module)
  • Role - user management, role - authority management
  • Permission to update log management

2, permission to intercept class features:

  • In section (Filter) to intercept permission to do
  • Determine whether the user has a permission

3, auxiliary class features:

  • Cache (, Redi) packaging and use
  • All kinds of trees: tree department, authority module tree, the tree role permissions, user rights trees
  • Permissions recovery operation

Third, the detailed structural design table

Design specifications:

 Each table has its own primary key;

It is defined as a possible field NOT NULL;

Try to add notes for each field;

Lowercase unified database fields, separated by an underscore between words;

Using the InnoDB storage engine;

You can use varchar fields do not use TEXT, BLOB type as far as possible;

UTF8 character set selection table

Detailed table structure design:

           

1, the department table

CREATE TABLE `sys_dept` (
`id`  int NOT NULL AUTO_INCREMENT COMMENT '部门id' , `name` varchar(20) NOT NULL COMMENT '部门名称' , `parent_id` int NOT NULL DEFAULT 0 COMMENT '上级部门id' , `level` varchar(200) NOT NULL DEFAULT '' COMMENT '部门层级' , `seq` int NOT NULL DEFAULT 0 COMMENT '部门在当前层级下的顺序。由小到大排序' , `remark` varchar(200) NULL DEFAULT '' COMMENT '备注' , `operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者' , `operator_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '最后一次操作时间' , `operator_ip` varchar(20) NOT NULL DEFAULT '' COMMENT '最后一次更新操作者ip' , PRIMARY KEY (`id`) );

2, the user table

CREATE TABLE `sys_user` (
`id`  int NOT NULL AUTO_INCREMENT COMMENT 'user id' , `username` varchar(20) NOT NULL DEFAULT '' COMMENT '用户名字' , `telephone` varchar(13) NOT NULL DEFAULT '' COMMENT '联系方式' , `mail` varchar(20) NOT NULL DEFAULT '' COMMENT '邮箱' , `password` varchar(40) NOT NULL DEFAULT '' COMMENT '密码' , `dept_id` int NOT NULL DEFAULT 0 COMMENT '部门id' , `status` int NOT NULL COMMENT '用户状态' , `remark` varchar(200) NULL DEFAULT '' COMMENT '备注' , `operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者' , `operator_time` datetime NOT NULL DEFAULT now() ON UPDATE CURRENT_TIMESTAMP COMMENT '最后一次操作时间' , `operator_ip` varchar(20) NOT NULL , PRIMARY KEY (`id`) );

3, permissions module table

CREATE TABLE `sys_acl_module` (
`id`  int NOT NULL AUTO_INCREMENT COMMENT '权限id' , `name` varchar(20) NOT NULL COMMENT '权限名称' , `parent_id` int NOT NULL DEFAULT 0 COMMENT '上级权限id' , `level` varchar(200) NOT NULL DEFAULT '' COMMENT '权限层级' , `seq` int NOT NULL DEFAULT 0 COMMENT '权限在当前层级下的顺序。由小到大排序' , `status` int NOT NULL DEFAULT 0 COMMENT '1表示可用,0表示失效' , `remark` varchar(200) NULL DEFAULT '' COMMENT '备注' , `operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者' , `operator_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '最后一次操作时间' , `operator_ip` varchar(20) NOT NULL DEFAULT '' COMMENT '最后一次更新操作者ip' , PRIMARY KEY (`id`) );

4, permissions table

CREATE TABLE `sys_acl` (
`id`  int NOT NULL AUTO_INCREMENT COMMENT '权限id' , `code` varchar(20) NOT NULL DEFAULT '' COMMENT '权限码' , `name` varchar(20) NOT NULL DEFAULT '' COMMENT '权限名称' , `acl_module_id` int NOT NULL DEFAULT 0 COMMENT '权限所在模块的id' , `url` varchar(100) NOT NULL DEFAULT '' COMMENT '请求的url,可用填正则表达式' , `type` int NOT NULL DEFAULT 1 COMMENT '类型1:菜单;2:按钮;3:其他' , `status` int NOT NULL DEFAULT 1 COMMENT '状态:1:正常;2:冻结' , `seq` int NOT NULL COMMENT '权限在当前模块下的顺序' , `remark` varchar(200) NULL DEFAULT '' COMMENT '备注' , `operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者' , `operator_time` datetime NOT NULL DEFAULT now() ON UPDATE CURRENT_TIMESTAMP COMMENT '最后操作时间' , `operator_ip` varchar(20) NOT NULL DEFAULT '' COMMENT '最后操作者的ip' , PRIMARY KEY (`id`) );

5, the role of table

CREATE TABLE `sys_role` (
`id`  int NOT NULL AUTO_INCREMENT COMMENT '角色id' , `name` varchar(20) NOT NULL DEFAULT '' COMMENT '角色名称' , `type` int NOT NULL DEFAULT 2 COMMENT '角色类型1:管理员。2:其他用户' , `status` int NOT NULL DEFAULT 1 COMMENT '状态:1:正常;2:冻结' , `remark` varchar(200) NULL DEFAULT '' COMMENT '备注' , `operator` varchar(20) NOT NULL DEFAULT '' , `operator_time` datetime NOT NULL DEFAULT now() ON UPDATE CURRENT_TIMESTAMP , `opeator_ip` varchar(20) NOT NULL DEFAULT '' , PRIMARY KEY (`id`) );

6, the role of the user associated table

CREATE TABLE `sys_role_user` (
`id`  int NOT NULL AUTO_INCREMENT , `role_id` int NOT NULL COMMENT '角色id' , `user_id` int NOT NULL COMMENT '用户id' , `operator` varchar(20) NOT NULL , `operator_time` datetime NOT NULL DEFAULT now() ON UPDATE CURRENT_TIMESTAMP , `operator_ip` varchar(20) NOT NULL , PRIMARY KEY (`id`) );

7. Role - privileges associated table

CREATE TABLE `sys_role_acl` (
`id`  int NOT NULL AUTO_INCREMENT , `role_id` int NOT NULL COMMENT '角色id' , `acl_id` int NOT NULL COMMENT '权限id' , `operator` varchar(20) NOT NULL , `operator_time` datetime NOT NULL DEFAULT now() ON UPDATE CURRENT_TIMESTAMP , `operator_ip` varchar(20) NOT NULL , PRIMARY KEY (`id`) );

8, the relevant authority to update records in the table

CREATE TABLE `sys_log` (
`id`  int NOT NULL AUTO_INCREMENT COMMENT 'id' , `type` int NOT NULL DEFAULT 0 COMMENT '权限更新的类型:1:部门;2:用户;3:权限模块;4:权限;5:角色;6:角色用户关系;7:角色权限关系;' , `target_id` int NOT NULL COMMENT '基于type指定的对象id,比如用户、角色、权限表的主键' , `old_value` text NOT NULL , `new_value` text NOT NULL , `operator` varchar(255) NOT NULL , `operator_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP , `operator_ip` varchar(255) NOT NULL , `status` int NOT NULL COMMENT '当前是否复原过0:没有;1:有' , PRIMARY KEY (`id`) );

note: 

            datetime type only supports M ysql5.6.5 above version.

            The following versions of the  datetime  into  TIMESTAMP  can be.

Guess you like

Origin www.cnblogs.com/wushaopei/p/11681415.html