用户表
create table if not exists `user`( `id` bigint unsigned not null auto_increment comment '主键', `code` varchar(64) not null default '' comment '业务主键', `username` varchar(64) not null default '' comment '用户名称', `password` varchar(64) not null default '' comment '密码', `phone` varchar(32) not null default '' comment '手机号码', `email` varchar(64) not null default '' comment '邮件', `birthday` timestamp null default null comment '出生日期', `address` varchar(256) not null default '' comment '地址', `is_enable` tinyint unsigned not null default 1 comment '是否启用,1表示是,0表示否', `is_delete` tinyint unsigned not null default 0 comment '是否删除,1表示是,0表示否', `version` bigint unsigned not null default 0 comment '版本号', `gmt_create` timestamp not null default current_timestamp comment '创建时间', `creator` varchar(64) not null default '' comment '创建人', `creator_id` bigint unsigned not null default 0 comment '创建人id', `gmt_modified` timestamp not null default current_timestamp on update current_timestamp comment '修改时间', `modifier` varchar(64) not null default '' comment '修改人', `modifier_id` bigint unsigned not null default 0 comment '修改人id', primary key(`id`), unique key uk_code(`code`)) engine=innodb comment '用户信息表';
角色表
create table if not exists `role`( `id` bigint unsigned not null auto_increment comment '主键', `code` varchar(64) not null default '' comment '业务主键', `role_name` varchar(64) not null default '' comment '角色名称', `is_enable` tinyint unsigned not null default 1 comment '是否启用,1表示是,0表示否', `is_delete` tinyint unsigned not null default 0 comment '是否删除,1表示是,0表示否', `version` bigint unsigned not null default 0 comment '版本号', `gmt_create` timestamp not null default current_timestamp comment '创建时间', `creator` varchar(64) not null default '' comment '创建人', `creator_id` bigint unsigned not null default 0 comment '创建人id', `gmt_modified` timestamp not null default current_timestamp on update current_timestamp comment '修改时间', `modifier` varchar(64) not null default '' comment '修改人', `modifier_id` bigint unsigned not null default 0 comment '修改人id', primary key(`id`), unique key uk_code(`code`)) comment '角色表';
用户-角色-中间表
create table if not exists `user_role`(
`id` bigint unsigned not null auto_increment comment '主键',
`code` varchar(64) not null default '' comment '业务主键',
`user_id` bigint unsigned not null comment '用户主键',
`role_id` bigint unsigned not null comment '角色主键',
`is_enable` tinyint unsigned not null default 1 comment '是否启用,1表示是,0表示否',
`is_delete` tinyint unsigned not null default 0 comment '是否删除,1表示是,0表示否',
`version` bigint unsigned not null default 0 comment '版本号',
`gmt_create` timestamp not null default current_timestamp comment '创建时间',
`creator` varchar(64) not null default '' comment '创建人',
`creator_id` bigint unsigned not null default 0 comment '创建人id',
`gmt_modified` timestamp not null default current_timestamp on update current_timestamp comment '修改时间',
`modifier` varchar(64) not null default '' comment '修改人',
`modifier_id` bigint unsigned not null default 0 comment '修改人id',
primary key(`id`),
unique key uk_code(`code`)
)comment '用户-角色关系中间表';
权限表
create table if not exists `role_permission`(
`id` bigint unsigned not null auto_increment comment '主键',
`code` varchar(64) not null default '' comment '业务主键',
`role_id` bigint unsigned not null auto_increment comment '角色主键',
`permission_id` bigint unsigned not null auto_increment comment '权限主键',
`is_enable` tinyint unsigned not null default 1 comment '是否启用,1表示是,0表示否',
`is_delete` tinyint unsigned not null default 0 comment '是否删除,1表示是,0表示否',
`version` bigint unsigned not null default 0 comment '版本号',
`gmt_create` timestamp not null default current_timestamp comment '创建时间',
`creator` varchar(64) not null default '' comment '创建人',
`creator_id` bigint unsigned not null default 0 comment '创建人id',
`gmt_modified` timestamp not null default current_timestamp on update current_timestamp comment '修改时间',
`modifier` varchar(64) not null default '' comment '修改人',
`modifier_id` bigint unsigned not null default 0 comment '修改人id',
) comment '角色权限中间表';
角色-权限-中间表
create table if not exists `permission`(
`id` bigint unsigned not null auto_increment comment '主键',
`code` varchar(64) not null default '' comment '业务主键',
`permission_name` varchar(64) not null default '' comment '权限描述名称',
`permission_url` varchar(64) not null default '' comment '权限url',
`is_enable` tinyint unsigned not null default 1 comment '是否启用,1表示是,0表示否',
`is_delete` tinyint unsigned not null default 0 comment '是否删除,1表示是,0表示否',
`version` bigint unsigned not null default 0 comment '版本号',
`gmt_create` timestamp not null default current_timestamp comment '创建时间',
`creator` varchar(64) not null default '' comment '创建人',
`creator_id` bigint unsigned not null default 0 comment '创建人id',
`gmt_modified` timestamp not null default current_timestamp on update current_timestamp comment '修改时间',
`modifier` varchar(64) not null default '' comment '修改人',
`modifier_id` bigint unsigned not null default 0 comment '修改人id',
primary key(`id`),
unique key uk_code(`code`)
) comment '角色表';