-- 插入评分模板数据
-- 注意：这个脚本会创建一个编程大赛的评分模板

-- 1. 插入评分模板 (t_rating_scheme)
INSERT INTO t_rating_scheme (id, name, description, state, create_time, create_user_id, update_time, update_user_id, version) 
VALUES (1, '编程大赛评分标准', '用于编程比赛的综合评分标准，包含代码质量、功能完整性、用户体验、创新性和项目展示等维度', 1, NOW(), 1, NOW(), 1, 0);

-- 2. 插入评分项目 (t_rating_item)
INSERT INTO t_rating_item (id, scheme_id, name, max_score, order_no, create_time, create_user_id, update_time, update_user_id, version) VALUES
(1, 1, '代码质量', 30, 1, NOW(), 1, NOW(), 1, 0),
(2, 1, '功能完整性', 25, 2, NOW(), 1, NOW(), 1, 0),
(3, 1, '用户体验', 20, 3, NOW(), 1, NOW(), 1, 0),
(4, 1, '创新性', 15, 4, NOW(), 1, NOW(), 1, 0),
(5, 1, '项目展示', 10, 5, NOW(), 1, NOW(), 1, 0);

-- 验证插入结果
SELECT '=== 评分模板 ===' as info;
SELECT * FROM t_rating_scheme WHERE id = 1;

SELECT '=== 评分项目 ===' as info;
SELECT * FROM t_rating_item WHERE scheme_id = 1 ORDER BY order_no;

SELECT '=== 总分验证 ===' as info;
SELECT 
    rs.name as scheme_name,
    SUM(ri.max_score) as total_max_score
FROM t_rating_scheme rs
LEFT JOIN t_rating_item ri ON rs.id = ri.scheme_id
WHERE rs.id = 1
GROUP BY rs.id, rs.name;