mirror of
https://gitee.com/yudaocode/SpringBoot-Labs.git
synced 2026-09-03 05:53:54 +08:00
增加 spring boot x seata
This commit is contained in:
@@ -22,7 +22,7 @@ public class OrderController {
|
||||
public Integer createOrder(@RequestParam("userId") Long userId,
|
||||
@RequestParam("productId") Long productId,
|
||||
@RequestParam("price") Integer price) throws Exception {
|
||||
logger.info("收到下单请求,用户:{}, 商品:{}, 价格:{}", userId, productId, price);
|
||||
logger.info("[createOrder] 收到下单请求,用户:{}, 商品:{}, 价格:{}", userId, productId, price);
|
||||
return orderService.createOrder(userId, productId, price);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package cn.iocoder.springboot.lab52.seatademo.service;
|
||||
|
||||
/**
|
||||
* 支付 Service
|
||||
* 账户 Service
|
||||
*/
|
||||
public interface PayService {
|
||||
public interface AccountService {
|
||||
|
||||
/**
|
||||
* 扣除余额
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.iocoder.springboot.lab52.seatademo.service.impl;
|
||||
|
||||
import cn.iocoder.springboot.lab52.seatademo.dao.AccountDao;
|
||||
import cn.iocoder.springboot.lab52.seatademo.service.PayService;
|
||||
import cn.iocoder.springboot.lab52.seatademo.service.AccountService;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import io.seata.core.context.RootContext;
|
||||
import org.slf4j.Logger;
|
||||
@@ -12,7 +12,7 @@ import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class PayServiceImpl implements PayService {
|
||||
public class AmountServiceImpl implements AccountService {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@@ -3,7 +3,7 @@ package cn.iocoder.springboot.lab52.seatademo.service.impl;
|
||||
import cn.iocoder.springboot.lab52.seatademo.dao.OrderDao;
|
||||
import cn.iocoder.springboot.lab52.seatademo.entity.OrderDO;
|
||||
import cn.iocoder.springboot.lab52.seatademo.service.OrderService;
|
||||
import cn.iocoder.springboot.lab52.seatademo.service.PayService;
|
||||
import cn.iocoder.springboot.lab52.seatademo.service.AccountService;
|
||||
import cn.iocoder.springboot.lab52.seatademo.service.StorageService;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import io.seata.core.context.RootContext;
|
||||
@@ -22,7 +22,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
private OrderDao orderDao;
|
||||
|
||||
@Autowired
|
||||
private PayService payService;
|
||||
private AccountService payService;
|
||||
|
||||
@Autowired
|
||||
private StorageService storageService;
|
||||
|
||||
@@ -5,12 +5,6 @@ spring:
|
||||
application:
|
||||
name: multi-datasource-service # 应用名
|
||||
|
||||
# cloud:
|
||||
# alibaba:
|
||||
# # Seata 配置项,对应 SpringCloudAlibabaConfiguration 类
|
||||
# seata:
|
||||
# tx-service-group: my_test_tx_group
|
||||
|
||||
datasource:
|
||||
# dynamic-datasource-spring-boot-starter 动态数据源的配配项,对应 DynamicDataSourceProperties 类
|
||||
dynamic:
|
||||
@@ -22,8 +16,8 @@ spring:
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password:
|
||||
# 支付 pay 数据源配置
|
||||
pay-ds:
|
||||
# 账户 pay 数据源配置
|
||||
amount-ds:
|
||||
url: jdbc:mysql://127.0.0.1:3306/seata_pay?useSSL=false&useUnicode=true&characterEncoding=UTF-8
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
|
||||
Reference in New Issue
Block a user