RBAC权限管理系统数据模型

懒得多写了,懂的看建表脚本就懂了。。。

-- ----------------------------
-- Table structure for ucb_user
-- ----------------------------
DROP TABLE IF EXISTS `ucb_user`;
CREATE TABLE `ucb_user` (
  `id` char(32) NOT NULL COMMENT '主键(UUID)',
  `user_type` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '用户类型:0、未定义;1、内部用户;2、合作方用户;3、外部用户',
  `source` tinyint(3) DEFAULT '0' COMMENT '来源',
  `code` varchar(8) DEFAULT NULL COMMENT '用户编码',
  `name` varchar(64) NOT NULL COMMENT '名称',
  `account` varchar(64) NOT NULL COMMENT '登录账号',
  `mobile` varchar(32) DEFAULT NULL COMMENT '手机号',
  `email` varchar(64) DEFAULT NULL COMMENT '电子邮箱',
  `union_id` varchar(128) DEFAULT NULL COMMENT '微信UnionID',
  `password` varchar(256) NOT NULL DEFAULT 'e10adc3949ba59abbe56e057f20f883e' COMMENT '密码(RSA加密)',
  `paypw` char(32) DEFAULT NULL COMMENT '支付密码(MD5)',
  `head_img` varchar(256) DEFAULT NULL COMMENT '用户头像',
  `remark` varchar(256) DEFAULT NULL COMMENT '备注',
  `setting` json DEFAULT NULL COMMENT '配置信息',
  `invite_code` varchar(32) DEFAULT NULL COMMENT '邀请码',
  `inviter` varchar(64) DEFAULT NULL COMMENT '邀请人',
  `inviter_id` char(32) DEFAULT NULL COMMENT '邀请人ID',
  `is_builtin` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否内置:0、非内置;1、内置',
  `is_invalid` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否失效:0、有效;1、失效',
  `creator` varchar(64) NOT NULL COMMENT '创建人',
  `creator_id` char(32) NOT NULL COMMENT '创建人ID',
  `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_ucb_user_code` (`code`) USING BTREE,
  KEY `idx_ucb_user_invite_code` (`invite_code`) USING BTREE,
  UNIQUE KEY `idx_ucb_user_account` (`account`) USING BTREE,
  UNIQUE KEY `idx_ucb_user_mobile` (`mobile`) USING BTREE,
  UNIQUE KEY `idx_ucb_user_email` (`email`) USING BTREE,
  UNIQUE KEY `idx_ucb_user_union_id` (`union_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='用户表';

-- ----------------------------
-- Table structure for ucg_group
-- ----------------------------
DROP TABLE IF EXISTS `ucg_group`;
CREATE TABLE `ucg_group` (
  `id` char(32) NOT NULL COMMENT '主键(UUID)',
  `name` varchar(64) NOT NULL COMMENT '名称',
  `remark` varchar(256) DEFAULT NULL COMMENT '备注',
  `is_builtin` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否内置:0、非内置;1、内置',
  `creator` varchar(64) NOT NULL COMMENT '创建人',
  `creator_id` char(32) NOT NULL COMMENT '创建人ID',
  `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_ucg_group_tenant_id` (`tenant_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='用户组表';

-- ----------------------------
-- Table structure for ucg_group_member
-- ----------------------------
DROP TABLE IF EXISTS `ucg_group_member`;
CREATE TABLE `ucg_group_member` (
  `id` char(32) NOT NULL COMMENT '主键(UUID)',
  `group_id` char(32) NOT NULL COMMENT '用户组ID',
  `user_id` char(32) NOT NULL COMMENT '用户ID',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_ucg_group_member_group_id` (`group_id`) USING BTREE,
  KEY `idx_ucg_group_member_user_id` (`user_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='用户组成员表';

-- ----------------------------
-- Table structure for uco_org
-- ----------------------------
DROP TABLE IF EXISTS `uco_org`;
CREATE TABLE `uco_org` (
  `id` char(32) NOT NULL COMMENT '主键(UUID)',
  `parent_id` char(32) DEFAULT NULL COMMENT '父级ID',
  `node_type` tinyint(3) unsigned DEFAULT NULL COMMENT '节点类型:0、机构;1、部门;2、职位',
  `index` tinyint(3) unsigned NOT NULL COMMENT '序号',
  `code` varchar(8) DEFAULT NULL COMMENT '编码',
  `name` varchar(64) NOT NULL COMMENT '名称',
  `alias` varchar(64) DEFAULT NULL COMMENT '简称',
  `full_name` varchar(128) DEFAULT NULL COMMENT '全称',
  `remark` varchar(256) DEFAULT NULL COMMENT '备注',
  `is_invalid` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否失效:0、有效;1、失效',
  `creator` varchar(64) NOT NULL COMMENT '创建人',
  `creator_id` char(32) NOT NULL COMMENT '创建人ID',
  `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `idx_uco_org_code` (`code`) USING BTREE,
  KEY `idx_uco_org_tenant_id` (`tenant_id`) USING BTREE,
  KEY `idx_uco_org_parent_id` (`parent_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='组织机构表';

-- ----------------------------
-- Table structure for uco_org_member
-- ----------------------------
DROP TABLE IF EXISTS `uco_org_member`;
CREATE TABLE `uco_org_member` (
  `id` char(32) NOT NULL COMMENT '主键(UUID)',
  `org_id` char(32) NOT NULL COMMENT '职位ID(组织机构表ID)',
  `user_id` char(32) NOT NULL COMMENT '用户ID(用户表ID)',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_uco_org_member_org_id` (`org_id`) USING BTREE,
  KEY `idx_uco_org_member_user_id` (`user_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='职位成员表';

-- ----------------------------
-- Table structure for ucs_application
-- ----------------------------
DROP TABLE IF EXISTS `ucs_application`;
CREATE TABLE `ucs_application` (
  `id` char(32) NOT NULL COMMENT '主键(UUID)',
  `index` int(11) unsigned NOT NULL COMMENT '序号',
  `name` varchar(64) NOT NULL COMMENT '应用名称',
  `alias` varchar(64) NOT NULL COMMENT '应用简称',
  `icon` varchar(128) DEFAULT NULL COMMENT '应用图标',
  `host` varchar(128) DEFAULT NULL COMMENT '应用域名',
  `token_life` int(10) unsigned NOT NULL DEFAULT '24' COMMENT '令牌生命周期(毫秒)',
  `is_signin_one` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否单点登录:0、允许多点;1、单点登录',
  `is_auto_refresh` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否自动刷新:0、手动刷新;1、自动刷新()',
  `creator` varchar(64) NOT NULL COMMENT '创建人',
  `creator_id` char(32) NOT NULL COMMENT '创建用户ID',
  `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='应用表';

-- ----------------------------
-- Table structure for ucs_navigator
-- ----------------------------
DROP TABLE IF EXISTS `ucs_navigator`;
CREATE TABLE `ucs_navigator` (
  `id` char(32) NOT NULL COMMENT '主键(UUID)',
  `parent_id` char(32) DEFAULT NULL COMMENT '父级导航ID',
  `app_id` char(32) NOT NULL COMMENT '应用ID',
  `type` tinyint(3) unsigned NOT NULL COMMENT '导航级别',
  `index` int(11) unsigned NOT NULL COMMENT '序号',
  `name` varchar(64) NOT NULL COMMENT '名称',
  `icon` varchar(128) DEFAULT NULL COMMENT '图标Url',
  `url` varchar(128) DEFAULT NULL COMMENT '模块/页面Url',
  `remark` varchar(256) DEFAULT NULL COMMENT '备注',
  `creator` varchar(64) NOT NULL COMMENT '创建人',
  `creator_id` char(32) NOT NULL COMMENT '创建用户ID',
  `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_ucs_navigator_app_id` (`app_id`) USING BTREE,
  KEY `idx_ucs_navigator_parent_id` (`parent_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='导航表';

-- ----------------------------
-- Table structure for ucs_function
-- ----------------------------
DROP TABLE IF EXISTS `ucs_function`;
CREATE TABLE `ucs_function` (
  `id` char(32) NOT NULL COMMENT '主键(UUID)',
  `nav_id` char(32) NOT NULL COMMENT '导航(末级模块)ID',
  `type` tinyint(3) unsigned NOT NULL COMMENT '功能类型 0:全局功能;1:数据项功能;2:其他功能',
  `code` varchar(16) DEFAULT NULL COMMENT '代码',
  `index` int(11) unsigned NOT NULL COMMENT '序号',
  `name` varchar(64) NOT NULL COMMENT '名称',
  `alias` varchar(64) DEFAULT NULL COMMENT '别名',
  `icon` varchar(128) DEFAULT NULL COMMENT '图标Url',
  `url` varchar(128) DEFAULT NULL COMMENT '功能URL',
  `interfaces` varchar(512) DEFAULT NULL COMMENT '接口URL,功能对应多个URL以逗号分隔(不含域名及端口号)',
  `remark` varchar(256) DEFAULT NULL COMMENT '备注',
  `begin_group` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否开始分组',
  `hide_text` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否隐藏文字',
  `is_invisible` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否不可见:0、可见;1、不可见',
  `creator` varchar(64) NOT NULL COMMENT '创建人',
  `creator_id` char(32) NOT NULL COMMENT '创建用户ID',
  `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_ucs_function_nav_id` (`nav_id`) USING BTREE,
  KEY `idx_ucs_function_alias` (`alias`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='功能表';

-- ----------------------------
-- Table structure for ucr_config
-- ----------------------------
DROP TABLE IF EXISTS `ucr_config`;
CREATE TABLE `ucr_config` (
  `id` char(32) NOT NULL COMMENT '主键(UUID)',
  `data_type` int(3) unsigned NOT NULL COMMENT '类型:0、无归属;1、仅本人;2、仅本部门;3、部门所有;4、机构所有',
  `name` varchar(32) NOT NULL COMMENT '名称',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_ucr_role_data_permit_data_type` (`data_type`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='数据配置表';

-- ----------------------------
-- Table structure for ucr_role
-- ----------------------------
DROP TABLE IF EXISTS `ucr_role`;
CREATE TABLE `ucr_role` (
  `id` char(32) NOT NULL COMMENT '主键(UUID)',
  `app_id` char(32) DEFAULT NULL COMMENT '应用ID,如不为空则该角色为应用专有',
  `name` varchar(64) NOT NULL COMMENT '名称',
  `remark` varchar(256) DEFAULT NULL COMMENT '备注',
  `is_builtin` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否内置:0、非内置;1、内置',
  `creator` varchar(64) NOT NULL COMMENT '创建人',
  `creator_id` char(32) NOT NULL COMMENT '创建人ID',
  `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_ucr_role_tenant_id` (`tenant_id`) USING BTREE,
  KEY `idx_ucr_role_app_id` (`app_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='角色表';

-- ----------------------------
-- Table structure for ucr_role_func_permit
-- ----------------------------
DROP TABLE IF EXISTS `ucr_role_func_permit`;
CREATE TABLE `ucr_role_func_permit` (
  `id` char(32) NOT NULL COMMENT '主键(UUID)',
  `role_id` char(32) NOT NULL COMMENT '角色ID',
  `function_id` char(32) NOT NULL COMMENT '功能ID',
  `permit` bit(1) NOT NULL DEFAULT b'0' COMMENT '授权类型:0、拒绝;1、允许',
  `creator` varchar(64) NOT NULL COMMENT '创建人',
  `creator_id` char(32) NOT NULL COMMENT '创建人ID',
  `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_ucr_role_func_permit_role_id` (`role_id`) USING BTREE,
  KEY `idx_ucr_role_func_permit_function_id` (`function_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='角色功能权限表';

-- ----------------------------
-- Table structure for ucr_role_data_permit
-- ----------------------------
DROP TABLE IF EXISTS `ucr_role_data_permit`;
CREATE TABLE `ucr_role_data_permit` (
  `id` char(32) NOT NULL COMMENT '主键(UUID)',
  `role_id` char(32) NOT NULL COMMENT '角色ID',
  `module_id` char(32) NOT NULL COMMENT '业务模块ID',
  `mode` int(3) unsigned NOT NULL COMMENT '授权模式:0、相对模式;1、用户模式;2、部门模式',
  `owner_id` char(32) NOT NULL COMMENT '数据所有者ID,相对模式下为模式ID',
  `permit` bit(1) NOT NULL DEFAULT b'0' COMMENT '授权类型:0、只读;1、读写',
  `creator` varchar(64) NOT NULL COMMENT '创建人',
  `creator_id` char(32) NOT NULL COMMENT '创建人ID',
  `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_ucr_role_data_permit_role_id` (`role_id`) USING BTREE,
  KEY `idx_ucr_role_data_permit_module_id` (`module_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='角色数据权限表';

-- ----------------------------
-- Table structure for ucr_role_member
-- ----------------------------
DROP TABLE IF EXISTS `ucr_role_member`;
CREATE TABLE `ucr_role_member` (
  `id` char(32) NOT NULL COMMENT '主键(UUID)',
  `type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '成员类型:0、未定义;1、用户;2、用户组;3、职位',
  `role_id` char(32) NOT NULL COMMENT '角色ID',
  `member_id` char(32) NOT NULL COMMENT '成员ID',
  `creator` varchar(64) NOT NULL COMMENT '创建人',
  `creator_id` char(32) NOT NULL COMMENT '创建人ID',
  `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_ucr_role_member_role_id` (`role_id`) USING BTREE,
  KEY `idx_ucr_role_member_member_id` (`member_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='角色成员表';

你可能感兴趣的:(RBAC权限管理系统数据模型)