-- =====================================================
-- 武术比赛管理系统 - 模拟测试数据
-- Database: martial_db
-- Author: Claude Code
-- Date: 2025-11-29
-- =====================================================

USE martial_db;

-- 清空现有测试数据(保留扣分项配置)
DELETE FROM martial_score WHERE id > 0;
DELETE FROM martial_result WHERE id > 0;
DELETE FROM martial_schedule_athlete WHERE id > 0;
DELETE FROM martial_schedule WHERE id > 0;
DELETE FROM martial_judge_invite WHERE id > 0;
DELETE FROM martial_judge WHERE id > 0;
DELETE FROM martial_athlete WHERE id > 0;
DELETE FROM martial_registration_order WHERE id > 0;
DELETE FROM martial_live_update WHERE id > 0;
DELETE FROM martial_info_publish WHERE id > 0;
DELETE FROM martial_activity_schedule WHERE id > 0;
DELETE FROM martial_venue WHERE id > 0;
DELETE FROM martial_project WHERE id > 0;
DELETE FROM martial_competition WHERE id > 0;
DELETE FROM martial_banner WHERE id > 0;

-- =====================================================
-- 1. 插入赛事数据
-- =====================================================
INSERT INTO `martial_competition` VALUES
(1, '2025年全国武术散打锦标赛暨第十七届世界武术锦标赛选拔赛',
 'WS2025001',
 '国家体育总局武术运动管理中心',
 '北京市',
 '北京市朝阳区国家奥林匹克体育中心',
 '2025-01-01 00:00:00',
 '2025-02-20 23:59:59',
 '2025-06-25 08:00:00',
 '2025-06-27 18:00:00',
 '本次比赛旨在选拔优秀武术运动员参加第十七届世界武术锦标赛,展示中华武术精神,传承优秀传统文化。',
 '["https://example.com/poster1.jpg","https://example.com/poster2.jpg"]',
 '张教练',
 '13800138000',
 'wushu2025@example.com',
 '按照国家武术运动管理中心最新竞赛规则执行',
 '年龄18-35岁,持有运动员等级证书,身体健康',
 '金牌、银牌、铜牌及优秀奖',
 '["https://example.com/regulation.pdf"]',
 156,
 78000.00,
 2,
 1, 1, NOW(), 1, NOW(), 0, '000000');

-- =====================================================
-- 2. 插入场地数据
-- =====================================================
INSERT INTO `martial_venue` VALUES
(1, 1, '第一场地', 'VENUE-001', '主竞技馆1号场地', 500, '标准武术竞技场地,配备LED屏幕、音响设备', 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(2, 1, '第二场地', 'VENUE-002', '主竞技馆2号场地', 500, '标准武术竞技场地,配备LED屏幕、音响设备', 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(3, 1, '第三场地', 'VENUE-003', '训练馆3号场地', 300, '训练场地,配备基础设施', 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(4, 1, '第四场地', 'VENUE-004', '训练馆4号场地', 300, '训练场地,配备基础设施', 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(5, 1, '第五场地', 'VENUE-005', '备用场地', 200, '备用竞技场地', 1, 1, 1, NOW(), 1, NOW(), 0, '000000');

-- =====================================================
-- 3. 插入比赛项目数据
-- =====================================================
INSERT INTO `martial_project` VALUES
(1, 1, '男子组陈氏太极拳', 'PRJ-001', '男子组', 1, 1, 1, 5, 100.00, '传统陈氏太极拳套路', 1, 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(2, 1, '女子组长拳', 'PRJ-002', '女子组', 1, 1, 1, 5, 100.00, '长拳基本套路', 2, 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(3, 1, '女子组双剑(含长穗双剑)', 'PRJ-003', '女子组', 2, 2, 2, 6, 200.00, '双剑配合演练', 3, 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(4, 1, '男子组杨氏太极拳', 'PRJ-004', '男子组', 1, 1, 1, 5, 100.00, '杨氏太极拳套路', 4, 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(5, 1, '女子组刀术', 'PRJ-005', '女子组', 1, 1, 1, 4, 100.00, '传统刀术', 5, 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(6, 1, '男子组棍术', 'PRJ-006', '男子组', 1, 1, 1, 4, 100.00, '传统棍术', 6, 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(7, 1, '女子组枪术', 'PRJ-007', '女子组', 1, 1, 1, 4, 100.00, '传统枪术', 7, 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(8, 1, '男子组剑术', 'PRJ-008', '男子组', 1, 1, 1, 4, 100.00, '传统剑术', 8, 1, 1, 1, NOW(), 1, NOW(), 0, '000000');

-- =====================================================
-- 4. 插入裁判数据
-- =====================================================
INSERT INTO `martial_judge` VALUES
(1, '欧阳丽娜', 2, '13900000001', '110101198501011234', 1, '国家一级裁判', '太极拳,长拳', NULL, '主裁判', 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(2, '张三', 1, '13900000002', '110101198502021234', 2, '国家二级裁判', '刀剑术', NULL, '普通裁判', 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(3, '李四', 1, '13900000003', '110101198503031234', 2, '国家二级裁判', '棍术', NULL, '普通裁判', 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(4, '王五', 2, '13900000004', '110101198504041234', 2, '国家二级裁判', '枪术', NULL, '普通裁判', 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(5, '赵六', 1, '13900000005', '110101198505051234', 2, '国家三级裁判', '长拳', NULL, '普通裁判', 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(6, '陈七', 2, '13900000006', '110101198506061234', 2, '国家三级裁判', '太极拳', NULL, '普通裁判', 1, 1, 1, NOW(), 1, NOW(), 0, '000000');

-- =====================================================
-- 5. 插入裁判邀请码
-- =====================================================
INSERT INTO `martial_judge_invite` VALUES
(1, 1, 1, 'admin', 'chief_judge', NULL, NULL, '2025-06-30 23:59:59', 1, '2025-06-25 08:00:00', 1, 1, NOW(), 1, NOW(), 0, '000000'),
(2, 1, 2, 'pub', 'judge', 1, '["男子组陈氏太极拳","男子组杨氏太极拳"]', '2025-06-30 23:59:59', 1, '2025-06-25 08:15:00', 1, 1, NOW(), 1, NOW(), 0, '000000'),
(3, 1, 3, 'pub001', 'judge', 1, '["女子组长拳","女子组刀术"]', '2025-06-30 23:59:59', 0, NULL, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(4, 1, 4, 'pub002', 'judge', 2, '["女子组双剑","女子组枪术"]', '2025-06-30 23:59:59', 0, NULL, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(5, 1, 5, 'pub003', 'judge', 2, '["男子组棍术","男子组剑术"]', '2025-06-30 23:59:59', 0, NULL, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(6, 1, 6, 'pub004', 'judge', 3, '["女子组长拳","男子组陈氏太极拳"]', '2025-06-30 23:59:59', 0, NULL, 1, 1, NOW(), 1, NOW(), 0, '000000');

-- =====================================================
-- 6. 插入报名订单数据
-- =====================================================
INSERT INTO `martial_registration_order` VALUES
(1, 'ORD202506250001', 1, 1001, '用户A', '张教练', '13800001111', '少林寺武术大学院', 26, 2600.00, 2600.00, 1, '2025-01-15 10:30:00', 1, NULL, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(2, 'ORD202506250002', 1, 1002, '用户B', '李老师', '13800002222', '北京体育大学', 15, 1500.00, 1500.00, 2, '2025-01-20 14:20:00', 1, NULL, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(3, 'ORD202506250003', 1, 1003, '用户C', '王队长', '13800003333', '上海武术协会', 20, 2200.00, 2200.00, 1, '2025-02-01 09:15:00', 1, NULL, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(4, 'ORD202506250004', 1, 1004, '用户D', '赵主任', '13800004444', '武当山武术学校', 18, 1900.00, 1900.00, 3, '2025-02-10 16:45:00', 1, NULL, 1, 1, NOW(), 1, NOW(), 0, '000000');

-- =====================================================
-- 7. 插入参赛选手数据(每个订单多名选手)
-- =====================================================
-- 订单1的选手(少林寺武术大学院 - 26人)
INSERT INTO `martial_athlete` VALUES
(1, 1, 1, 1, '张三丰', '123-4567898275', 1, 25, '110101199901011111', '13911111111', '少林寺武术大学院', '少林A队', '男子组', 1, '擅长陈氏太极拳', NULL, NULL, 1, 2, 8.907, 1, NULL, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(2, 1, 1, 1, '李天龙', '123-4567898276', 1, 23, '110101200001021111', '13911111112', '少林寺武术大学院', '少林A队', '男子组', 2, NULL, NULL, NULL, 1, 0, NULL, NULL, NULL, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(3, 1, 1, 2, '王小红', '123-4567898277', 2, 22, '110101200101031111', '13911111113', '少林寺武术大学院', '少林B队', '女子组', 1, NULL, NULL, NULL, 1, 0, NULL, NULL, NULL, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(4, 1, 1, 2, '赵美丽', '123-4567898278', 2, 24, '110101199901041111', '13911111114', '少林寺武术大学院', '少林B队', '女子组', 2, NULL, NULL, NULL, 1, 0, NULL, NULL, NULL, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(5, 1, 1, 5, '孙燕子', '123-4567898279', 2, 21, '110101200201051111', '13911111115', '少林寺武术大学院', '少林C队', '女子组', 1, NULL, NULL, NULL, 1, 0, NULL, NULL, NULL, 1, 1, NOW(), 1, NOW(), 0, '000000');

-- 继续插入更多选手(模拟26人,这里简化只插入关键数据)
INSERT INTO `martial_athlete` (id, order_id, competition_id, project_id, player_name, player_no, gender, age, id_card, contact_phone, organization, team_name, category, order_num, registration_status, competition_status, tenant_id)
SELECT
  5 + n, 1, 1,
  CASE (n % 4) WHEN 0 THEN 1 WHEN 1 THEN 2 WHEN 2 THEN 4 ELSE 6 END,
  CONCAT('选手', LPAD(n, 2, '0')),
  CONCAT('123-456789', LPAD(8280 + n, 4, '0')),
  ((n % 2) + 1),
  18 + (n % 15),
  CONCAT('11010119', 1995 + (n % 10), LPAD((n % 12) + 1, 2, '0'), LPAD((n % 28) + 1, 2, '0'), LPAD(1111 + n, 4, '0')),
  CONCAT('139111111', LPAD(16 + n, 2, '0')),
  '少林寺武术大学院',
  CONCAT('少林', CHAR(65 + (n % 5)), '队'),
  CASE ((n % 2) + 1) WHEN 1 THEN '男子组' ELSE '女子组' END,
  n + 1,
  1, 0, '000000'
FROM (
  SELECT @row := @row + 1 AS n
  FROM (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t1,
       (SELECT 0 UNION SELECT 1 UNION SELECT 2) t2,
       (SELECT @row := 0) r
  LIMIT 21
) numbers;

-- 订单2的选手(北京体育大学 - 15人)
INSERT INTO `martial_athlete` (id, order_id, competition_id, project_id, player_name, player_no, gender, age, id_card, contact_phone, organization, team_name, category, order_num, registration_status, competition_status, tenant_id)
SELECT
  100 + n, 2, 1,
  CASE (n % 4) WHEN 0 THEN 1 WHEN 1 THEN 3 WHEN 2 THEN 5 ELSE 7 END,
  CONCAT('北体选手', LPAD(n, 2, '0')),
  CONCAT('223-456789', LPAD(8300 + n, 4, '0')),
  ((n % 2) + 1),
  19 + (n % 12),
  CONCAT('11010220', 1996 + (n % 8), LPAD((n % 12) + 1, 2, '0'), LPAD((n % 28) + 1, 2, '0'), LPAD(2222 + n, 4, '0')),
  CONCAT('139222222', LPAD(10 + n, 2, '0')),
  '北京体育大学',
  CONCAT('北体', CHAR(65 + (n % 3)), '队'),
  CASE ((n % 2) + 1) WHEN 1 THEN '男子组' ELSE '女子组' END,
  n + 1,
  1, 0, '000000'
FROM (
  SELECT @row2 := @row2 + 1 AS n
  FROM (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t1,
       (SELECT 0 UNION SELECT 1) t2,
       (SELECT @row2 := 0) r
  LIMIT 15
) numbers;

-- =====================================================
-- 8. 插入赛程编排数据
-- =====================================================
INSERT INTO `martial_schedule` VALUES
(1, 1, 1, '男子组陈氏太极拳 - 上午场', 'SCH-001', 1, 1, 1, '2025-06-25', '上午 9:00-12:00', '2025-06-25 09:00:00', '2025-06-25 12:00:00', 10, 150, 1, 1, NULL, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(2, 1, 1, '女子组长拳 - 上午场', 'SCH-002', 1, 2, 2, '2025-06-25', '上午 9:00-12:00', '2025-06-25 09:00:00', '2025-06-25 12:00:00', 8, 120, 1, 0, NULL, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(3, 1, 1, '男子组杨氏太极拳 - 下午场', 'SCH-003', 1, 1, 4, '2025-06-25', '下午 14:00-17:00', '2025-06-25 14:00:00', '2025-06-25 17:00:00', 8, 120, 1, 0, NULL, 1, 1, NOW(), 1, NOW(), 0, '000000');

-- =====================================================
-- 9. 插入评分数据(张三丰的6位裁判评分)
-- =====================================================
INSERT INTO `martial_score` VALUES
(1, 1, 1, 1, 1, 1, '欧阳丽娜', 8.907, '[3,6,7]', '动作流畅,但节奏稍有失误', '2025-06-25 10:15:00', 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(2, 1, 1, 1, 1, 2, '张三', 8.901, '[3]', '整体表现良好', '2025-06-25 10:15:30', 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(3, 1, 1, 1, 1, 3, '李四', 8.902, '[]', '动作规范', '2025-06-25 10:16:00', 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(4, 1, 1, 1, 1, 4, '王五', 8.907, '[7]', '精神面貌好', '2025-06-25 10:16:30', 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(5, 1, 1, 1, 1, 5, '赵六', 8.905, '[1]', '表现出色', '2025-06-25 10:17:00', 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(6, 1, 1, 1, 1, 6, '陈七', 8.904, '[]', '动作标准', '2025-06-25 10:17:30', 1, 1, 1, NOW(), 1, NOW(), 0, '000000');

-- =====================================================
-- 10. 插入成绩数据
-- =====================================================
INSERT INTO `martial_result` VALUES
(1, 1, 1, 1, 1, '张三丰', '少林A队', 8.907, 8.904, 8.907, 0.005, NULL, 1, 1, 1, '2025-06-25 10:20:00', 1, 1, NOW(), 1, NOW(), 0, '000000');

-- =====================================================
-- 11. 插入活动日程
-- =====================================================
INSERT INTO `martial_activity_schedule` VALUES
(1, 1, '2025-06-25', '08:00:00', '签到注册', '主会场大厅', '参赛队伍签到,领取参赛证', NULL, 1, 2, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(2, 1, '2025-06-25', '09:00:00', '开幕式', '主竞技馆', '赛事开幕仪式', NULL, 2, 2, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(3, 1, '2025-06-25', '10:00:00', '预赛第一轮', '第一/二场地', '男子组陈氏太极拳、女子组长拳预赛', NULL, 3, 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(4, 1, '2025-06-25', '14:00:00', '预赛第二轮', '第一/二场地', '其他项目预赛', NULL, 4, 0, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(5, 1, '2025-06-26', '09:00:00', '半决赛', '第一/二/三场地', '各项目半决赛', NULL, 5, 0, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(6, 1, '2025-06-26', '14:00:00', '决赛', '主竞技馆', '各项目决赛', NULL, 6, 0, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(7, 1, '2025-06-27', '10:00:00', '颁奖典礼', '主竞技馆', '颁发金银铜牌', NULL, 7, 0, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(8, 1, '2025-06-27', '11:30:00', '闭幕式', '主竞技馆', '赛事闭幕仪式', NULL, 8, 0, 1, 1, NOW(), 1, NOW(), 0, '000000');

-- =====================================================
-- 12. 插入信息发布
-- =====================================================
INSERT INTO `martial_info_publish` VALUES
(1, 1, '报名截止时间通知', 1, '请各参赛队伍注意,报名将于2025年2月20日23:59:59截止,请尽快完成报名。', NULL, '2025-01-10 10:00:00', 1, 1, 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(2, 1, '场地变更公告', 2, '由于天气原因,部分项目场地有所调整,请关注最新通知。', NULL, '2025-06-20 15:00:00', 1, 2, 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(3, 1, '疫情防控须知', 3, '请所有参赛人员配合做好疫情防控工作,进场需出示健康码和行程卡。', NULL, '2025-06-23 09:00:00', 1, 3, 1, 1, 1, NOW(), 1, NOW(), 0, '000000');

-- =====================================================
-- 13. 插入比赛实况
-- =====================================================
INSERT INTO `martial_live_update` VALUES
(1, 1, 1, 1, 3, '精彩瞬间', '选手张三丰完成了一套流畅的陈氏太极拳,赢得现场观众热烈掌声!', '["https://example.com/live1.jpg"]', NULL, '2025-06-25 10:18:00', 1, 1, 1, NOW(), 1, 0, '000000'),
(2, 1, 1, 1, 2, '比分更新', '张三丰 - 男子组陈氏太极拳', NULL, '8.907分', '2025-06-25 10:20:00', 2, 1, 1, NOW(), 1, 0, '000000'),
(3, 1, 1, NULL, 1, '赛况播报', '上午场比赛进行顺利,目前已完成10名选手的比赛。', NULL, NULL, '2025-06-25 11:00:00', 3, 1, 1, NOW(), 1, 0, '000000');

-- =====================================================
-- 14. 插入轮播图
-- =====================================================
INSERT INTO `martial_banner` VALUES
(1, '2025武术锦标赛盛大开幕', 'https://example.com/banner1.jpg', '/competition/detail/1', 1, 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(2, '报名火热进行中', 'https://example.com/banner2.jpg', '/competition/register/1', 2, 1, 1, 1, NOW(), 1, NOW(), 0, '000000'),
(3, '往届精彩回顾', 'https://example.com/banner3.jpg', '/competition/history', 3, 1, 1, 1, NOW(), 1, NOW(), 0, '000000');

-- =====================================================
-- 验证数据
-- =====================================================
SELECT '=== 数据插入完成 ===' AS status;
SELECT '赛事数据:', COUNT(*) FROM martial_competition;
SELECT '项目数据:', COUNT(*) FROM martial_project;
SELECT '场地数据:', COUNT(*) FROM martial_venue;
SELECT '裁判数据:', COUNT(*) FROM martial_judge;
SELECT '订单数据:', COUNT(*) FROM martial_registration_order;
SELECT '选手数据:', COUNT(*) FROM martial_athlete;
SELECT '赛程数据:', COUNT(*) FROM martial_schedule;
SELECT '评分数据:', COUNT(*) FROM martial_score;
SELECT '成绩数据:', COUNT(*) FROM martial_result;
SELECT '活动日程:', COUNT(*) FROM martial_activity_schedule;
SELECT '信息发布:', COUNT(*) FROM martial_info_publish;
SELECT '比赛实况:', COUNT(*) FROM martial_live_update;
SELECT '轮播图:', COUNT(*) FROM martial_banner;
