lrj
2 天以前 c61d4fe27c97d2ecc907756aa571a4ef14a7b9b6
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
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<Map<String, Object>> result = jdbcTemplate.queryForList(sql);
            System.out.println("=== t_rating_scheme 表结构 ===");
            for (Map<String, Object> row : result) {
                System.out.println(row);
            }
        } catch (Exception e) {
            System.out.println("t_rating_scheme 表不存在,查看所有表:");
            String sql = "SHOW TABLES LIKE '%rating%'";
            List<Map<String, Object>> tables = jdbcTemplate.queryForList(sql);
            for (Map<String, Object> table : tables) {
                System.out.println(table);
            }
        }
    }
 
    @Test
    public void testRatingItemTable() {
        try {
            // 查看评分条目表结构
            String sql = "DESCRIBE t_rating_item";
            List<Map<String, Object>> result = jdbcTemplate.queryForList(sql);
            System.out.println("=== t_rating_item 表结构 ===");
            for (Map<String, Object> row : result) {
                System.out.println(row);
            }
        } catch (Exception e) {
            System.out.println("t_rating_item 表不存在");
        }
    }
 
    @Test
    public void testAllTables() {
        String sql = "SHOW TABLES";
        List<Map<String, Object>> tables = jdbcTemplate.queryForList(sql);
        System.out.println("=== 所有数据库表 ===");
        for (Map<String, Object> table : tables) {
            System.out.println(table);
        }
    }
}