Commit d936f777 authored by jiaorz's avatar jiaorz

seata

parent f7319951
...@@ -63,22 +63,16 @@ ...@@ -63,22 +63,16 @@
<artifactId>mapper</artifactId> <artifactId>mapper</artifactId>
<version>4.1.5</version> <version>4.1.5</version>
</dependency> </dependency>
<!-- <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.0.4.RELEASE</version>
</dependency>-->
<dependency> <dependency>
<groupId>com.github.pagehelper</groupId> <groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId> <artifactId>pagehelper</artifactId>
<version>5.1.8</version> <version>5.1.8</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <dependency> <!-- <groupId>io.seata</groupId>-->
<groupId>org.springframework</groupId> <!-- <artifactId>seata-all</artifactId>-->
<artifactId>spring-web</artifactId> <!-- <version>0.8.0</version>-->
<version>5.0.4.RELEASE</version> <!-- </dependency>-->
</dependency>-->
<!-- fastjson.jar --> <!-- fastjson.jar -->
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
......
//package com.github.wxiaoqi.security.common.config.global;
//
//import io.seata.spring.annotation.GlobalTransactionScanner;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.boot.context.properties.EnableConfigurationProperties;
//import org.springframework.context.ApplicationContext;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.util.StringUtils;
//
//@Slf4j
//@Configuration
//@EnableConfigurationProperties({SeataProperties.class})
//public class GlobalTransactionAutoConfiguration {
// private final ApplicationContext applicationContext;
// private final SeataProperties seataProperties;
//
// public GlobalTransactionAutoConfiguration(ApplicationContext applicationContext, SeataProperties seataProperties) {
// this.applicationContext = applicationContext;
// this.seataProperties = seataProperties;
// }
//
// @Bean
// public GlobalTransactionScanner globalTransactionScanner() {
// String applicationName = this.applicationContext.getEnvironment().getProperty("spring.application.name");
// log.info("【初始化seata GlobalTransactionScanner】......{}", applicationName);
// String txServiceGroup = seataProperties.getTxServiceGroup();
// if (StringUtils.isEmpty(txServiceGroup)) {
// txServiceGroup = applicationName + "-fescar-service-group";
// this.seataProperties.setTxServiceGroup(txServiceGroup);
// }
//
// return new GlobalTransactionScanner(applicationName, txServiceGroup);
// }
//
//}
//package com.github.wxiaoqi.security.common.config.global;
//
//import org.springframework.boot.context.properties.ConfigurationProperties;
//
//@ConfigurationProperties("spring.cloud.alibaba.seata")
//public class SeataProperties {
// private String txServiceGroup;
//
// public SeataProperties() {
// }
//
// public String getTxServiceGroup() {
// return this.txServiceGroup;
// }
//
// public void setTxServiceGroup(String txServiceGroup) {
// this.txServiceGroup = txServiceGroup;
// }
//}
//package com.github.wxiaoqi.security.common.config.global;
//
//import com.github.wxiaoqi.security.common.interceptor.SeataRestTemplateInterceptor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.http.client.ClientHttpRequestInterceptor;
//import org.springframework.web.client.RestTemplate;
//
//import javax.annotation.PostConstruct;
//import java.util.ArrayList;
//import java.util.Collection;
//import java.util.Iterator;
//import java.util.List;
//
//@Slf4j
//@Configuration
//public class SeataRestTemplateAutoConfiguration {
// @Autowired(
// required = false
// )
// private Collection<RestTemplate> restTemplates;
// @Autowired
// private SeataRestTemplateInterceptor seataRestTemplateInterceptor;
//
// public SeataRestTemplateAutoConfiguration() {
// }
//
// @Bean
// public SeataRestTemplateInterceptor seataRestTemplateInterceptor() {
// return new SeataRestTemplateInterceptor();
// }
//
// @PostConstruct
// public void init() {
// log.info("【初始化seata SeataRestTemplateInterceptor】......");
// if (this.restTemplates != null) {
// Iterator var1 = this.restTemplates.iterator();
//
// while (var1.hasNext()) {
// RestTemplate restTemplate = (RestTemplate) var1.next();
// List<ClientHttpRequestInterceptor> interceptors = new ArrayList(restTemplate.getInterceptors());
// interceptors.add(this.seataRestTemplateInterceptor);
// restTemplate.setInterceptors(interceptors);
// }
// }
//
// }
//}
\ No newline at end of file
//package com.github.wxiaoqi.security.common.filter;
//
//import io.seata.core.context.RootContext;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang.StringUtils;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.Filter;
//import javax.servlet.FilterChain;
//import javax.servlet.FilterConfig;
//import javax.servlet.ServletException;
//import javax.servlet.ServletRequest;
//import javax.servlet.ServletResponse;
//import javax.servlet.http.HttpServletRequest;
//import java.io.IOException;
//
//@Slf4j
//@Component
//public class SeataFilter implements Filter {
// @Override
// public void init(FilterConfig filterConfig) throws ServletException {
// }
//
// @Override
// public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
// log.info("【初始化SEATA过滤器】......");
// HttpServletRequest req = (HttpServletRequest) servletRequest;
// String xid = req.getHeader(RootContext.KEY_XID.toLowerCase());
// boolean isBind = false;
// if (StringUtils.isNotBlank(xid)) {
// RootContext.bind(xid);
// isBind = true;
// }
// try {
// filterChain.doFilter(servletRequest, servletResponse);
// } finally {
// if (isBind) {
// RootContext.unbind();
// }
// }
// }
//
// @Override
// public void destroy() {
// }
//}
\ No newline at end of file
//package com.github.wxiaoqi.security.common.interceptor;
//
//import io.seata.core.context.RootContext;
//import org.apache.commons.lang.StringUtils;
//import org.springframework.http.HttpRequest;
//import org.springframework.http.client.ClientHttpRequestExecution;
//import org.springframework.http.client.ClientHttpRequestInterceptor;
//import org.springframework.http.client.ClientHttpResponse;
//import org.springframework.http.client.support.HttpRequestWrapper;
//
//import java.io.IOException;
//
//public class SeataRestTemplateInterceptor implements ClientHttpRequestInterceptor {
// public SeataRestTemplateInterceptor() {
// }
//
// public ClientHttpResponse intercept(HttpRequest httpRequest, byte[] bytes, ClientHttpRequestExecution clientHttpRequestExecution) throws IOException {
// HttpRequestWrapper requestWrapper = new HttpRequestWrapper(httpRequest);
// String xid = RootContext.getXID();
// if (StringUtils.isNotEmpty(xid)) {
// requestWrapper.getHeaders().add(RootContext.KEY_XID, xid);
// }
//
// return clientHttpRequestExecution.execute(requestWrapper, bytes);
// }
//}
...@@ -5,7 +5,7 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; ...@@ -5,7 +5,7 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.activity.dto.ActivityListDTO; import com.xxfc.platform.activity.dto.ActivityListDTO;
import com.xxfc.platform.activity.dto.ActivityPopularizeRelationDTO; import com.xxfc.platform.activity.dto.ActivityPopularizeRelationDTO;
import com.xxfc.platform.activity.entity.Coupon; import com.xxfc.platform.activity.entity.Coupon;
import com.xxfc.platform.activity.entity.IntegralUserTotal; import com.xxfc.platform.activity.entity.IntegralRule;
import com.xxfc.platform.activity.vo.UserCouponVo; import com.xxfc.platform.activity.vo.UserCouponVo;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -13,7 +13,6 @@ import org.springframework.cloud.openfeign.FeignClient; ...@@ -13,7 +13,6 @@ import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -86,4 +85,8 @@ public interface ActivityFeign { ...@@ -86,4 +85,8 @@ public interface ActivityFeign {
@ApiOperation("获取所用优惠卷") @ApiOperation("获取所用优惠卷")
@GetMapping("/coupon/couponsBycouponIds") @GetMapping("/coupon/couponsBycouponIds")
List<Coupon> couponsByTickerNoList(@RequestParam(value = "tickerNoList") List<String> tickerNoList); List<Coupon> couponsByTickerNoList(@RequestParam(value = "tickerNoList") List<String> tickerNoList);
@PostMapping(value = "/integralRule/add")
@ApiOperation(value = "添加积分规则")
public ObjectRestResponse add(@RequestBody IntegralRule integralRule);
} }
...@@ -23,6 +23,16 @@ ...@@ -23,6 +23,16 @@
<version>2.0-SNAPSHOT</version> <version>2.0-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-all</artifactId>
<version>0.9.0</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-seata</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -4,4 +4,8 @@ logging: ...@@ -4,4 +4,8 @@ logging:
com.github.wxiaoqi: com.github.wxiaoqi:
debug debug
com.xxfc.platform: com.xxfc.platform:
debug debug
\ No newline at end of file io.seata:
info
com.xxfc.platform.activity.mapper:
debug
transport {
# tcp udt unix-domain-socket
type = "TCP"
#NIO NATIVE
server = "NIO"
#enable heartbeat
heartbeat = true
#thread factory for netty
thread-factory {
boss-thread-prefix = "NettyBoss"
worker-thread-prefix = "NettyServerNIOWorker"
server-executor-thread-prefix = "NettyServerBizHandler"
share-boss-worker = false
client-selector-thread-prefix = "NettyClientSelector"
client-selector-thread-size = 1
client-worker-thread-prefix = "NettyClientWorkerThread"
# netty boss thread size,will not be used for UDT
boss-thread-size = 1
#auto default pin or 8
worker-thread-size = 8
}
shutdown {
# when destroy server, wait seconds
wait = 3
}
serialization = "seata"
compressor = "none"
}
service {
#vgroup->rgroup
vgroup_mapping.activity_tx_group = "default"
#only support single node
default.grouplist = "127.0.0.1:8091"
#degrade current not support
enableDegrade = false
#disable
disable = false
#unit ms,s,m,h,d represents milliseconds, seconds, minutes, hours, days, default permanent
max.commit.retry.timeout = "-1"
max.rollback.retry.timeout = "-1"
disableGlobalTransaction = false
}
client {
async.commit.buffer.limit = 10000
lock {
retry.internal = 10
retry.times = 30
}
report.retry.count = 5
tm.commit.retry.count = 1
tm.rollback.retry.count = 1
}
transaction {
undo.data.validation = true
undo.log.serialization = "jackson"
undo.log.save.days = 7
#schedule delete expired undo_log in milliseconds
undo.log.delete.period = 86400000
undo.log.table = "undo_log"
}
support {
## spring
spring {
# auto proxy the DataSource bean
datasource.autoproxy = false
}
}
\ No newline at end of file
registry {
# file 、nacos 、eureka、redis、zk
type = "file"
nacos {
serverAddr = "localhost"
namespace = ""
cluster = "default"
}
eureka {
serviceUrl = "http://localhost:1001/eureka"
application = "default"
weight = "1"
}
redis {
serverAddr = "localhost:6381"
db = "0"
}
zk {
cluster = "default"
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
file {
name = "file.conf"
}
}
config {
# file、nacos 、apollo、zk
type = "file"
nacos {
serverAddr = "localhost"
namespace = ""
cluster = "default"
}
apollo {
app.id = "fescar-server"
apollo.meta = "http://192.168.1.204:8801"
}
zk {
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
file {
name = "file.conf"
}
}
\ No newline at end of file
...@@ -43,7 +43,16 @@ ...@@ -43,7 +43,16 @@
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-seata</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-all</artifactId>
<version>0.9.0</version>
</dependency>
<!-- excel 组件 --> <!-- excel 组件 -->
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
......
...@@ -34,6 +34,21 @@ ...@@ -34,6 +34,21 @@
<artifactId>xx-order-api</artifactId> <artifactId>xx-order-api</artifactId>
<version>2.0-SNAPSHOT</version> <version>2.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>com.xxfc.platform</groupId>
<artifactId>xx-activity-api</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-all</artifactId>
<version>0.9.0</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-seata</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package com.xxfc.platform.vehicle.biz;
import com.xxfc.platform.activity.entity.IntegralRule;
import com.xxfc.platform.activity.feign.ActivityFeign;
import com.xxfc.platform.vehicle.entity.Vehicle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class TestBiz {
@Autowired
ActivityFeign activityFeign;
@Autowired
VehicleBiz vehicleBiz;
public void test() {
activityFeign.add(new IntegralRule(){{
setIsdel(false);
setIntegralStatus(false);
setBtnWord("已完成");
setCode("ACDDF");
setRegulation("hdusiahfi");
setDetail("fjdksfjsapgpd'sg");
setCrtTime(System.currentTimeMillis());
setFinishDay(5);
setFinishPoint(20);
setName("fgdg");
setIsContinuity(true);
setNumber(10);
setPeriod(1);
setPoint(20);
}
});
vehicleBiz.updateSelectiveById(new Vehicle(){{
setId("001b4809-998e-4545-a272-9caf14944437");
setNumberPlate("测试789102");
}});
}
}
package com.xxfc.platform.vehicle.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.vehicle.biz.TestBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "/test")
public class TestController {
@Autowired
TestBiz testBiz;
@GetMapping(value = "/app/unauth/hello")
public ObjectRestResponse test() {
testBiz.test();
return ObjectRestResponse.succ();
}
}
transport {
# tcp udt unix-domain-socket
type = "TCP"
#NIO NATIVE
server = "NIO"
#enable heartbeat
heartbeat = true
#thread factory for netty
thread-factory {
boss-thread-prefix = "NettyBoss"
worker-thread-prefix = "NettyServerNIOWorker"
server-executor-thread-prefix = "NettyServerBizHandler"
share-boss-worker = false
client-selector-thread-prefix = "NettyClientSelector"
client-selector-thread-size = 1
client-worker-thread-prefix = "NettyClientWorkerThread"
# netty boss thread size,will not be used for UDT
boss-thread-size = 1
#auto default pin or 8
worker-thread-size = 8
}
shutdown {
# when destroy server, wait seconds
wait = 3
}
serialization = "seata"
compressor = "none"
}
service {
#vgroup->rgroup
vgroup_mapping.vehicle_tx_group = "default"
#only support single node
default.grouplist = "127.0.0.1:8091"
#degrade current not support
enableDegrade = false
#disable
disable = false
#unit ms,s,m,h,d represents milliseconds, seconds, minutes, hours, days, default permanent
max.commit.retry.timeout = "-1"
max.rollback.retry.timeout = "-1"
disableGlobalTransaction = false
}
client {
async.commit.buffer.limit = 10000
lock {
retry.internal = 10
retry.times = 30
}
report.retry.count = 5
tm.commit.retry.count = 1
tm.rollback.retry.count = 1
}
transaction {
undo.data.validation = true
undo.log.serialization = "jackson"
undo.log.save.days = 7
#schedule delete expired undo_log in milliseconds
undo.log.delete.period = 86400000
undo.log.table = "undo_log"
}
support {
## spring
spring {
# auto proxy the DataSource bean
datasource.autoproxy = false
}
}
\ No newline at end of file
registry {
# file 、nacos 、eureka、redis、zk
type = "file"
nacos {
serverAddr = "localhost"
namespace = ""
cluster = "default"
}
eureka {
serviceUrl = "http://localhost:1001/eureka"
application = "default"
weight = "1"
}
redis {
serverAddr = "localhost:6381"
db = "0"
}
zk {
cluster = "default"
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
file {
name = "file.conf"
}
}
config {
# file、nacos 、apollo、zk
type = "file"
nacos {
serverAddr = "localhost"
namespace = ""
cluster = "default"
}
apollo {
app.id = "fescar-server"
apollo.meta = "http://192.168.1.204:8801"
}
zk {
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
file {
name = "file.conf"
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment