admin
2025-07-30 cc5cf127da76d03ce7086da4d70f34b20e9803e0
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package com.taoke.autopay.dao;
 
import com.taoke.autopay.entity.ClientAdditionalInfo;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
 
import javax.annotation.Resource;
import java.util.Date;
 
/**
 * @author 
 * @title: ClientAdditionalInfoMapperTest
 * @description: ClientAdditionalInfoMapper单元测试
 * @date 2024/6/14 18:09
 */
@SpringBootTest
public class ClientAdditionalInfoMapperTest {
 
    @Resource
    private ClientAdditionalInfoMapper clientAdditionalInfoMapper;
 
    @Test
    public void testInsert() {
        ClientAdditionalInfo info = ClientAdditionalInfo.builder()
                .id(System.currentTimeMillis()) // 使用当前时间戳作为ID
                .mobile("13800138000")
                .alipayAccount("alipay@example.com")
                .alipayPassword("password123")
                .createTime(new Date())
                .updateTime(new Date())
                .build();
        
        int result = clientAdditionalInfoMapper.insert(info);
        System.out.println("插入结果: " + result);
    }
 
    @Test
    public void testSelectByPrimaryKey() {
        // 先插入一条测试数据
        long id = System.currentTimeMillis();
        ClientAdditionalInfo info = ClientAdditionalInfo.builder()
                .id(id)
                .mobile("13900139000")
                .alipayAccount("alipay2@example.com")
                .alipayPassword("password456")
                .createTime(new Date())
                .updateTime(new Date())
                .build();
        
        clientAdditionalInfoMapper.insert(info);
        
        // 查询刚刚插入的数据
        ClientAdditionalInfo result = clientAdditionalInfoMapper.selectByPrimaryKey(id);
        System.out.println("查询结果: " + result);
    }
 
    @Test
    public void testUpdateByPrimaryKey() {
        // 先插入一条测试数据
        long id = System.currentTimeMillis();
        ClientAdditionalInfo info = ClientAdditionalInfo.builder()
                .id(id)
                .mobile("13700137000")
                .alipayAccount("alipay3@example.com")
                .alipayPassword("password789")
                .createTime(new Date())
                .updateTime(new Date())
                .build();
        
        clientAdditionalInfoMapper.insert(info);
        
        // 更新数据
        ClientAdditionalInfo updateInfo = ClientAdditionalInfo.builder()
                .id(id)
                .mobile("13600136000")
                .alipayAccount("alipay4@example.com")
                .alipayPassword("newpassword123")
                .createTime(info.getCreateTime())
                .updateTime(new Date())
                .build();
        
        int result = clientAdditionalInfoMapper.updateByPrimaryKey(updateInfo);
        System.out.println("更新结果: " + result);
        
        // 查询更新后的数据
        ClientAdditionalInfo resultInfo = clientAdditionalInfoMapper.selectByPrimaryKey(id);
        System.out.println("更新后数据: " + resultInfo);
    }
 
    @Test
    public void testDeleteByPrimaryKey() {
        // 先插入一条测试数据
        long id = System.currentTimeMillis();
        ClientAdditionalInfo info = ClientAdditionalInfo.builder()
                .id(id)
                .mobile("13500135000")
                .alipayAccount("alipay5@example.com")
                .alipayPassword("password999")
                .createTime(new Date())
                .updateTime(new Date())
                .build();
        
        clientAdditionalInfoMapper.insert(info);
        
        // 删除数据
        int result = clientAdditionalInfoMapper.deleteByPrimaryKey(id);
        System.out.println("删除结果: " + result);
    }
}