mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-02-05 18:15:28 +08:00
spring3
This commit is contained in:
@ -13,7 +13,7 @@ import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,15 @@
|
||||
server:
|
||||
port: 5002
|
||||
spring:
|
||||
data:
|
||||
redis:
|
||||
##redis 单机环境配置
|
||||
host: localhost
|
||||
port: 6379
|
||||
database: 0
|
||||
password:
|
||||
ssl:
|
||||
enabled: false
|
||||
application:
|
||||
name: seata-account
|
||||
main:
|
||||
@ -18,8 +27,13 @@ spring:
|
||||
password: root
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
schema: classpath:sql/schema-account.sql
|
||||
cloud:
|
||||
nacos:
|
||||
config:
|
||||
import-check:
|
||||
enabled: false
|
||||
seata:
|
||||
enable-auto-data-source-proxy: false
|
||||
enable-auto-data-source-proxy: true
|
||||
service:
|
||||
grouplist:
|
||||
default: 127.0.0.1:8091
|
||||
|
||||
@ -6,9 +6,9 @@ package org.jeecg.modules.test.seata.order.controller;
|
||||
* @date: 2022/01/24
|
||||
* @version: V1.0
|
||||
*/
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.jeecg.modules.test.seata.order.dto.PlaceOrderRequest;
|
||||
import org.jeecg.modules.test.seata.order.service.SeataOrderService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/test/seata/order")
|
||||
@Api(tags = "seata测试")
|
||||
@Tag(name = "seata测试")
|
||||
public class SeataOrderController {
|
||||
|
||||
@Autowired
|
||||
@ -30,7 +30,7 @@ public class SeataOrderController {
|
||||
* 自由下单
|
||||
*/
|
||||
@PostMapping("/placeOrder")
|
||||
@ApiOperation(value = "自由下单", notes = "自由下单")
|
||||
@Operation(summary = "自由下单")
|
||||
public String placeOrder(@Validated @RequestBody PlaceOrderRequest request) {
|
||||
orderService.placeOrder(request);
|
||||
return "下单成功";
|
||||
@ -40,7 +40,7 @@ public class SeataOrderController {
|
||||
* 测试商品库存不足-异常回滚
|
||||
*/
|
||||
@PostMapping("/test1")
|
||||
@ApiOperation(value = "测试商品库存不足", notes = "测试商品库存不足")
|
||||
@Operation(summary = "测试商品库存不足")
|
||||
public String test1() {
|
||||
//商品单价10元,库存20个,用户余额50元,模拟一次性购买22个。 期望异常回滚
|
||||
orderService.placeOrder(new PlaceOrderRequest(1L, 1L, 22));
|
||||
@ -51,7 +51,7 @@ public class SeataOrderController {
|
||||
* 测试用户账户余额不足-异常回滚
|
||||
*/
|
||||
@PostMapping("/test2")
|
||||
@ApiOperation(value = "测试用户账户余额不足", notes = "测试用户账户余额不足")
|
||||
@Operation(summary = "测试用户账户余额不足")
|
||||
public String test2() {
|
||||
//商品单价10元,库存20个,用户余额50元,模拟一次性购买6个。 期望异常回滚
|
||||
orderService.placeOrder(new PlaceOrderRequest(1L, 1L, 6));
|
||||
|
||||
@ -4,7 +4,7 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
/**
|
||||
* @Description: 订单请求对象
|
||||
* @author: zyf
|
||||
|
||||
@ -16,7 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
|
||||
@ -1,12 +1,21 @@
|
||||
server:
|
||||
port: 5001
|
||||
spring:
|
||||
data:
|
||||
redis:
|
||||
##redis 单机环境配置
|
||||
host: localhost
|
||||
port: 6379
|
||||
database: 0
|
||||
password:
|
||||
ssl:
|
||||
enabled: false
|
||||
application:
|
||||
name: seata-order
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
autoconfigure:
|
||||
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
|
||||
exclude: com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure
|
||||
datasource:
|
||||
dynamic:
|
||||
primary: order
|
||||
@ -19,6 +28,11 @@ spring:
|
||||
username: root
|
||||
password: root
|
||||
schema: classpath:sql/schema-order.sql
|
||||
cloud:
|
||||
nacos:
|
||||
config:
|
||||
import-check:
|
||||
enabled: false
|
||||
seata:
|
||||
enable-auto-data-source-proxy: false
|
||||
service:
|
||||
|
||||
@ -6,6 +6,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
@ -19,7 +20,7 @@ public class SeataProductController {
|
||||
private SeataProductService seataProductService;
|
||||
|
||||
@PostMapping("/reduceStock")
|
||||
public BigDecimal reduceStock(Long productId, Integer count) {
|
||||
public BigDecimal reduceStock(Long productId, Integer count, HttpServletRequest request) {
|
||||
return seataProductService.reduceStock(productId, count);
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,15 @@
|
||||
server:
|
||||
port: 5003
|
||||
spring:
|
||||
data:
|
||||
redis:
|
||||
##redis 单机环境配置
|
||||
host: localhost
|
||||
port: 6379
|
||||
database: 0
|
||||
password:
|
||||
ssl:
|
||||
enabled: false
|
||||
application:
|
||||
name: seata-product
|
||||
main:
|
||||
@ -18,6 +27,11 @@ spring:
|
||||
username: root
|
||||
password: root
|
||||
schema: classpath:sql/schema-product.sql
|
||||
cloud:
|
||||
nacos:
|
||||
config:
|
||||
import-check:
|
||||
enabled: false
|
||||
seata:
|
||||
enable-auto-data-source-proxy: false
|
||||
service:
|
||||
|
||||
Reference in New Issue
Block a user