package com.ruoyi;
|
|
import com.ruoyi.domain.ZfEvent;
|
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;
|
|
@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);
|
|
}
|
|
}
|
}
|