CREATE TABLE `project`
(
    `id`          bigint unsigned PRIMARY KEY NOT NULL AUTO_INCREMENT COMMENT '序号',
    `code`        varchar(128)                NOT NULL COMMENT '项目编号',
    `name`        varchar(128)                NOT NULL COMMENT '名称',
    `icon`        bigint                      NOT NULL COMMENT '图标',
    `language`    char(1)                     NOT NULL DEFAULT '0' COMMENT '项目语言',
    `type`        char(1)                     NOT NULL DEFAULT '0' COMMENT '项目类型',
    `status`      tinyint(1)                  NOT NULL DEFAULT 0 COMMENT '状态',
    `pd_gpd`      varchar(128) COMMENT 'PD/GPD',
    `pm_gpm`      varchar(128) COMMENT 'PM/GPM',
    `cta_gcta`    varchar(128) COMMENT 'CTA/GCTA',
    `sponsor`     varchar(128) COMMENT '申办方',
    `cro`         varchar(128) COMMENT 'CRO',
    `note`        varchar(255) COMMENT '备注',
    `start_time`  datetime COMMENT '开始时间',
    `end_time`    datetime COMMENT '结束时间',
    `create_dept` bigint(20) COMMENT '创建部门',
    `create_by`   bigint(20) COMMENT '创建者',
    `create_time` datetime COMMENT '创建时间',
    `update_by`   bigint(20) COMMENT '更新者',
    `update_time` datetime COMMENT '更新时间',
    `del_flag`    char(1)                              DEFAULT '0' COMMENT '删除标志（0代表存在 1代表删除）',
    `tenant_id`   varchar(40) COMMENT '租户id'
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4 COMMENT ='项目';

CREATE TABLE `sys_user_projects`
(
    `user_id`  bigint       NOT NULL PRIMARY KEY COMMENT '用户ID',
    `projects` varchar(255) NOT NULL COMMENT '项目ID'
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4 COMMENT ='用户项目数据权限表';

CREATE TABLE `sys_user_center`
(
    `user_id`   bigint NOT NULL COMMENT '用户ID',
    `folder_id` bigint NOT NULL COMMENT '文件夹ID',
    PRIMARY KEY (`user_id`, `folder_id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4 COMMENT ='用户中心关联表';

CREATE TABLE `folder`
(
    `id`          bigint unsigned PRIMARY KEY NOT NULL AUTO_INCREMENT COMMENT '序号',
    `project_id`  bigint unsigned             NOT NULL COMMENT '所属项目',
    `parent_id`   bigint unsigned             NOT NULL COMMENT '父级',
    `type`        tinyint(1)                  NOT NULL COMMENT '类型',
    `name`        varchar(128)                NOT NULL COMMENT '名称',
    `status`      tinyint(1)                  NOT NULL DEFAULT 0 COMMENT '状态',
    `note`        varchar(255) COMMENT '备注',
    `create_dept` bigint(20) COMMENT '创建部门',
    `create_by`   bigint(20) COMMENT '创建者',
    `create_time` datetime COMMENT '创建时间',
    `update_by`   bigint(20) COMMENT '更新者',
    `update_time` datetime COMMENT '更新时间',
    `del_flag`    char(1)                              DEFAULT '0' COMMENT '删除标志（0代表存在 1代表删除）',
    `tenant_id`   varchar(40) COMMENT '租户id'
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4 COMMENT ='文件夹';

CREATE TABLE `document`
(
    `id`                    bigint unsigned PRIMARY KEY NOT NULL AUTO_INCREMENT COMMENT '序号',
    `folder_id`             bigint unsigned             NOT NULL COMMENT '所属文件夹',
    `file_specification`    char(1)                     NOT NULL COMMENT '文档标识',
    `name`                  varchar(128)                NOT NULL COMMENT '计划名称',
    `status`                tinyint(1)                  NOT NULL DEFAULT 0 COMMENT '状态',
    `scheduled_upload_time` date                        NOT NULL COMMENT '计划上传时间',
    `oss_id`                bigint COMMENT '文档本体',
    `note`                  varchar(255) COMMENT '备注',
    `create_dept`           bigint(20) COMMENT '创建部门',
    `create_by`             bigint(20) COMMENT '创建者',
    `create_time`           datetime COMMENT '创建时间',
    `update_by`             bigint(20) COMMENT '更新者',
    `update_time`           datetime COMMENT '更新时间',
    `del_flag`              char(1)                              DEFAULT '0' COMMENT '删除标志（0代表存在 1代表删除）',
    `tenant_id`             varchar(40) COMMENT '租户id'
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4 COMMENT ='文档';

CREATE TABLE `file_audit_log`
(
    `id`            bigint unsigned PRIMARY KEY NOT NULL AUTO_INCREMENT COMMENT '序号',
    `file_id`       bigint unsigned             NOT NULL COMMENT '文件',
    `auditor_id`    bigint unsigned             NOT NULL COMMENT '审核人',
    `result`        tinyint(1)                  NOT NULL COMMENT '审核结果',
    `reject_reason` varchar(255) COMMENT '驳回理由',
    `audit_time`    datetime                    NOT NULL COMMENT '审核时间',
    `create_dept`   bigint(20) COMMENT '创建部门',
    `create_by`     bigint(20) COMMENT '创建者',
    `create_time`   datetime COMMENT '创建时间',
    `update_by`     bigint(20) COMMENT '更新者',
    `update_time`   datetime COMMENT '更新时间',
    `del_flag`      char(1) DEFAULT '0' COMMENT '删除标志（0代表存在 1代表删除）',
    `tenant_id`     varchar(40) COMMENT '租户id'
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4 COMMENT ='文档审核记录';

CREATE TABLE `project_setting`
(
    `id`          bigint unsigned PRIMARY KEY NOT NULL AUTO_INCREMENT COMMENT '序号',
    `create_dept` bigint(20) COMMENT '创建部门',
    `create_by`   bigint(20) COMMENT '创建者',
    `create_time` datetime COMMENT '创建时间',
    `update_by`   bigint(20) COMMENT '更新者',
    `update_time` datetime COMMENT '更新时间',
    `del_flag`    char(1) DEFAULT '0' COMMENT '删除标志（0代表存在 1代表删除）',
    `tenant_id`   varchar(40) COMMENT '租户id'
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4 COMMENT ='设置';

CREATE TABLE `applet_setting`
(
    `id`                bigint unsigned PRIMARY KEY NOT NULL AUTO_INCREMENT COMMENT '序号',
    `user_agreement`    text COMMENT '用户协议',
    `privacy_agreement` text COMMENT '隐私协议',
    `create_dept`       bigint(20) COMMENT '创建部门',
    `create_by`         bigint(20) COMMENT '创建者',
    `create_time`       datetime COMMENT '创建时间',
    `update_by`         bigint(20) COMMENT '更新者',
    `update_time`       datetime COMMENT '更新时间',
    `del_flag`          char(1) DEFAULT '0' COMMENT '删除标志（0代表存在 1代表删除）',
    `tenant_id`         varchar(40) COMMENT '租户id'
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4 COMMENT ='微信小程序设置';
