lrj
2 天以前 c61d4fe27c97d2ecc907756aa571a4ef14a7b9b6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.rongyichuang.judge;
 
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ActiveProfiles;
 
import java.util.List;
import java.util.Map;
 
@SpringBootTest
@ActiveProfiles("test")
public class JudgeDataVerificationTest {
 
    @Autowired
    private JdbcTemplate jdbcTemplate;
 
    @Test
    public void verifyJudgeData() {
        System.out.println("=== 验证评委数据 ===");
        
        // 1. 检查最新的评委记录
        System.out.println("\n1. 最新的评委记录:");
        List<Map<String, Object>> judges = jdbcTemplate.queryForList(
            "SELECT * FROM t_judge ORDER BY id DESC LIMIT 3"
        );
        judges.forEach(judge -> {
            System.out.println("评委ID: " + judge.get("id") + 
                             ", 姓名: " + judge.get("name") + 
                             ", 电话: " + judge.get("phone"));
        });
        
        // 2. 检查最新的评委标签关联
        System.out.println("\n2. 最新的评委标签关联:");
        List<Map<String, Object>> judgeTags = jdbcTemplate.queryForList(
            "SELECT jt.*, j.name as judge_name, t.name as tag_name " +
            "FROM t_judge_tag jt " +
            "JOIN t_judge j ON jt.judge_id = j.id " +
            "JOIN t_tag t ON jt.tag_id = t.id " +
            "ORDER BY jt.judge_id DESC LIMIT 10"
        );
        judgeTags.forEach(jt -> {
            System.out.println("评委: " + jt.get("judge_name") + 
                             " -> 标签: " + jt.get("tag_name"));
        });
        
        // 3. 检查最新的媒体记录
        System.out.println("\n3. 最新的媒体记录:");
        List<Map<String, Object>> medias = jdbcTemplate.queryForList(
            "SELECT * FROM t_media ORDER BY id DESC LIMIT 3"
        );
        medias.forEach(media -> {
            System.out.println("媒体ID: " + media.get("id") + 
                             ", 路径: " + media.get("path") + 
                             ", 目标类型: " + media.get("target_type") + 
                             ", 目标ID: " + media.get("target_id"));
        });
        
        // 4. 检查评委和媒体的关联
        System.out.println("\n4. 评委和媒体的关联:");
        List<Map<String, Object>> judgeMedias = jdbcTemplate.queryForList(
            "SELECT j.id as judge_id, j.name as judge_name, " +
            "       m.id as media_id, m.path as media_path " +
            "FROM t_judge j " +
            "LEFT JOIN t_media m ON j.id = m.target_id AND m.target_type = 'JUDGE' " +
            "WHERE j.id IN (SELECT id FROM t_judge ORDER BY id DESC LIMIT 3)"
        );
        judgeMedias.forEach(jm -> {
            System.out.println("评委: " + jm.get("judge_name") + 
                             " (ID: " + jm.get("judge_id") + ")" +
                             " -> 媒体路径: " + jm.get("media_path"));
        });
        
        System.out.println("\n=== 数据验证完成 ===");
    }
}