lrj
14 小时以前 f04f35b562760afbac0c477357e2a29f77aec3b9
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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<Map<String, Object>> columns = jdbcTemplate.queryForList(sql);
        
        for (Map<String, Object> 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<Map<String, Object>> columns = jdbcTemplate.queryForList(sql);
            
            for (Map<String, Object> 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<String, Object> 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<Map<String, Object>> items = jdbcTemplate.queryForList(sql);
            
            for (Map<String, Object> item : items) {
                System.out.println("评分项: " + item);
            }
            
        } catch (Exception e) {
            System.out.println("检查表结构失败: " + e.getMessage());
            e.printStackTrace();
        }
    }
}