用户表

  1. create table if not exists `user`(
  2. `id` bigint unsigned not null auto_increment comment '主键',
  3. `code` varchar(64) not null default '' comment '业务主键',
  4. `username` varchar(64) not null default '' comment '用户名称',
  5. `password` varchar(64) not null default '' comment '密码',
  6. `phone` varchar(32) not null default '' comment '手机号码',
  7. `email` varchar(64) not null default '' comment '邮件',
  8. `birthday` timestamp null default null comment '出生日期',
  9. `address` varchar(256) not null default '' comment '地址',
  10. `is_enable` tinyint unsigned not null default 1 comment '是否启用,1表示是,0表示否',
  11. `is_delete` tinyint unsigned not null default 0 comment '是否删除,1表示是,0表示否',
  12. `version` bigint unsigned not null default 0 comment '版本号',
  13. `gmt_create` timestamp not null default current_timestamp comment '创建时间',
  14. `creator` varchar(64) not null default '' comment '创建人',
  15. `creator_id` bigint unsigned not null default 0 comment '创建人id',
  16. `gmt_modified` timestamp not null default current_timestamp on update current_timestamp comment '修改时间',
  17. `modifier` varchar(64) not null default '' comment '修改人',
  18. `modifier_id` bigint unsigned not null default 0 comment '修改人id',
  19. primary key(`id`),
  20. unique key uk_code(`code`)
  21. ) engine=innodb comment '用户信息表';

角色表

  1. create table if not exists `role`(
  2. `id` bigint unsigned not null auto_increment comment '主键',
  3. `code` varchar(64) not null default '' comment '业务主键',
  4. `role_name` varchar(64) not null default '' comment '角色名称',
  5. `is_enable` tinyint unsigned not null default 1 comment '是否启用,1表示是,0表示否',
  6. `is_delete` tinyint unsigned not null default 0 comment '是否删除,1表示是,0表示否',
  7. `version` bigint unsigned not null default 0 comment '版本号',
  8. `gmt_create` timestamp not null default current_timestamp comment '创建时间',
  9. `creator` varchar(64) not null default '' comment '创建人',
  10. `creator_id` bigint unsigned not null default 0 comment '创建人id',
  11. `gmt_modified` timestamp not null default current_timestamp on update current_timestamp comment '修改时间',
  12. `modifier` varchar(64) not null default '' comment '修改人',
  13. `modifier_id` bigint unsigned not null default 0 comment '修改人id',
  14. primary key(`id`),
  15. unique key uk_code(`code`)
  16. ) 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 '角色表';