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 java.util.List; import java.util.Map; @SpringBootTest public class DatabaseSchemaTest { @Autowired private JdbcTemplate jdbcTemplate; @Test public void testRatingSchemeTable() { try { // 查看评分模板表结构 String sql = "DESCRIBE t_rating_scheme"; List> result = jdbcTemplate.queryForList(sql); System.out.println("=== t_rating_scheme 表结构 ==="); for (Map row : result) { System.out.println(row); } } catch (Exception e) { System.out.println("t_rating_scheme 表不存在,查看所有表:"); String sql = "SHOW TABLES LIKE '%rating%'"; List> tables = jdbcTemplate.queryForList(sql); for (Map table : tables) { System.out.println(table); } } } @Test public void testRatingItemTable() { try { // 查看评分条目表结构 String sql = "DESCRIBE t_rating_item"; List> result = jdbcTemplate.queryForList(sql); System.out.println("=== t_rating_item 表结构 ==="); for (Map row : result) { System.out.println(row); } } catch (Exception e) { System.out.println("t_rating_item 表不存在"); } } @Test public void testAllTables() { String sql = "SHOW TABLES"; List> tables = jdbcTemplate.queryForList(sql); System.out.println("=== 所有数据库表 ==="); for (Map table : tables) { System.out.println(table); } } }