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 java.util.List;
|
import java.util.Map;
|
|
@SpringBootTest
|
public class JudgeTableSchemaTest {
|
|
@Autowired
|
private JdbcTemplate jdbcTemplate;
|
|
@Test
|
public void testJudgeAvatarData() {
|
try {
|
System.out.println("=== 查看评委数据 ===");
|
List<Map<String, Object>> judges = jdbcTemplate.queryForList("SELECT id, name, phone FROM t_judge WHERE state = 1 LIMIT 5");
|
|
for (Map<String, Object> judge : judges) {
|
System.out.println(String.format("评委ID: %s, 姓名: %s, 电话: %s",
|
judge.get("id"), judge.get("name"), judge.get("phone")));
|
}
|
|
System.out.println("\n=== 查看评委头像数据 (target_type=1) ===");
|
List<Map<String, Object>> avatars = jdbcTemplate.queryForList(
|
"SELECT target_id, path, name FROM t_media WHERE target_type = 1 AND state = 1");
|
|
if (avatars.isEmpty()) {
|
System.out.println("没有找到评委头像数据");
|
} else {
|
for (Map<String, Object> avatar : avatars) {
|
System.out.println(String.format("评委ID: %s, 头像路径: %s, 文件名: %s",
|
avatar.get("target_id"), avatar.get("path"), avatar.get("name")));
|
}
|
}
|
|
System.out.println("\n=== 查看所有media数据的target_type分布 ===");
|
List<Map<String, Object>> typeDistribution = jdbcTemplate.queryForList(
|
"SELECT target_type, COUNT(*) as count FROM t_media WHERE state = 1 GROUP BY target_type");
|
|
for (Map<String, Object> row : typeDistribution) {
|
System.out.println(String.format("target_type: %s, 数量: %s",
|
row.get("target_type"), row.get("count")));
|
}
|
|
} catch (Exception e) {
|
System.out.println("查询失败: " + e.getMessage());
|
e.printStackTrace();
|
}
|
}
|
}
|