-- 赛事通用附件表 -- 支持多种附件类型:赛事发布(info)、赛事规程(rules)、活动日程(schedule)、成绩(results)、奖牌榜(medals)、图片直播(photos) DROP TABLE IF EXISTS `martial_competition_attachment`; CREATE TABLE `martial_competition_attachment` ( `id` bigint NOT NULL COMMENT '主键ID', `tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID', `competition_id` bigint NOT NULL COMMENT '赛事ID', `attachment_type` varchar(20) NOT NULL COMMENT '附件类型:info-赛事发布, rules-赛事规程, schedule-活动日程, results-成绩, medals-奖牌榜, photos-图片直播', `file_name` varchar(255) NOT NULL COMMENT '文件名称', `file_url` varchar(500) NOT NULL COMMENT '文件URL', `file_size` bigint DEFAULT NULL COMMENT '文件大小(字节)', `file_type` varchar(20) DEFAULT NULL COMMENT '文件类型(pdf/doc/docx/xls/xlsx/jpg/png等)', `order_num` int DEFAULT 0 COMMENT '排序序号', `status` int DEFAULT 1 COMMENT '状态(1-启用 0-禁用)', `create_user` bigint DEFAULT NULL COMMENT '创建人', `create_dept` bigint DEFAULT NULL COMMENT '创建部门', `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_user` bigint DEFAULT NULL COMMENT '更新人', `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', `is_deleted` int DEFAULT 0 COMMENT '是否已删除(0-否 1-是)', PRIMARY KEY (`id`), KEY `idx_competition_id` (`competition_id`), KEY `idx_attachment_type` (`attachment_type`), KEY `idx_competition_type` (`competition_id`, `attachment_type`), KEY `idx_tenant_id` (`tenant_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='赛事通用附件表'; -- 插入测试数据(假设赛事ID为1) INSERT INTO `martial_competition_attachment` (`id`, `tenant_id`, `competition_id`, `attachment_type`, `file_name`, `file_url`, `file_size`, `file_type`, `order_num`, `status`) VALUES (1, '000000', 1, 'info', '2025年郑州武术大赛通知.pdf', 'http://example.com/files/notice.pdf', 1258291, 'pdf', 1, 1), (2, '000000', 1, 'rules', '2025年郑州武术大赛竞赛规程.pdf', 'http://example.com/files/rules.pdf', 2621440, 'pdf', 1, 1), (3, '000000', 1, 'rules', '参赛报名表.pdf', 'http://example.com/files/form.pdf', 163840, 'pdf', 2, 1), (4, '000000', 1, 'schedule', '比赛日程安排表.pdf', 'http://example.com/files/schedule.pdf', 911360, 'pdf', 1, 1), (5, '000000', 1, 'results', '比赛成绩公告.pdf', 'http://example.com/files/results.pdf', 1887436, 'pdf', 1, 1), (6, '000000', 1, 'medals', '奖牌榜统计.pdf', 'http://example.com/files/medals.pdf', 532480, 'pdf', 1, 1), (7, '000000', 1, 'photos', '比赛精彩瞬间.pdf', 'http://example.com/files/photos.pdf', 16357785, 'pdf', 1, 1);