Jinquan_Ou
2023-04-03 1dfe61fdf1b36061871ead5337172801e64df201
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
package com.ruoyi;
 
import com.ruoyi.domain.ZfDoctor;
import com.ruoyi.domain.ZfEvent;
import com.ruoyi.service.ZfDoctorService;
import com.ruoyi.service.ZfEventService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
 
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
 
/**
 * @Version 1.0
 * @Author Jin_quan Ou
 * @Date 2023-03-22 19:11
 */
@SpringBootTest
public class insertData {
 
    @Autowired
    private ZfEventService zfEventService;
 
    @Autowired
    private ZfDoctorService zfDoctorService;
 
    @Test
    public void insert(){
        List<String> people = Arrays.asList("张三,张强,张力", "张萌,张蒙", "张旺,张点,张可", "张章,张常", "张璇,张为,张强,张力");
        List<String> address = Arrays.asList("花园", "海滩", "公园", "游乐场", "田园", "农庄");
 
        ZfEvent zfEvent = null;
 
        for (int i = 0; i < 200; i++) {
            zfEvent=new ZfEvent();
            int peopleRandom = new Random().nextInt(5);//0-4的随机数
            int addressRandom = new Random().nextInt(6);//0-5的随机数
 
            String base="abcdefghijklmnopqrstuvwxyz";
            int strRandom1 = new Random().nextInt(16);//0-15的随机数
            int strRandom2 = new Random().nextInt(16);//0-15的随机数
            String title=base.substring(strRandom1,strRandom1+8);
            String remark=base.substring(strRandom2,strRandom2+8);
 
            zfEvent.setPeople(people.get(peopleRandom));
            zfEvent.setAddress(address.get(addressRandom));
            zfEvent.setTitle(title);
            zfEvent.setRemark(remark);
            zfEventService.save(zfEvent);
 
        }
 
    }
    @Test
    void insertDoctor(){
        List<String> l1 = Arrays.asList("牙科", "神经科","外科");
        List<String> l2 = Arrays.asList("牙痛", "头痛", "皮肤炎");
        List<String> l3 = Arrays.asList("一个月", "半个月", "一天");
        List<String> l4 = Arrays.asList("白芷10g", "中医药1", "中医药2");
        List<String> l5 = Arrays.asList("维生素C", "布洛芬", "皮康霜");
        List<String> l6 = Arrays.asList("缓解牙痛", "缓解头痛", "缓解皮肤炎");
        List<String> l7 = Arrays.asList("张三", "李四", "王五");
        List<String> l8 = Arrays.asList("专治牙痛", "专治头痛", "专治皮肤炎");
 
        ZfDoctor zfDoctor=null;
        int count=0;
        for (int i = 0; i < 200; i++) {
            count=count%3;
            zfDoctor=new ZfDoctor();
            zfDoctor.setType(l1.get(count));
            zfDoctor.setSymptom(l2.get(count));
            zfDoctor.setDuration(l3.get(count));
            zfDoctor.setCMedical(l4.get(count));
            zfDoctor.setWMedical(l5.get(count));
            zfDoctor.setEffect(l6.get(count));
            zfDoctor.setSuitable(l7.get(count));
            zfDoctor.setRemark(l8.get(count));
            zfDoctor.setUrl("profile/upload/2023/03/19/test7_20230319222030A007.jpg");
            count++;
            zfDoctorService.save(zfDoctor);
        }
    }
 
}