From 5300c070d95f9f3d6222b149e8431e77e9337637 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 13 四月 2021 18:33:58 +0800 Subject: [PATCH] 单片购买 --- src/main/java/com/yeshi/buwan/service/manager/SeataManagerTest.java | 58 ++++++++++++++++++++++++++++++++++------------------------ 1 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/yeshi/buwan/service/manager/SeataManagerTest.java b/src/main/java/com/yeshi/buwan/service/manager/SeataManagerTest.java index d414fd3..8dd58ea 100644 --- a/src/main/java/com/yeshi/buwan/service/manager/SeataManagerTest.java +++ b/src/main/java/com/yeshi/buwan/service/manager/SeataManagerTest.java @@ -1,32 +1,42 @@ package com.yeshi.buwan.service.manager; +import com.ks.goldcorn.pojo.DO.GoldCornGetSource; +import com.ks.goldcorn.service.remote.GoldCornGetSourceService; +import com.yeshi.buwan.dao.user.LoginUserDao; +import com.yeshi.buwan.domain.user.LoginUser; +import io.seata.core.context.RootContext; +import io.seata.spring.annotation.GlobalTransactional; +import org.apache.dubbo.config.annotation.Reference; import org.springframework.stereotype.Component; + +import javax.annotation.Resource; @Component public class SeataManagerTest { -// -// @Resource -// private LoginUserDao loginUserDao; -// -// @Reference(version = "1.0") -// private GoldCornGetSourceService goldCornGetSourceService; -// -// @GlobalTransactional(timeoutMills = 30000, name = "buwan-order", rollbackFor = Exception.class) -// public void addGetResource() throws Exception { -// System.out.println("寮�濮嬪叏灞�浜嬪姟锛孹ID = " + RootContext.getXID()); -// LoginUser loginUser = new LoginUser(); -// loginUser.setId("50134"); -// loginUser.setName("test3"); -// loginUserDao.updateSelective(loginUser); -// -// GoldCornGetSource get = new GoldCornGetSource(); -// get.setAppId(15L); -// get.setSourceCode("test1"); -// get.setSourceName("娴嬭瘯"); -// get.setGoldCorn(1); -// -// goldCornGetSourceService.addSource(get); -// throw new Exception("鎵嬪姩鎶ラ敊"); -// } + + @Resource + private LoginUserDao loginUserDao; + + @Reference(version = "1.0") + private GoldCornGetSourceService goldCornGetSourceService; + + @GlobalTransactional(timeoutMills = 30000, name = "buwan-order", rollbackFor = Exception.class) + public void addGetResource() throws Exception { +// loginUserDao.selectByPrimaryKeyForUpdate("50134"); + System.out.println("寮�濮嬪叏灞�浜嬪姟锛孹ID = " + RootContext.getXID()); + LoginUser loginUser = new LoginUser(); + loginUser.setId("50134"); + loginUser.setName("test9"); + loginUserDao.updateSelective(loginUser); + + GoldCornGetSource get = new GoldCornGetSource(); + get.setAppId(15L); + get.setSourceCode("test5"); + get.setSourceName("娴嬭瘯"); + get.setGoldCorn(1); + + goldCornGetSourceService.addSource(get); + throw new Exception("鎵嬪姩鎶ラ敊"); + } } -- Gitblit v1.8.0