lrj
7 天以前 7ba080d35812e6db7bd5aa8f88161c02653eb6c1
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
package com.rongyichuang;
 
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 CheckActivityJudgeTest {
 
    @Autowired
    private JdbcTemplate jdbcTemplate;
 
    @Test
    public void checkActivityJudgeData() {
        try {
            // 检查活动评委关联表结构
            String describeTableSql = "DESCRIBE t_activity_judge";
            List<Map<String, Object>> tableStructure = jdbcTemplate.queryForList(describeTableSql);
            
            System.out.println("=== t_activity_judge 表结构 ===");
            for (Map<String, Object> column : tableStructure) {
                System.out.println("字段: " + column.get("Field") + 
                                 ", 类型: " + column.get("Type") + 
                                 ", 是否为空: " + column.get("Null") + 
                                 ", 键: " + column.get("Key") + 
                                 ", 默认值: " + column.get("Default"));
            }
            
            // 检查关联数据
            String countSql = "SELECT COUNT(*) as count FROM t_activity_judge";
            Map<String, Object> countResult = jdbcTemplate.queryForMap(countSql);
            System.out.println("\n=== 活动评委关联数据统计 ===");
            System.out.println("关联记录总数: " + countResult.get("count"));
            
            // 查看前5条关联数据
            String dataSql = "SELECT * FROM t_activity_judge LIMIT 5";
            List<Map<String, Object>> relationData = jdbcTemplate.queryForList(dataSql);
            System.out.println("\n=== 前5条活动评委关联数据 ===");
            for (Map<String, Object> relation : relationData) {
                System.out.println("活动ID: " + relation.get("activity_id") + 
                                 ", 评委ID: " + relation.get("judge_id") + 
                                 ", 状态: " + relation.get("state"));
            }
            
            // 检查活动ID为1的评委关联
            String activity1Sql = "SELECT * FROM t_activity_judge WHERE activity_id = 1";
            List<Map<String, Object>> activity1Judges = jdbcTemplate.queryForList(activity1Sql);
            System.out.println("\n=== 活动ID为1的评委关联 ===");
            for (Map<String, Object> relation : activity1Judges) {
                System.out.println("活动ID: " + relation.get("activity_id") + 
                                 ", 评委ID: " + relation.get("judge_id") + 
                                 ", 状态: " + relation.get("state"));
            }
            
        } catch (Exception e) {
            System.out.println("表不存在或查询失败: " + e.getMessage());
            
            // 尝试查看所有表
            String showTablesSql = "SHOW TABLES LIKE '%judge%'";
            List<Map<String, Object>> tables = jdbcTemplate.queryForList(showTablesSql);
            System.out.println("\n=== 包含judge的表 ===");
            for (Map<String, Object> table : tables) {
                System.out.println("表名: " + table.values().iterator().next());
            }
        }
    }
}