Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
L
loit-seata-order-example
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
loit-Infrastructure-example
loit-seata-order-example
Commits
747232ef
提交
747232ef
authored
2月 14, 2020
作者:
陈世营
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sharding Test
上级
146e7ca5
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
38 行增加
和
1 行删除
+38
-1
OrderService.java
...om/loit/seata/order/example/service/biz/OrderService.java
+20
-1
ShardingSeataExampleFeignClient.java
...ple/service/comsumer/ShardingSeataExampleFeignClient.java
+11
-0
OrderController.java
...t/seata/order/example/web/controller/OrderController.java
+7
-0
没有找到文件。
loit-seata-order-example-main/src/main/java/com/loit/seata/order/example/service/biz/OrderService.java
浏览文件 @
747232ef
...
...
@@ -3,8 +3,8 @@ package com.loit.seata.order.example.service.biz;
import
com.loit.seata.order.example.model.Order
;
import
com.loit.seata.order.example.repository.OrderDAO
;
import
com.loit.seata.order.example.service.comsumer.AccountFeignClient
;
import
com.loit.seata.order.example.service.comsumer.ShardingSeataExampleFeignClient
;
import
com.loit.seata.order.example.service.comsumer.StorageFeignClient
;
import
io.seata.spring.annotation.GlobalLock
;
import
io.seata.spring.annotation.GlobalTransactional
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -19,6 +19,10 @@ public class OrderService {
private
AccountFeignClient
accountFeignClient
;
@Resource
private
StorageFeignClient
storageFeignClient
;
@Resource
private
ShardingSeataExampleFeignClient
shardingSeataExampleFeignClient
;
@Resource
private
OrderDAO
orderDAO
;
...
...
@@ -60,4 +64,19 @@ public class OrderService {
accountFeignClient
.
reduce
(
userId
,
orderMoney
);
}
@GlobalTransactional
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
shardingSeataTest
(
String
userId
,
String
commodityCode
,
Integer
count
)
{
BigDecimal
orderMoney
=
new
BigDecimal
(
count
).
multiply
(
new
BigDecimal
(
5
));
Order
order
=
new
Order
()
.
setUserId
(
userId
)
.
setCommodityCode
(
commodityCode
)
.
setCount
(
count
)
.
setMoney
(
orderMoney
);
orderDAO
.
insert
(
order
);
shardingSeataExampleFeignClient
.
purchase
();
throw
new
RuntimeException
(
"shardingSeataTest"
);
}
}
loit-seata-order-example-main/src/main/java/com/loit/seata/order/example/service/comsumer/ShardingSeataExampleFeignClient.java
0 → 100644
浏览文件 @
747232ef
package
com
.
loit
.
seata
.
order
.
example
.
service
.
comsumer
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
@FeignClient
(
name
=
"loit-shardingshere"
)
public
interface
ShardingSeataExampleFeignClient
{
@GetMapping
(
"demo/purchase"
)
void
purchase
();
}
loit-seata-order-example-main/src/main/java/com/loit/seata/order/example/web/controller/OrderController.java
浏览文件 @
747232ef
...
...
@@ -88,4 +88,11 @@ public class OrderController {
public
BaseResponse
echo
()
{
return
BaseResponse
.
ofSuccess
(
true
);
}
@GetMapping
(
"/shardingSeataTest"
)
public
BaseResponse
shardingSeataTest
()
{
orderService
.
shardingSeataTest
(
"1"
,
"product-2"
,
1
);
return
BaseResponse
.
ofSuccess
(
true
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论