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
package com.dy.pipIrrDemo.mp;
 
import com.dy.common.multiDataSource.DataSourceContext;
import com.dy.pipIrrGlobal.pojoDemo.DemoMp;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
 
import java.time.LocalDateTime;
 
@RunWith(SpringRunner.class)
@SpringBootTest
public class MpTest1 {
 
    @Autowired
    private DemoMpSv demoMpSv ;
 
    @Before
    public void setup(){
        DataSourceContext.set("ym");
    }
 
    @Test
    public void insert(){
        DemoMp po = new DemoMp() ;
        po.name = "张三" ;
        po.age = 20 ;
        po.dt = LocalDateTime.now() ;
        int count = this.demoMpSv.insert(po) ;
        System.out.println("插入了" + count + "记录");
    }
 
    @Test
    public void updateById(){
        //把上面插入的记录进行更新
        DemoMp po = new DemoMp() ;
        po.id = 2023110716001900000L ;
        po.name = "李四" ;
        po.age = 22 ;
        //po.dt = LocalDateTime.now() ;
        int count = this.demoMpSv.updateById(po);
        System.out.println("更新了" + count + "记录");
    }
 
    @Test
    public void selectById(){
        DemoMp po = this.demoMpSv.selectById(1L) ;
    }
}