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());
|
}
|
}
|
}
|
}
|