fix: 优化

This commit is contained in:
胥员员 2022-11-15 15:44:54 +08:00
parent 8b924446ed
commit 31b239c0c8

View File

@ -1,11 +1,14 @@
package com.yupi.project.service; package com.yupi.project.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yupi.project.mapper.OrderMapper; import com.yupi.project.mapper.OrderMapper;
import com.yupi.project.model.entity.OrderDO; import com.yupi.project.model.entity.OrderDO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/** /**
* @author Administrator * @author Administrator
*/ */
@ -14,19 +17,23 @@ public class OrderService {
@Autowired @Autowired
private OrderMapper orderMapper; private OrderMapper orderMapper;
@Autowired
private OrderMapper orderMapper1;
@Transactional @Transactional
public void add(OrderDO order) { public void add(OrderDO order) {
// <1.1> 这里先假模假样的读取一下读取从库 // <1.1> 这里先假模假样的读取一下读取从库
OrderDO exists = orderMapper.selectById(1); OrderDO exists = orderMapper.selectById(1);
OrderDO exists1 = orderMapper1.selectById(1);
System.out.println(exists); System.out.println(exists);
System.out.println(exists1);
// <1.2> 插入订单 // <1.2> 插入订单
orderMapper.insert(order); orderMapper.insert(order);
// <1.3> 这里先假模假样的读取一下读取主库 // <1.3> 这里先假模假样的读取一下读取主库
exists = orderMapper.selectById(1); List<OrderDO> orderDOList = orderMapper.selectList(new LambdaQueryWrapper<OrderDO>().eq(OrderDO::getUserId, 10));
System.out.println(exists); System.out.println(orderDOList);
} }
public OrderDO findById(Integer id) { public OrderDO findById(Integer id) {