Skip to content

Commit

Permalink
增加 spring boot x seata
Browse files Browse the repository at this point in the history
  • Loading branch information
YunaiV committed Apr 2, 2020
1 parent 644ef85 commit d2d18b8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package cn.iocoder.springboot.lab52.seatademo.service;

/**
* 支付 Service
* 账户 Service
*/
public interface PayService {
public interface AccountService {

/**
* 扣除余额
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,7 +12,7 @@
import org.springframework.transaction.annotation.Transactional;

@Service
public class PayServiceImpl implements PayService {
public class AmountServiceImpl implements AccountService {

private Logger logger = LoggerFactory.getLogger(getClass());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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;
Expand All @@ -22,7 +22,7 @@ public class OrderServiceImpl implements OrderService {
private OrderDao orderDao;

@Autowired
private PayService payService;
private AccountService payService;

@Autowired
private StorageService storageService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit d2d18b8

Please sign in to comment.