create database if not exists cmii_material_warehouse DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
use cmii_material_warehouse;
ALTER TABLE
  `cmii_material_warehouse`.`mw_tus_upload`
ADD
  COLUMN `platform` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'PLATFORM_CLOUD' COMMENT '所属平台';
ALTER TABLE `cmii_material_warehouse`.`mw_proj_item` 
ADD COLUMN `platform` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '所属平台';
CREATE TABLE `base_upload_type` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `type` varchar(32) NOT NULL COMMENT '业务类型',
  `max_size` int NOT NULL COMMENT '最大文件大小',
  `type_limit` varchar(255) NOT NULL COMMENT '文件类型限制',
  `platform` varchar(32) DEFAULT NULL COMMENT '文件所属平台',
  `is_confirm` tinyint(1) DEFAULT NULL COMMENT '上传是否需要业务确认',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_type` (`type`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT '基础上传类型表';
CREATE TABLE `item_recycle_bin` (
  `proj_obj_id` varchar(32) NOT NULL COMMENT '文件ID',
  `proj_id` varchar(32) DEFAULT NULL COMMENT '项目ID',
  `object_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '对象名称',
  `mat_type` varchar(20) DEFAULT NULL COMMENT '素材类型，来源于数据字典',
  `object_size` double DEFAULT NULL COMMENT '大小，默认 单位为KB，前端展示为M，需转换',
  `object_format` varchar(10) DEFAULT NULL COMMENT '格式',
  `play_duration` double DEFAULT NULL COMMENT '时长，单位为s',
  `bucket_name` varchar(255) DEFAULT NULL COMMENT '桶名称',
  `object_path` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '对象路径 日期/项目/类型/对象ID.对象类型 例如（20201104/234234/234/2234.jpg',
  `type` tinyint NOT NULL COMMENT '删除类型：0 业务删除 1 未确认删除 ',
  `company_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '公司ID',
  `thumbnail_image_path` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '缩略图路径',
  `object_md5` varchar(255) DEFAULT NULL COMMENT '文件md5',
  `def_usr_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建用户',
  `def_time` datetime NOT NULL COMMENT '创建日期',
  `upd_usr_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新用户',
  `upd_time` datetime NOT NULL COMMENT '更新日期',
  `platform` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '所属平台',
  PRIMARY KEY (`proj_obj_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='文件回收站表';
CREATE TABLE `mw_proj_item_unconfirmed` (
  `proj_obj_id` varchar(32) NOT NULL COMMENT '文件ID',
  `proj_id` varchar(32) DEFAULT NULL COMMENT '项目ID',
  `object_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '对象名称',
  `object_size` double DEFAULT NULL COMMENT '大小，默认 单位为KB，前端展示为M，需转换',
  `bucket_name` varchar(255) DEFAULT NULL COMMENT '桶名称',
  `object_path` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '对象路径 日期/项目/类型/对象ID.对象类型 例如（20201104/234234/234/2234.jpg',
  `object_md5` varchar(255) DEFAULT NULL COMMENT '文件md5',
  `def_time` datetime NOT NULL COMMENT '创建日期',
  PRIMARY KEY (`proj_obj_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='未确认文件表';
CREATE TABLE `mw_item_agg` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `company_id` varchar(32) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '公司ID',
  `type` tinyint DEFAULT NULL COMMENT '统计类型。0：图片；1：视频；2：模型；3：其他',
  `create_time` varchar(8) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '生成日期',
  `object_size` bigint DEFAULT NULL COMMENT '文件统计大小',
  PRIMARY KEY (`id`),
  KEY `idx_company_id` (`company_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT '文件大小统计表';
INSERT INTO `cmii_material_warehouse`.`base_upload_type`(`id`, `type`, `max_size`, `type_limit`, `platform`, `is_confirm`) VALUES (1, 'hangar', 2, '.png;.jpg;.jpeg;.gif;.jfif', '', 0);
INSERT INTO `cmii_material_warehouse`.`base_upload_type`(`id`, `type`, `max_size`, `type_limit`, `platform`, `is_confirm`) VALUES (2, 'payload', 2, '.png;.jpg;.jpeg;.gif;.jfif', '', 0);
INSERT INTO `cmii_material_warehouse`.`base_upload_type`(`id`, `type`, `max_size`, `type_limit`, `platform`, `is_confirm`) VALUES (3, 'uav', 2, '.png;.jpg;.jpeg;.gif;.jfif', '', 0);
INSERT INTO `cmii_material_warehouse`.`base_upload_type`(`id`, `type`, `max_size`, `type_limit`, `platform`, `is_confirm`) VALUES (4, 'feedback', 2, '.png;.jpg;.jpeg;.gif;.jfif', '', 0);
INSERT INTO `cmii_material_warehouse`.`base_upload_type`(`id`, `type`, `max_size`, `type_limit`, `platform`, `is_confirm`) VALUES (5, 'system/company', 5, '.png;.pdf;.jpg;.jpeg', '', 0);
INSERT INTO `cmii_material_warehouse`.`base_upload_type`(`id`, `type`, `max_size`, `type_limit`, `platform`, `is_confirm`) VALUES (6, 'personnelInfo', 2, '.jpg;.jpeg;.png', '', 0);
INSERT INTO `cmii_material_warehouse`.`base_upload_type`(`id`, `type`, `max_size`, `type_limit`, `platform`, `is_confirm`) VALUES (7, 'airspace', 5, '.jpg;.jpeg;.png;.gif;.jfif;.pdf;.bmp', '', 0);
INSERT INTO `cmii_material_warehouse`.`base_upload_type`(`id`, `type`, `max_size`, `type_limit`, `platform`, `is_confirm`) VALUES (8, 'app', 300, '.apk', 'PLATFORM_ADMIN', 0);
INSERT INTO `cmii_material_warehouse`.`base_upload_type`(`id`, `type`, `max_size`, `type_limit`, `platform`, `is_confirm`) VALUES (9, 'process', 2, '.png;.jpg;.jpeg;.gif;.jfif', '', 0);
INSERT INTO `cmii_material_warehouse`.`base_upload_type`(`id`, `type`, `max_size`, `type_limit`, `platform`, `is_confirm`) VALUES (10, 'application', 5, '.png;.jpg;.jpeg;.gif;.jfif', '', 0);
INSERT INTO `cmii_material_warehouse`.`base_upload_type`(`id`, `type`, `max_size`, `type_limit`, `platform`, `is_confirm`) VALUES (11, 'developer', 2, '.png;.jpg;.jpeg', '', 0);
INSERT INTO `cmii_material_warehouse`.`base_upload_type`(`id`, `type`, `max_size`, `type_limit`, `platform`, `is_confirm`) VALUES (12, 'tower', 10, '.jpg;.jpeg;.png;.txt;.pdf;.doc;.docx', '', 0);
INSERT INTO `cmii_material_warehouse`.`base_upload_type`(`id`, `type`, `max_size`, `type_limit`, `platform`, `is_confirm`) VALUES (13, 'screenshot', 10, '.jpg;.jpeg;.png', '', 0);
INSERT INTO `cmii_material_warehouse`.`base_upload_type`(`id`, `type`, `max_size`, `type_limit`, `platform`, `is_confirm`) VALUES (14, 'lifecycle_idcard', 10, '.jpg;.jpeg;.png', '', 1);
INSERT INTO `cmii_material_warehouse`.`base_upload_type`(`id`, `type`, `max_size`, `type_limit`, `platform`, `is_confirm`) VALUES (15, 'lifecycle_avatar', 2, '.jpg;.jpeg;.png', '', 0);
INSERT INTO `cmii_material_warehouse`.`base_upload_type`(`id`, `type`, `max_size`, `type_limit`, `platform`, `is_confirm`) VALUES (16, 'lifecycle_uav', 10, '.jpg;.jpeg;.png', '', 0);
INSERT INTO `cmii_material_warehouse`.`base_upload_type`(`id`, `type`, `max_size`, `type_limit`, `platform`, `is_confirm`) VALUES (17, 'lifecycle_license', 10, '.jpg;.jpeg;.png', '', 0);
INSERT INTO `cmii_material_warehouse`.`base_upload_type`(`id`, `type`, `max_size`, `type_limit`, `platform`, `is_confirm`) VALUES (18, 'cms', 100, '.pdf', '', 0);
INSERT INTO `cmii_material_warehouse`.`base_upload_type`(`id`, `type`, `max_size`, `type_limit`, `platform`, `is_confirm`) VALUES (19, 'lifecycle_approvalfile', 10, '.pdf', '', 1);
