CREATE DATABASE IF NOT EXISTS `saas_platform` DEFAULT CHARACTER SET = utf8mb4;
Use `saas_platform`;

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for saas_account
-- ----------------------------
DROP TABLE IF EXISTS `saas_account`;
CREATE TABLE `saas_account`  (
  `ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `GROUP_CODE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '集团编码',
  `TERMINAL` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '应用ID， PC-电脑端，APP-手机端',
  `USERNAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '登录用户名，集团下唯一，业务保证',
  `PASSWORD` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '登录密码',
  `PHONE_NUM` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '手机号',
  `MAIL` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '邮箱',
  `HEAD_PORTRAIT` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '头像，图片URL',
  `ACCOUNT_TYPE` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '2' COMMENT '账号类型, 0-超级管理员(所有集团)，1-单集团管理员(单集团)，2-普通账号',
  `ACCOUNT_BELONG` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '账号所属, 0-运维系统账号，1-业务账号',
  `ACCOUNT_SOURCE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'persagy' COMMENT '账号来源, persagy-博锐',
  `LAST_LOGIN_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '账号上一次登录时间',
  `LAST_LOGIN_IP` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '账号上一次登录IP',
  `LOGIN_FAIL` tinyint(4) NULL DEFAULT NULL COMMENT '账号登录失败次数，超过阈值，冻结',
  `VALID_LAST` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '1' COMMENT '账号有效期，0-期内有效，1-永久有效',
  `VALID_START_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '账号有效期的开始时间',
  `VALID_END_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '账号有效期的结束时间',
  `CREATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '更新时间',
  `UPDATE_USER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '最后一次操作者ID',
  `REMARK` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `VALID` tinyint(4) NULL DEFAULT 1 COMMENT '0-不可用，1-可用',
  PRIMARY KEY (`ID`) USING BTREE,
  INDEX `NK_ACCOUNT_GROUP_APP`(`GROUP_CODE`, `TERMINAL`) USING BTREE,
  INDEX `NK_ACCOUNT_VALID_NAME`(`VALID`, `USERNAME`) USING BTREE,
  INDEX `NK_ACCOUNT_UPDATE_TIME`(`UPDATE_TIME`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '账号信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for saas_account_project
-- ----------------------------
DROP TABLE IF EXISTS `saas_account_project`;
CREATE TABLE `saas_account_project`  (
  `ACCOUNT_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '账号ID',
  `GROUP_CODE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '集团编码',
  `AREA_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '区域ID',
  `PROJECT_ID` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '项目ID',
  UNIQUE INDEX `UK_ACCOUNT_PROJECT_GROUP`(`ACCOUNT_ID`, `GROUP_CODE`, `PROJECT_ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '账号-集团项目关联信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for saas_account_role
-- ----------------------------
DROP TABLE IF EXISTS `saas_account_role`;
CREATE TABLE `saas_account_role`  (
  `GROUP_CODE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `ACCOUNT_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '账号ID',
  `ROLE_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色ID',
  `CAS_TYPE` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联类型，0-主岗，1-副岗，2-业务超管默认角色',
  UNIQUE INDEX `UK_ACCOUNT_ACCOUNT_ROLE`(`ACCOUNT_ID`, `GROUP_CODE`, `ROLE_ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '账号-角色关联信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for saas_area
-- ----------------------------
DROP TABLE IF EXISTS `saas_area`;
CREATE TABLE `saas_area`  (
  `ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `GROUP_CODE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '集团编码',
  `PARENT_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '上级区域ID',
  `AREA_CODE` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '区域编码',
  `AREA_NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '区域名称',
  `AREA_TYPE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '区域类型，0-非最底层区域，1-最底层区域',
  `CREATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '更新时间',
  `UPDATE_USER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '最后一次操作者ID',
  `REMARK` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`ID`) USING BTREE,
  INDEX `NK_AREA_PARENT_ID`(`PARENT_ID`) USING BTREE,
  INDEX `NK_AREA_AREA_CODE`(`AREA_TYPE`) USING BTREE,
  INDEX `NK_AREA_GROUP_AREA_CODE`(`GROUP_CODE`, `AREA_CODE`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '区域信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for saas_function
-- ----------------------------
DROP TABLE IF EXISTS `saas_function`;
CREATE TABLE `saas_function`  (
  `ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `PRODUCT_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '产品ID',
  `PAGE_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '页面ID',
  `MENU_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '菜单ID',
  `FUN_CODE` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '功能编码',
  `FUN_NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '功能名称',
  `FUN_URL` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '功能URL',
  `CREATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '更新时间',
  `UPDATE_USER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '最后一次操作者ID',
  `REMARK` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`ID`) USING BTREE,
  INDEX `NK_FUN_MENU_ID`(`MENU_ID`) USING BTREE,
  INDEX `NK_FUN_FUN_CODE`(`FUN_CODE`) USING BTREE,
  INDEX `NK_FUN_PAGE_ID`(`PAGE_ID`) USING BTREE,
  INDEX `NK_FUN_CREATE_TIME`(`CREATE_TIME`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '功能信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for saas_group
-- ----------------------------
DROP TABLE IF EXISTS `saas_group`;
CREATE TABLE `saas_group`  (
  `GROUP_CODE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '集团编码',
  `GROUP_NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '集团名称,业务保证唯一性',
  `GROUP_ICON` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '集团图标',
  `GROUP_DESC` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '集团描述',
  `DEPLOY_MODEL` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '集团部署方式，0-公有云，1-私有云',
  `SYNC_STATE` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '2' COMMENT '数据同步状态,0-数据同步失败，1-数据同步成功，2-未同步',
  `SYNC_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '上次数据同步时间',
  `CREATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '更新时间',
  `UPDATE_USER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '最后一次操作者ID',
  `REMARK` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `VALID` tinyint(4) NULL DEFAULT 1 COMMENT '0-不可用，1-可用',
  PRIMARY KEY (`GROUP_CODE`) USING BTREE,
  INDEX `NK_GROUP_VALID_NAME`(`VALID`, `GROUP_NAME`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '集团信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for saas_group_product
-- ----------------------------
DROP TABLE IF EXISTS `saas_group_product`;
CREATE TABLE `saas_group_product`  (
  `ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `GROUP_CODE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '集团编码',
  `PRODUCT_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '产品ID',
  `PRODUCT_RANGE` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '产品使用范围，0-全部项目，1-部分项目',
  `PRODUCT_CONTRACT` timestamp(0) NULL DEFAULT NULL COMMENT '签约时间',
  `VALID_START_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '签约有效期的开始时间',
  `VALID_END_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '签约有效期的结束时间',
  `VALID_LAST` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '1' COMMENT '签约有效期，0-期内有效，1-永久有效',
  `UPDATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '更新时间',
  `UPDATE_USER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '最后一次操作者ID',
  `REMARK` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`ID`) USING BTREE,
  UNIQUE INDEX `UK_GROUP_PRODUCT_ID`(`GROUP_CODE`, `PRODUCT_ID`) USING BTREE,
  INDEX `NK_GROUP_PRODUCT_ID`(`PRODUCT_ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '产品集团签约信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for saas_group_product_page
-- ----------------------------
DROP TABLE IF EXISTS `saas_group_product_page`;
CREATE TABLE `saas_group_product_page`  (
  `CONTRACT_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '集团签约ID',
  `PAGE_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '页面ID',
  UNIQUE INDEX `UK_GROUP_PRODUCT_PAGE_ID`(`CONTRACT_ID`, `PAGE_ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '集团签约产品详情' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for saas_menu
-- ----------------------------
DROP TABLE IF EXISTS `saas_menu`;
CREATE TABLE `saas_menu`  (
  `ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `PARENT_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '上级菜单ID',
  `PRODUCT_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '产品ID',
  `APP_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '应用ID， PC-电脑端，APP-手机端',
  `MENU_CODE` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '菜单编码',
  `MENU_NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '菜单名称',
  `MENU_URL` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '菜单URL',
  `URL_TYPE` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'URL类型，0-相对路径，1-绝对路径',
  `MENU_ICON` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '菜单图标',
  `MENU_SORT` int(11) NULL DEFAULT NULL COMMENT '菜单顺序',
  `MENU_TYPE` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '菜单类型，0-系统菜单，1-标准业务菜单，2-IBMS菜单，3-APP菜单',
  `MENU_GROUP` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '分组菜单，0-非分组菜单，1-分组菜单',
  `CREATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '更新时间',
  `UPDATE_USER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '最后一次操作者ID',
  `REMARK` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `EXTRA_MENU` json NULL COMMENT '菜单额外字段',
  PRIMARY KEY (`ID`) USING BTREE,
  INDEX `NK_MENU_MENU_CODE`(`MENU_CODE`) USING BTREE,
  INDEX `NK_MENU_PARENT_ID`(`PARENT_ID`) USING BTREE,
  INDEX `NK_MENU_APP_ID`(`APP_ID`) USING BTREE,
  INDEX `NK_MENU_MENU_SORT`(`MENU_SORT`) USING BTREE,
  INDEX `NK_MENU_PRODUCT_ID`(`PRODUCT_ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '菜单信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for saas_product
-- ----------------------------
DROP TABLE IF EXISTS `saas_product`;
CREATE TABLE `saas_product`  (
  `ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `APP_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '应用ID， PC-电脑端，APP-手机端',
  `PRODUCT_TYPE` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '产品类型，0-系统产品，1-标准业务产品，2-IBMS产品',
  `PRODUCT_CODE` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '产品编码',
  `PRODUCT_NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '产品名称',
  `PRODUCT_ICON` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '产品图标',
  `PRODUCT_STATE` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '产品状态，0-建设中，1-已完成，2-已关联',
  `PRODUCT_MENU` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '产品是否关联菜单，0-未关联，1-已关联',
  `MENU_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '菜单ID',
  `CREATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '更新时间',
  `UPDATE_USER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '最后一次操作者ID',
  `REMARK` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`ID`) USING BTREE,
  INDEX `NK_PRODUCT_APP_ID`(`APP_ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '产品信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for saas_product_category
-- ----------------------------
DROP TABLE IF EXISTS `saas_product_category`;
CREATE TABLE `saas_product_category`  (
  `ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `PARENT_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '上级ID',
  `CATEGORY_NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '类别名称',
  `CATEGORY_ICON` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '类别图标',
  `TERMINAL` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '类别所属终端',
  `TERMINAL_NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '类别所属终端名称',
  `PRODUCT_TYPE` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '此类别所对应的产品类型',
  `MENU_TYPE` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '此类别所对应的菜单类型',
  `CREATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间',
  `REMARK` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '产品类别信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for saas_product_page
-- ----------------------------
DROP TABLE IF EXISTS `saas_product_page`;
CREATE TABLE `saas_product_page`  (
  `ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'PA+雪花',
  `PRODUCT_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '产品ID',
  `PARENT_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '上级页面ID',
  `PAGE_NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '页面名称',
  `PAGE_ICON` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '页面图标',
  `PAGE_URL` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '页面URL，一般为前端页面跳转链接',
  `PAGE_ANGLE` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '页面视角，0-集团项目页，1-集团独有页，2-项目独有页，默认0',
  `PAGE_FLOOR` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否为落地页，0-非落地页，1-集团落地页，2-项目落地页，3-集团项目落地页',
  `PAGE_LEVEL` int(11) NULL DEFAULT NULL COMMENT '页面顺序',
  `CREATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '更新时间',
  `UPDATE_USER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '最后一次操作者ID',
  `REMARK` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`ID`) USING BTREE,
  INDEX `NK_PAGE_PRODUCT_ID`(`PRODUCT_ID`) USING BTREE,
  INDEX `NK_PAGE_PARENT_ID`(`PARENT_ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '产品页面配置' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for saas_project
-- ----------------------------
DROP TABLE IF EXISTS `saas_project`;
CREATE TABLE `saas_project`  (
  `ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `GROUP_CODE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '集团编码',
  `PROJECT_ID` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '项目ID，集团下唯一，业务保证',
  `AREA_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '项目所属区域，必须为最底层的区域',
  `PROJECT_LOCAL_ID` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '项目本地编码，集团下唯一，业务保证',
  `PROJECT_NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '项目名称，集团下唯一，业务保证',
  `PROVINCE_CODE` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '项目所在省',
  `CITY_CODE` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '项目所在市',
  `ZONE_CODE` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '项目所在区',
  `LOCATION` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '项目详细地址',
  `OPEN_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '项目开业时间',
  `PROJECT_FUN` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '项目功能',
  `PROJECT_WEATHER` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '项目天气',
  `PROJECT_IMAGE` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '项目图标，多个之间，用逗号分隔',
  `LONGITUDE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '项目经度',
  `LATITUDE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '项目纬度',
  `MANAGE_ZONE` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '集团管理分区字段，只做展示用',
  `CREATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '更新时间',
  `UPDATE_USER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '最后一次操作者ID',
  `REMARK` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `VALID` tinyint(4) NULL DEFAULT 1 COMMENT '0-不可用，1-可用',
  PRIMARY KEY (`ID`) USING BTREE,
  INDEX `NK_PROJECT_GROUP_PROJECT`(`VALID`, `GROUP_CODE`, `PROJECT_ID`) USING BTREE,
  INDEX `NK_PROJECT_AREA_ID`(`AREA_ID`) USING BTREE,
  INDEX `NK_PROJECT_PROJECT_NAME`(`PROJECT_NAME`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '项目信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for saas_project_product
-- ----------------------------
DROP TABLE IF EXISTS `saas_project_product`;
CREATE TABLE `saas_project_product`  (
  `CONTRACT_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '集团签约ID',
  `GROUP_CODE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '集团编码',
  `PROJECT_ID` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '项目ID',
  `PRODUCT_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '产品ID',
  `PRODUCT_CONTRACT` timestamp(0) NULL DEFAULT NULL COMMENT '签约时间',
  `REMARK` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  UNIQUE INDEX `UK_PROJECT_PRODUCT_ID`(`GROUP_CODE`, `PROJECT_ID`, `PRODUCT_ID`) USING BTREE,
  INDEX `NK_PROJECT_PRODUCT_ID`(`PRODUCT_ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '产品项目签约信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for saas_role
-- ----------------------------
DROP TABLE IF EXISTS `saas_role`;
CREATE TABLE `saas_role`  (
  `ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `GROUP_CODE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `ROLE_CODE` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `ROLE_NAME` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `ROLE_TYPE` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '角色类型',
  `CREATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATE_TIME` timestamp(0) NULL DEFAULT NULL COMMENT '更新时间',
  `UPDATE_USER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '最后一次操作者ID',
  `REMARK` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `VALID` tinyint(4) NULL DEFAULT 1 COMMENT '0-不可用，1-可用',
  PRIMARY KEY (`ID`) USING BTREE,
  INDEX `NK_ROLE_GROUP_ROLE_TYPE`(`VALID`, `GROUP_CODE`, `ROLE_TYPE`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for saas_role_menu
-- ----------------------------
DROP TABLE IF EXISTS `saas_role_menu`;
CREATE TABLE `saas_role_menu`  (
  `GROUP_CODE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `ROLE_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色ID',
  `MENU_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '菜单ID',
  `PAGE_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '页面ID',
  `FUNCTION_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '功能ID',
  INDEX `UK_ROLE_MENU_GROUP_PAGE`(`GROUP_CODE`, `ROLE_ID`, `MENU_ID`, `PAGE_ID`, `FUNCTION_ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色-菜单功能关联信息' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

DELETE FROM `saas_account` WHERE ID = 'AC1372371635352403969';
INSERT INTO `saas_account`(`ID`, `GROUP_CODE`, `TERMINAL`, `USERNAME`, `PASSWORD`, `PHONE_NUM`, `MAIL`, `HEAD_PORTRAIT`, `ACCOUNT_TYPE`, `ACCOUNT_BELONG`, `ACCOUNT_SOURCE`, `LAST_LOGIN_TIME`, `LAST_LOGIN_IP`, `VALID_START_TIME`, `VALID_END_TIME`, `CREATE_TIME`, `UPDATE_TIME`, `UPDATE_USER`, `REMARK`, `VALID`, `VALID_LAST`, `LOGIN_FAIL`) 
VALUES ('AC1372371635352403969', NULL, '[\"PC\"]', 'PERSAGYADMIN', '1608B9B21D2794DA3DDFECF1772DA529', NULL, NULL, NULL, '0', '0', NULL, NOW(), NOW(), NOW(), NOW(), NOW(), NOW(), 'AC1372371635352403969', NULL, 1, '1', 0);
