SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for bc_property_map
-- ----------------------------
DROP TABLE IF EXISTS `bc_property_map`;
CREATE TABLE `bc_property_map`  (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '属性Id，property_id',
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '属性中文说明',
  `parent_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '父编码',
  `code` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '属性英文说明，简称编码（与属性键字段联合唯一）',
  `key` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '属性键，（与属性编码字段联合唯一）',
  `val` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '属性值',
  `sort` int(10) UNSIGNED NULL DEFAULT 0 COMMENT '排序',
  `status` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态，0为禁用，1为启用',
  `remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注',
  `create_user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_code_key`(`code`, `key`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 230 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '属性映射表，表简写 bpm' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for uc_permission
-- ----------------------------
DROP TABLE IF EXISTS `uc_permission`;
CREATE TABLE `uc_permission`  (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '权限Id，per_id',
  `parent_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '父节点Id，根目录统一为0',
  `per_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '权限编码（用于前端控制）',
  `per_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '权限名',
  `path` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '节点路径',
  `per_url` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '访问地址',
  `per_icon` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '权限图标',
  `per_type` char(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '权限类型，菜单与普通按钮（MENU,BUTTON）',
  `sort` int(10) UNSIGNED NULL DEFAULT 0 COMMENT '排序，从小到大',
  `system_type` tinyint(3) UNSIGNED NULL DEFAULT 1 COMMENT '系统类型，具体数值看配置表',
  `status` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态，0为禁用，1为启用',
  `remark` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注',
  `create_user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1259 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '权限表，表简写 up' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for uc_role
-- ----------------------------
DROP TABLE IF EXISTS `uc_role`;
CREATE TABLE `uc_role`  (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '角色ID，role_id',
  `role_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色名',
  `status` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态，1为启用，0为禁用',
  `remark` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注',
  `create_user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_role_name`(`role_name`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色表，表简写 ur' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for uc_role_per
-- ----------------------------
DROP TABLE IF EXISTS `uc_role_per`;
CREATE TABLE `uc_role_per`  (
  `role_id` int(10) UNSIGNED NOT NULL COMMENT '角色Id',
  `per_id` int(10) UNSIGNED NOT NULL COMMENT '权限Id',
  PRIMARY KEY (`role_id`, `per_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色与权限关系表，表简写 urp' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for uc_route
-- ----------------------------
DROP TABLE IF EXISTS `uc_route`;
CREATE TABLE `uc_route`  (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '路由Id，route_id',
  `system_type` tinyint(3) UNSIGNED NULL DEFAULT 0 COMMENT '系统类型，具体数值看配置表',
  `route_type` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '接口类型，具体数值看配置表',
  `button_perm` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '前端按钮权限',
  `http_method` char(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '请求方法',
  `route_path` varchar(190) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '路由路径',
  `middlewares` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '中间件',
  `method_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '方法名',
  `method_desc` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '方法描述',
  `status` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态，0为禁用，1为启用',
  `update_user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_apptype_routetype_routepath`(`system_type`, `route_type`, `route_path`) USING BTREE,
  UNIQUE INDEX `uk_button_perm`(`button_perm`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11361 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '路由表，表简写 urt' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for uc_user
-- ----------------------------
DROP TABLE IF EXISTS `uc_user`;
CREATE TABLE `uc_user`  (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '用户Id，user_id',
  `user_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户登录名',
  `login_name` char(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '登录（电话）',
  `password` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '密码，限制6-15位需要md5加密',
  `organ_id` int(10) UNSIGNED NULL DEFAULT 0 COMMENT '所属机构',
  `realname` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '姓名',
  `sex` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '性别，1男，2女，0保密',
  `role_ids` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '角色列表，以英文逗号分隔，0 表示无角色',
  `email` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '邮箱',
  `is_super` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '是否超级管理员，0否，1是',
  `status` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态，1启用，0禁用',
  `last_login_time` datetime NULL DEFAULT NULL COMMENT '最后登陆时间',
  `login_error` tinyint(3) NULL DEFAULT 0 COMMENT '输错一次+1成功后重置为0，5次后锁定',
  `remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注',
  `create_user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_login_name`(`login_name`) USING BTREE,
  INDEX `uk_user_name`(`user_name`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 262 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户表，表简写 uu' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user`  (
  `user_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增用户id',
  `status` tinyint(2) UNSIGNED NOT NULL DEFAULT 0 COMMENT '用户状态 0 为正常；1 禁用；2 冻结；3 注销',
  `business_status` tinyint(2) UNSIGNED NOT NULL DEFAULT 0 COMMENT '转换工商身份状态；0：未转换，1：转换中，2：已转换',
  `is_signed` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否有签约过',
  `is_authenticate` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否已完成认证',
  `is_newuser` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '是否是新用户',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
  PRIMARY KEY (`user_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 29 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '全局用户表，用于适配多端' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wechat_info
-- ----------------------------
DROP TABLE IF EXISTS `wechat_info`;
CREATE TABLE `wechat_info`  (
  `wx_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增用户id',
  `user_id` int(11) UNSIGNED NOT NULL COMMENT '用户表的自增id',
  `open_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '小程序OpenID',
  `union_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '小程序UnionID',
  `nick_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '微信昵称',
  `gender` tinyint(2) UNSIGNED NOT NULL DEFAULT 0 COMMENT '用户性别；0：未知、1：男、2：女',
  `avatar_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户头像图片URL',
  `city` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '城市',
  `country` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '国家',
  `province` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '省份',
  `language` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '显示 country、province、city 所用的语言',
  `phone` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '手机号',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
  PRIMARY KEY (`wx_id`) USING BTREE,
  UNIQUE INDEX `uk_user_id_idx`(`user_id`) USING BTREE,
  UNIQUE INDEX `uk_open_id_idx`(`open_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 29 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '微信小程序用户信息表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Procedure structure for testa
-- ----------------------------
DROP PROCEDURE IF EXISTS `testa`;
delimiter ;;
CREATE PROCEDURE `testa`()
begin
        select * from users;
        select * from orders;
    end
;;
delimiter ;

-- ----------------------------
-- Procedure structure for 注册人才信息
-- ----------------------------
DROP PROCEDURE IF EXISTS `注册人才信息`;
delimiter ;;
CREATE PROCEDURE `注册人才信息`()
BEGIN
	declare personnel_ids varchar(32) default 0;
	select personnel_id into personnel_ids from personnel_info where user_id = 0;
	select personnel_ids;
END
;;
delimiter ;

-- ----------------------------
-- Procedure structure for 测试
-- ----------------------------
DROP PROCEDURE IF EXISTS `测试`;
delimiter ;;
CREATE PROCEDURE `测试`()
BEGIN
	#Routine body goes here...

END
;;
delimiter ;

SET FOREIGN_KEY_CHECKS = 1;
