package com.wm.demo1.service;
import com.wm.demo1.entity.*;
import com.wm.demo1.ignite.repository.PersonRepository;
import com.wm.demo1.mapper.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionTemplate;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**********************************************************
* 类描述:
* 创建人:王锰
* 创建时间:2021年03月25日 下午3:07
* 修改备注:
**********************************************************/
@Service
@Slf4j
public class PersonService {
@Autowired
private PersonRepository personRepository;
@Autowired
private PersonMapper personMapper;
@Autowired
private ChildOneService childOneService;
@Autowired
private ChildTwoService childTwoService;
@Autowired
private ChildThreeService childThreeService;
@Autowired
private ChildFourService childFourService;
@Autowired
private ChildOneMapper childOneMapper;
@Autowired
private ChildTwoMapper childTwoMapper;
@Autowired
private ChildThreeMapper childThreeMapper;
@Autowired
private ChildFourMapper childFourMapper;
@Autowired
private TransactionTemplate transactionTemplate;
public Person save(Person person) {
final Person save = personRepository.save(person.getId(), person);
log.info("save:{}", person.toString());
return save;
}
public Person findById(Long id) {
return personRepository.findById(id).orElseThrow(() -> new RuntimeException("id不存在"));
}
public List<Person> findAll() {
final Iterable<Person> all = personRepository.findAll();
List<Person> list = new ArrayList<>();
all.forEach(list::add);
return list;
}
public void testOneInsert(int num) {
int parentId = 10000;
String json = "{\"appid\":\"wx431fef5c79711f2b\",\"body\":\"商品缴费\",\"busiScopeNo\":\"WS\",\"cardinfo\":[],\"chongzhiUrl\":\"充值URL暂不需要\",\"goods\":[{\"quantity\":1,\"price\":\"payTotalPrice\",\"goodsName\":\"外卖单\"}],\"items\":[{\"calcPrice\":4,\"code\":\"101001\",\"hyjFlg\":\"1\",\"istc\":\"0\",\"itemMOList\":[{\"addPr\":\"0\",\"addPrType\":0,\"moID\":136,\"moName\":\"特辣\",\"qty\":1}],\"itemcount\":1,\"itemid\":720,\"itemname\":\"长沙臭豆腐@大份\",\"mljFlg\":\"1\",\"npartPr\":9,\"price\":9,\"skuinfo\":\"瓶\",\"unID\":-1,\"unName\":\"瓶\",\"vipPrice\":4}],\"kind\":\"10325\",\"login_token\":\"2c6y2fo6XJLdAx+3mUQStw==\",\"money\":15.00,\"mpid\":\"gh_8a00eb1a4d42\",\"openid\":\"oYo7s4pDj0ysGiu5R5pCi3J_e__k\",\"order_entry\":\"pages/index\",\"orderid\":\"6103821289091233874922\",\"otherBillAmount\":\"11\",\"otherBillAmountRemark\":\"餐盒费1,配送费10\",\"parentOpenid\":\"\",\"payBusinNo\":\"6103821289091233874922\",\"payFrom\":3,\"payMoney\":15.00,\"paySerialNo\":\"\",\"payTypeProd\":\"miniProgram\",\"payhuis\":[{\"huiprice\":5,\"huiremark\":\"微信会员价结算立减5元\",\"huitypeid\":\"1\"},{\"huiprice\":0,\"huiremark\":\"促销方案价结算立减0元\",\"huitypeid\":\"3\"},{\"huiprice\":0,\"huiremark\":\"满N优惠结算立减0元\",\"huitypeid\":\"5\"},{\"huiprice\":0,\"huiremark\":\"配送费满减0元\",\"huitypeid\":\"4\"}],\"paytypeid\":0,\"storeid\":\"7178\",\"trueMoney\":15.00,\"turnUrl\":\"跳转URL暂不需要\",\"udStateUrl\":\"http://alpha2.wuuxiang.com/api/tcsl/UpdateDeInfo.htm\",\"unionid\":\"obts_wTIPXjQX8sUCkzFP-cYC-ko\"}";
Person person = new Person();
person.setId(parentId);
person.setName("wangxiaoming");
List<ChildOne> listOne = new ArrayList<>();
List<ChildTwo> listTwo = new ArrayList<>();
List<ChildThree> listThree = new ArrayList<>();
List<ChildFour> listFour = new ArrayList<>();
for (int i = 0; i < num; i++) {
ChildOne childOne = new ChildOne();
ChildTwo childTwo = new ChildTwo();
ChildThree childThree = new ChildThree();
ChildFour childFour = new ChildFour();
final int id = 1000;
childOne.setId(id + i);
childTwo.setId(id + i);
childThree.setId(id + i);
childFour.setId(id + i);
childOne.setParentId(parentId);
childTwo.setParentId(parentId);
childThree.setParentId(parentId);
childFour.setParentId(parentId);
childOne.setJson(json);
childTwo.setJson(json);
childThree.setJson(json);
childFour.setJson(json);
listOne.add(childOne);
listTwo.add(childTwo);
listThree.add(childThree);
listFour.add(childFour);
}
PersonAll personAll = new PersonAll();
personAll.setPerson(person);
personAll.setListOne(listOne);
personAll.setListTwo(listTwo);
personAll.setListThree(listThree);
personAll.setListFour(listFour);
long start = System.currentTimeMillis();
transactionTemplate.execute(status -> {
personMapper.insertAll(personAll);
return true;
});
log.info("一次发送多个表的insert语句,insert使用多value方式。time:{}", System.currentTimeMillis() - start);
}
public void testOneInsert2(int num) {
int parentId = 10000;
String json = "{\"appid\":\"wx431fef5c79711f2b\",\"body\":\"商品缴费\",\"busiScopeNo\":\"WS\",\"cardinfo\":[],\"chongzhiUrl\":\"充值URL暂不需要\",\"goods\":[{\"quantity\":1,\"price\":\"payTotalPrice\",\"goodsName\":\"外卖单\"}],\"items\":[{\"calcPrice\":4,\"code\":\"101001\",\"hyjFlg\":\"1\",\"istc\":\"0\",\"itemMOList\":[{\"addPr\":\"0\",\"addPrType\":0,\"moID\":136,\"moName\":\"特辣\",\"qty\":1}],\"itemcount\":1,\"itemid\":720,\"itemname\":\"长沙臭豆腐@大份\",\"mljFlg\":\"1\",\"npartPr\":9,\"price\":9,\"skuinfo\":\"瓶\",\"unID\":-1,\"unName\":\"瓶\",\"vipPrice\":4}],\"kind\":\"10325\",\"login_token\":\"2c6y2fo6XJLdAx+3mUQStw==\",\"money\":15.00,\"mpid\":\"gh_8a00eb1a4d42\",\"openid\":\"oYo7s4pDj0ysGiu5R5pCi3J_e__k\",\"order_entry\":\"pages/index\",\"orderid\":\"6103821289091233874922\",\"otherBillAmount\":\"11\",\"otherBillAmountRemark\":\"餐盒费1,配送费10\",\"parentOpenid\":\"\",\"payBusinNo\":\"6103821289091233874922\",\"payFrom\":3,\"payMoney\":15.00,\"paySerialNo\":\"\",\"payTypeProd\":\"miniProgram\",\"payhuis\":[{\"huiprice\":5,\"huiremark\":\"微信会员价结算立减5元\",\"huitypeid\":\"1\"},{\"huiprice\":0,\"huiremark\":\"促销方案价结算立减0元\",\"huitypeid\":\"3\"},{\"huiprice\":0,\"huiremark\":\"满N优惠结算立减0元\",\"huitypeid\":\"5\"},{\"huiprice\":0,\"huiremark\":\"配送费满减0元\",\"huitypeid\":\"4\"}],\"paytypeid\":0,\"storeid\":\"7178\",\"trueMoney\":15.00,\"turnUrl\":\"跳转URL暂不需要\",\"udStateUrl\":\"http://alpha2.wuuxiang.com/api/tcsl/UpdateDeInfo.htm\",\"unionid\":\"obts_wTIPXjQX8sUCkzFP-cYC-ko\"}";
Person person = new Person();
person.setId(parentId);
person.setName("wangxiaoming");
List<ChildOne> listOne = new ArrayList<>();
List<ChildTwo> listTwo = new ArrayList<>();
List<ChildThree> listThree = new ArrayList<>();
List<ChildFour> listFour = new ArrayList<>();
for (int i = 0; i < num; i++) {
ChildOne childOne = new ChildOne();
ChildTwo childTwo = new ChildTwo();
ChildThree childThree = new ChildThree();
ChildFour childFour = new ChildFour();
final int id = 1000;
childOne.setId(id + i);
childTwo.setId(id + i);
childThree.setId(id + i);
childFour.setId(id + i);
childOne.setParentId(parentId);
childTwo.setParentId(parentId);
childThree.setPa
没有合适的资源?快使用搜索试试~ 我知道了~
mybatis plus 5种批量操作性能测试
共947个文件
classname0:699个
xml:175个
java:27个
需积分: 50 21 下载量 151 浏览量
2021-03-31
00:12:20
上传
评论 2
收藏 401KB ZIP 举报
温馨提示
测试在单元测试中
资源推荐
资源详情
资源评论
收起资源包目录
mybatis plus 5种批量操作性能测试 (947个子文件)
$PRODUCT_WORKSPACE_FILE$ 489B
PersonService.class 15KB
IgniteController.class 7KB
PersonCache.class 4KB
PersonAll.class 4KB
igniteConfig.class 4KB
IgniteRemoteListenService.class 4KB
ChildThree.class 2KB
ChildFour.class 2KB
ChildOne.class 2KB
ChildTwo.class 2KB
Person.class 2KB
Start.class 2KB
test.class 1KB
OrderController.class 1KB
ApplicationUtils.class 1KB
Start.class 1012B
OrderHandler.class 697B
ChildThreeService.class 600B
ChildFourService.class 595B
ChildTwoService.class 590B
ChildOneService.class 590B
PersonRepository.class 498B
ChildThreeMapper.class 455B
ChildFourMapper.class 451B
ChildOneMapper.class 447B
ChildTwoMapper.class 447B
PersonMapper.class 431B
-508813789.classname0 127B
-1103045131.classname0 121B
1088523225.classname0 121B
-214766806.classname0 121B
353451091.classname0 121B
2022747413.classname0 121B
454671454.classname0 121B
-1661589030.classname0 120B
566576278.classname0 120B
299847278.classname0 120B
-774576598.classname0 113B
-1091113903.classname0 113B
-826460663.classname0 113B
1055966517.classname0 113B
362096568.classname0 113B
330474244.classname0 113B
938284269.classname0 113B
1396248048.classname0 113B
1015848105.classname0 113B
1763764690.classname0 113B
753070976.classname0 112B
-305788204.classname0 112B
-1161593882.classname0 112B
-552499255.classname0 112B
943021234.classname0 112B
-100360699.classname0 112B
47954883.classname0 112B
-852413129.classname0 111B
-2071311540.classname0 107B
-587151368.classname0 107B
-670562117.classname0 107B
1354036671.classname0 107B
-1998404069.classname0 107B
1114970758.classname0 107B
152363358.classname0 107B
-1686406524.classname0 107B
-2017961569.classname0 107B
1370474757.classname0 107B
1817484030.classname0 107B
-480742836.classname0 107B
-667298931.classname0 107B
-682507583.classname0 107B
-1687658529.classname0 107B
-519675014.classname0 107B
-781405394.classname0 107B
660141295.classname0 107B
816008527.classname0 107B
-369547600.classname0 107B
-1830258209.classname0 107B
-170452484.classname0 107B
907033554.classname0 107B
1564567398.classname0 107B
773666652.classname0 107B
2032836909.classname0 107B
1482126769.classname0 107B
-1507038824.classname0 107B
-1729966693.classname0 107B
1578176470.classname0 107B
1587771799.classname0 107B
-517559998.classname0 107B
864267122.classname0 107B
-337187661.classname0 107B
-358461397.classname0 107B
844994342.classname0 107B
334458170.classname0 107B
-639468062.classname0 107B
974632935.classname0 107B
30645205.classname0 107B
1196111273.classname0 107B
-1617313912.classname0 107B
855460216.classname0 107B
-45597106.classname0 107B
共 947 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
maybe宸
- 粉丝: 53
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功