package com.ruoyi; import com.ruoyi.domain.ZfDoctor; import com.ruoyi.domain.ZfEquipment; import com.ruoyi.domain.ZfEvent; import com.ruoyi.service.ZfDoctorService; import com.ruoyi.service.ZfEquipmentService; 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; @Autowired private ZfEquipmentService zfEquipmentService; @Test public void insert(){ List people = Arrays.asList("张三,张强,张力", "张萌,张蒙", "张旺,张点,张可", "张章,张常", "张璇,张为,张强,张力"); List 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 l1 = Arrays.asList("牙科", "神经科","外科"); List l2 = Arrays.asList("牙痛", "头痛", "皮肤炎"); List l3 = Arrays.asList("一个月", "半个月", "一天"); List l4 = Arrays.asList("白芷10g", "中医药1", "中医药2"); List l5 = Arrays.asList("维生素C", "布洛芬", "皮康霜"); List l6 = Arrays.asList("缓解牙痛", "缓解头痛", "缓解皮肤炎"); List l7 = Arrays.asList("张三", "李四", "王五"); List 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); } } @Test void insertEquipment(){ List l1 = Arrays.asList("电视", "电冰箱","电脑"); List l2 = Arrays.asList("2020-11-11", "2021-11-12", "2022-12-08"); List l3 = Arrays.asList("张三", "李四", "王五"); List l4 = Arrays.asList("夏普液晶电视", "西门子电冰箱", "苹果电脑"); List l5 = Arrays.asList("客厅", "厨房", "卧室"); List l6 = Arrays.asList("4k超高清", "双开门", "M2芯片"); ZfEquipment zfEquipment=null; int count=0; for (int i = 0; i < 200; i++) { count=count%3; zfEquipment=new ZfEquipment(); zfEquipment.setName(l1.get(count)); zfEquipment.setBuyer(l3.get(count)); zfEquipment.setContent(l4.get(count)); zfEquipment.setLocation(l5.get(count)); zfEquipment.setRemark(l6.get(count)); zfEquipment.setUrl("profile/upload/2023/03/19/test7_20230319222030A007.jpg"); count++; zfEquipmentService.save(zfEquipment); } } }