-- ----------------------------
-- 创建立档单位表 setting_organization
-- ----------------------------
DROP TABLE IF EXISTS `setting_organization`;
CREATE TABLE `setting_organization`  (
                                         `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '单位id',
                                         `organization_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '单位名称',
                                         `organization_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '单位编码',
                                         `case_num` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '全宗号',
                                         `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
                                         `attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预留字段1',
                                         `attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预留字段2',
                                         `attr3` int(11) NULL DEFAULT NULL COMMENT '预留字段3',
                                         `attr4` int(11) NULL DEFAULT NULL COMMENT '预留字段4',
                                         `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
                                         `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
                                         `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
                                         `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
                                         `dept_id` bigint(20) NULL DEFAULT NULL COMMENT '所属部门id',
                                         `dept_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属部门',
                                         `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id',
                                         `deleted` bit(1) NULL DEFAULT b'0' COMMENT '是否删除',
                                         `company_id` bigint(20) NULL DEFAULT NULL COMMENT '业务实体id',
                                         `company` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '业务实体',
                                         `tenant_id` bigint(20) NOT NULL COMMENT '租户编号，一个集团/总公司对应一个租户',
                                         `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '制单人',
                                         PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '立档单位' ROW_FORMAT = Dynamic;

-- ----------------------------
-- 创建库房表 for setting_depot
-- ----------------------------
DROP TABLE IF EXISTS `setting_depot`;
CREATE TABLE `setting_depot`  (
                                  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
                                  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '库房名称',
                                  `code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '库房编号',
                                  `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '库房地址',
                                  `organization_id` bigint(20) NULL DEFAULT NULL COMMENT '立党单位id',
                                  `maneger_id` bigint(20) NULL DEFAULT NULL COMMENT '管理者ID',
                                  `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
                                  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
                                  `maneger_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '管理者姓名',
                                  `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
                                  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
                                  `dept_id` bigint(20) NULL DEFAULT NULL COMMENT '所属部门ID',
                                  `dept_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属部门',
                                  `company_id` bigint(20) NULL DEFAULT NULL COMMENT '业务实体ID',
                                  `company` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '业务实体',
                                  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
                                  `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户ID',
                                  `deleted` bit(1) NULL DEFAULT b'0' COMMENT '是否删除',
                                  `tenant_id` bigint(20) NOT NULL COMMENT '租户编号',
                                  `attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预留字段1',
                                  `attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预留字段2',
                                  `attr3` int(11) NULL DEFAULT NULL COMMENT '预留字段3',
                                  `attr4` int(11) NULL DEFAULT NULL COMMENT '预留字段4',
                                  `organization_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '立档单位名称',
                                  `organization_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '立档单位编码',
                                  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '库房管理' ROW_FORMAT = Dynamic;

-- ----------------------------
-- 创建档案柜表 for setting_depot_cabinet
-- ----------------------------
DROP TABLE IF EXISTS `setting_depot_cabinet`;
CREATE TABLE `setting_depot_cabinet`  (
                                          `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
                                          `depot_id` bigint(20) NULL DEFAULT NULL COMMENT '所属库房ID',
                                          `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '柜子名称',
                                          `code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '柜子编号',
                                          `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '库房地址',
                                          `maneger_id` bigint(20) NULL DEFAULT NULL COMMENT '管理者ID',
                                          `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
                                          `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
                                          `maneger_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '管理者姓名',
                                          `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
                                          `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
                                          `dept_id` bigint(20) NULL DEFAULT NULL COMMENT '所属部门ID',
                                          `dept_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属部门',
                                          `company_id` bigint(20) NULL DEFAULT NULL COMMENT '业务实体ID',
                                          `company` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '业务实体',
                                          `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户ID',
                                          `deleted` bit(1) NULL DEFAULT b'0' COMMENT '是否删除',
                                          `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
                                          `tenant_id` bigint(20) NOT NULL COMMENT '租户编号',
                                          `attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预留字段1',
                                          `attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预留字段2',
                                          `attr3` int(11) NULL DEFAULT NULL COMMENT '预留字段3',
                                          `attr4` int(11) NULL DEFAULT NULL COMMENT '预留字段4',
                                          `cabinet_num` int(11) NULL DEFAULT NULL COMMENT '柜子数量',
                                          PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '档案柜管理' ROW_FORMAT = Dynamic;

-- 插入档案设置菜单
INSERT INTO `lyr-one`.`system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ('档案设置', '', 1, 2, 0, '/setting', 'config', NULL, NULL, 0, b'1', b'1', b'1', '1', '2023-09-11 09:50:15', '1', '2023-09-11 10:41:21', b'0');
-- 获取插入的档案设置菜单ID
SET @menuId = LAST_INSERT_ID();
INSERT INTO `lyr-one`.`system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ('立档单位管理', '', 2, 0, @menuId, 'organization', '', 'setting/organization/index', 'Organization', 0, b'1', b'1', b'1', '', '2023-09-11 10:39:56', '', '2023-09-11 10:39:56', b'0');
-- 获取插入的立档单位菜单ID
SET @menuId2 = LAST_INSERT_ID();
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '立档单位查询', 'setting:organization:query', 3, 1, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-11 10:39:56', '', '2023-09-11 10:39:56', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '立档单位创建', 'setting:organization:create', 3, 2, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-11 10:39:56', '', '2023-09-11 10:39:56', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '立档单位更新', 'setting:organization:update', 3, 3, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-11 10:39:56', '', '2023-09-11 10:39:56', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '立档单位删除', 'setting:organization:delete', 3, 4, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-11 10:39:56', '', '2023-09-11 10:39:56', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '立档单位导出', 'setting:organization:export', 3, 5, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-11 10:39:56', '', '2023-09-11 10:39:56', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '档案柜管理管理', '', 2, 2, @menuId, 'depot-cabinet', '', 'setting/depotCabinet/index', 'DepotCabinet', 0, b'1', b'1', b'1', '', '2023-09-12 09:28:34', '1', '2023-09-12 09:33:27', b'0');
-- 获取插入的档案柜管理菜单ID
SET @menuId3 = LAST_INSERT_ID();
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '档案柜管理查询', 'setting:depot-cabinet:query', 3, 1, @menuId3, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-12 09:28:34', '', '2023-09-12 09:28:34', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '档案柜管理创建', 'setting:depot-cabinet:create', 3, 2, @menuId3, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-12 09:28:34', '', '2023-09-12 09:28:34', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '档案柜管理更新', 'setting:depot-cabinet:update', 3, 3, @menuId3, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-12 09:28:34', '', '2023-09-12 09:28:34', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '档案柜管理删除', 'setting:depot-cabinet:delete', 3, 4, @menuId3, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-12 09:28:34', '', '2023-09-12 09:28:34', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '档案柜管理导出', 'setting:depot-cabinet:export', 3, 5, @menuId3, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-12 09:28:34', '', '2023-09-12 09:28:34', b'0');
INSERT INTO `lyr-one`.`system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ('库房管理管理', '', 2, 1, @menuId, 'depot', '', 'setting/depot/index', 'Depot', 0, b'1', b'1', b'1', '', '2023-09-12 09:28:44', '1', '2023-09-12 09:33:31', b'0');
-- 获取插入的库房管理菜单ID
SET @menuId4 = LAST_INSERT_ID();
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '库房管理查询', 'setting:depot:query', 3, 1, @menuId4, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-12 09:28:44', '', '2023-09-12 09:28:44', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '库房管理创建', 'setting:depot:create', 3, 2, @menuId4, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-12 09:28:44', '', '2023-09-12 09:28:44', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '库房管理更新', 'setting:depot:update', 3, 3, @menuId4, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-12 09:28:44', '', '2023-09-12 09:28:44', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '库房管理删除', 'setting:depot:delete', 3, 4, @menuId4, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-12 09:28:44', '', '2023-09-12 09:28:44', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '库房管理导出', 'setting:depot:export', 3, 5, @menuId4, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-12 09:28:44', '', '2023-09-12 09:28:44', b'0');
