/*
SQLyog Ultimate v12.03 (32 bit)
MySQL - 5.7.22-log : Database - party_building
*********************************************************************
*/

SET NAMES utf8mb4;

CREATE DATABASE IF NOT EXISTS `party_building` DEFAULT CHARACTER SET utf8mb4;

USE `party_building`;

/*Table structure for table `party_documents` */

DROP TABLE IF EXISTS `party_documents`;

CREATE TABLE `party_documents` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '表ID',
  `name` varchar(50) NOT NULL COMMENT '原始文件名',
  `encode_name` varchar(32) NOT NULL COMMENT '转散列文件名',
  `orig_path` varchar(60) NOT NULL COMMENT '原始文件存储路径',
  `documents_category_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '文件分类ID',
  `extension` varchar(20) NOT NULL COMMENT '文件格式(后缀)',
  `size` int(10) unsigned NOT NULL COMMENT '文件大小',
  `creator_uuid` char(32) NOT NULL COMMENT '上传人UUID',
  `ctime` int(10) unsigned NOT NULL COMMENT '上传时间',
  `modifier_uuid` char(32) NOT NULL DEFAULT '' COMMENT '更新人UUID',
  `mtime` int(10) NOT NULL DEFAULT '0' COMMENT '最后更新时间',
  `version` int(10) unsigned NOT NULL DEFAULT '1' COMMENT '当前文件版本',
  `is_limit` enum('y','n') NOT NULL DEFAULT 'n' COMMENT '是否限制访问',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文档表';

/*Data for the table `party_documents` */

/*Table structure for table `party_documents_category` */

DROP TABLE IF EXISTS `party_documents_category`;

CREATE TABLE `party_documents_category` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '表ID',
  `name` varchar(100) NOT NULL COMMENT '分类名称',
  `desc` varchar(100) NOT NULL COMMENT '分类描述',
  `creator_uuid` char(32) NOT NULL COMMENT '添加操作员UUID',
  `ctime` int(10) unsigned NOT NULL COMMENT '添加时间',
  `category_type` enum('office','picture') NOT NULL DEFAULT 'office' COMMENT '分类类型',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文档分类';

/*Data for the table `party_documents_category` */

/*Table structure for table `party_documents_access` */

DROP TABLE IF EXISTS `party_documents_access`;

CREATE TABLE `party_documents_access` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '表ID',
  `documents_id` int(10) unsigned NOT NULL COMMENT '文件ID',
  `uuid` char(32) NOT NULL COMMENT '用户UUID',
  `permission` enum('read','write','none') NOT NULL DEFAULT 'read' COMMENT '权限',
  `expire` int(10) unsigned NOT NULL COMMENT '有效期（整型），0表示永远有效',
  `ctime` int(10) unsigned NOT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文档权限';

/*Data for the table `party_documents_access` */

/*Table structure for table `party_documents_notify` */

DROP TABLE IF EXISTS `party_documents_notify`;

CREATE TABLE `party_documents_notify` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '表ID',
  `documents_id` int(10) unsigned NOT NULL COMMENT '文件ID',
  `header` varchar(2000) NOT NULL COMMENT '请求头信息',
  `cmd` varchar(2000) NOT NULL COMMENT '操作标识',
  `body` varchar(2000) NOT NULL COMMENT '具体内容',
  `ctime` int(10) unsigned NOT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文档回调通知';

/*Table structure for table `party_documents_version` */

DROP TABLE IF EXISTS `party_documents_version`;

CREATE TABLE `party_documents_version` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '表ID',
  `documents_id` int(10) unsigned NOT NULL COMMENT '文件ID',
  `version` int(10) unsigned NOT NULL COMMENT '版本号',
  `name` varchar(50) NOT NULL COMMENT '文件名',
  `size` int(10) unsigned NOT NULL COMMENT '文件大小',
  `path` char(100) NOT NULL COMMENT '文件路径',
  `ctime` int(10) unsigned NOT NULL COMMENT '版本创建时间',
  `creator_uuid` char(32) NOT NULL DEFAULT '' COMMENT '版本创建用户',
  `extension` varchar(20) NOT NULL COMMENT '文件格式(后缀)',
  `remark` varchar(200) NOT NULL COMMENT '备注',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文档版本';

/*Data for the table `party_documents_version` */

CREATE TABLE `party_documents_logs` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '表ID',
  `documents_id` int(10) unsigned NOT NULL COMMENT '文件ID',
  `ctime` int(10) unsigned NOT NULL COMMENT '操作时间',
  `operator_uuid` char(32) NOT NULL DEFAULT '' COMMENT '操作用户',
  `type` enum('visit', 'save', 'rename') NOT NULL DEFAULT 'visit' COMMENT '操作类型',
  `remark` varchar(200) NOT NULL COMMENT '备注',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文档访问历史';


