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("dev") public class CheckTableStructureTest { @Autowired private JdbcTemplate jdbcTemplate; @Test public void checkActivityPlayerRatingTableStructure() { System.out.println("=== 检查 t_activity_player_rating 表结构 ==="); String sql = "DESCRIBE t_activity_player_rating"; List> columns = jdbcTemplate.queryForList(sql); for (Map column : columns) { System.out.println("字段: " + column.get("Field") + ", 类型: " + column.get("Type") + ", 是否为空: " + column.get("Null") + ", 键: " + column.get("Key") + ", 默认值: " + column.get("Default")); } // 检查是否存在rating_scheme_id字段 boolean hasRatingSchemeId = columns.stream() .anyMatch(col -> "rating_scheme_id".equals(col.get("Field"))); System.out.println("是否存在rating_scheme_id字段: " + hasRatingSchemeId); } @Test public void checkRatingItemTable() { System.out.println("=== 检查 t_rating_item 表结构 ==="); try { String sql = "DESCRIBE t_rating_item"; List> columns = jdbcTemplate.queryForList(sql); for (Map column : columns) { System.out.println("字段: " + column.get("Field") + ", 类型: " + column.get("Type") + ", 是否为空: " + column.get("Null") + ", 键: " + column.get("Key") + ", 默认值: " + column.get("Default")); } System.out.println("\n=== 检查 t_rating_scheme 表结构 ==="); sql = "DESCRIBE t_rating_scheme"; columns = jdbcTemplate.queryForList(sql); for (Map column : columns) { System.out.println("字段: " + column.get("Field") + ", 类型: " + column.get("Type") + ", 是否为空: " + column.get("Null") + ", 键: " + column.get("Key") + ", 默认值: " + column.get("Default")); } System.out.println("\n=== 检查评分项数据 ==="); sql = "SELECT * FROM t_rating_item LIMIT 5"; List> items = jdbcTemplate.queryForList(sql); for (Map item : items) { System.out.println("评分项: " + item); } } catch (Exception e) { System.out.println("检查表结构失败: " + e.getMessage()); e.printStackTrace(); } } }