diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/config/GatewayRoutersConfiguration.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/config/GatewayRoutersConfiguration.java index bc1e3c17..b28f0aca 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/config/GatewayRoutersConfiguration.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/config/GatewayRoutersConfiguration.java @@ -2,6 +2,7 @@ package org.jeecg.config; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.MediaType; @@ -19,11 +20,9 @@ import static org.springframework.web.reactive.function.server.ServerResponse.ok */ @Slf4j @Configuration +@RefreshScope public class GatewayRoutersConfiguration { - /** - * 路由配置方式:database,yml,nacos - */ - public static String DATA_TYPE; + public static final long DEFAULT_TIMEOUT = 30000; public static String SERVER_ADDR; public static String NAMESPACE; @@ -52,10 +51,6 @@ public class GatewayRoutersConfiguration { ROUTE_GROUP = routeGroup; } - @Value("${jeecg.route.config.data-type:#{null}}") - public void setDataType(String dataType) { - DATA_TYPE = dataType; - } @Value("${spring.cloud.nacos.config.username}") public void setUsername(String username) { diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/config/RouterDataType.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/config/RouterDataType.java index 9f18f00f..735a1e1b 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/config/RouterDataType.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/config/RouterDataType.java @@ -2,6 +2,8 @@ package org.jeecg.config; /** * nocos配置方式枚举 + * @author zyf + * @date: 2022/4/21 10:55 */ public enum RouterDataType { /** diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/fallback/sentinel/GatewaySentinelExceptionConfig.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/fallback/sentinel/GatewaySentinelExceptionConfig.java index a8905854..a4e8e132 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/fallback/sentinel/GatewaySentinelExceptionConfig.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/fallback/sentinel/GatewaySentinelExceptionConfig.java @@ -33,7 +33,7 @@ public class GatewaySentinelExceptionConfig { } else { msg = "未知限流降级"; } - HashMap map = new HashMap(); + HashMap map = new HashMap(5); map.put("code", HttpStatus.TOO_MANY_REQUESTS.toString()); map.put("message", msg); //自定义异常处理 diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/filter/GlobalAccessTokenFilter.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/filter/GlobalAccessTokenFilter.java index 88c8618a..f1191493 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/filter/GlobalAccessTokenFilter.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/filter/GlobalAccessTokenFilter.java @@ -30,22 +30,17 @@ public class GlobalAccessTokenFilter implements GlobalFilter, Ordered { @Override public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { - String url = exchange.getRequest().getURI().getPath(); -// log.info(" access url : "+ url); String scheme = exchange.getRequest().getURI().getScheme(); String host = exchange.getRequest().getURI().getHost(); int port = exchange.getRequest().getURI().getPort(); String basePath = scheme + "://" + host + ":" + port; -// log.info(" base path : "+ basePath); - // 1. 重写StripPrefix(获取真实的URL) addOriginalRequestUrl(exchange, exchange.getRequest().getURI()); String rawPath = exchange.getRequest().getURI().getRawPath(); String newPath = "/" + Arrays.stream(StringUtils.tokenizeToStringArray(rawPath, "/")).skip(1L).collect(Collectors.joining("/")); ServerHttpRequest newRequest = exchange.getRequest().mutate().path(newPath).build(); exchange.getAttributes().put(GATEWAY_REQUEST_URL_ATTR, newRequest.getURI()); - //2.将现在的request,添加当前身份 ServerHttpRequest mutableReq = exchange.getRequest().mutate().header("Authorization-UserName", "").header(X_GATEWAY_BASE_PATH,basePath).build(); ServerWebExchange mutableExchange = exchange.mutate().request(mutableReq).build(); diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/handler/LoderRouderHandler.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/handler/LoderRouderHandler.java index de11b9b9..dabe0278 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/handler/LoderRouderHandler.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/handler/LoderRouderHandler.java @@ -11,6 +11,8 @@ import javax.annotation.Resource; /** * 路由刷新监听(实现方式:redis监听handler) + * @author zyf + * @date: 2022/4/21 10:55 */ @Slf4j @Component(GlobalConstants.LODER_ROUDER_HANDLER) diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/handler/swagger/MySwaggerResourceProvider.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/handler/swagger/MySwaggerResourceProvider.java index 0252471e..6c52713b 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/handler/swagger/MySwaggerResourceProvider.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/handler/swagger/MySwaggerResourceProvider.java @@ -1,5 +1,6 @@ package org.jeecg.handler.swagger; +import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ObjectUtil; import com.alibaba.nacos.api.naming.NamingFactory; import com.alibaba.nacos.api.naming.NamingService; @@ -21,6 +22,8 @@ import java.util.Set; /** * 聚合各个服务的swagger接口 + * @author zyf + * @date: 2022/4/21 10:55 */ @Component @Slf4j @@ -42,6 +45,11 @@ public class MySwaggerResourceProvider implements SwaggerResourcesProvider { @Value("${spring.cloud.nacos.discovery.server-addr}") private String serverAddr; + /** + * Swagger中需要排除的服务 + */ + private String[] excludeServiceIds=new String[]{"jeecg-cloud-monitor"}; + /** * 网关应用名称 @@ -82,8 +90,8 @@ public class MySwaggerResourceProvider implements SwaggerResourcesProvider { swaggerResource.setUrl(url); swaggerResource.setSwaggerVersion("2.0"); swaggerResource.setName(instance); - //Swagger排除监控 - if(instance.indexOf("jeecg-cloud-monitor")==-1){ + //Swagger排除不展示的服务 + if(!ArrayUtil.contains(excludeServiceIds,instance)){ resources.add(swaggerResource); } } diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/handler/swagger/SwaggerResourceController.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/handler/swagger/SwaggerResourceController.java index 59f46466..41424fbe 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/handler/swagger/SwaggerResourceController.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/handler/swagger/SwaggerResourceController.java @@ -11,6 +11,8 @@ import java.util.List; /** * swagger聚合接口,三个接口都是 doc.html需要访问的接口 + * @author zyf + * @date: 2022/4/21 10:55 */ @RestController @RequestMapping("/swagger-resources") diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/loader/DynamicRouteLoader.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/loader/DynamicRouteLoader.java index 57358276..3f4e382a 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/loader/DynamicRouteLoader.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/loader/DynamicRouteLoader.java @@ -21,6 +21,8 @@ import org.jeecg.config.RouterDataType; import org.jeecg.loader.repository.DynamicRouteService; import org.jeecg.loader.repository.MyInMemoryRouteDefinitionRepository; import org.jeecg.loader.vo.MyRouteDefinition; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.gateway.event.RefreshRoutesEvent; import org.springframework.cloud.gateway.filter.FilterDefinition; import org.springframework.cloud.gateway.handler.predicate.PredicateDefinition; @@ -49,6 +51,7 @@ import java.util.concurrent.Executor; @Slf4j @Component @DependsOn({"gatewayRoutersConfiguration"}) +@RefreshScope public class DynamicRouteLoader implements ApplicationEventPublisherAware { @@ -57,6 +60,12 @@ public class DynamicRouteLoader implements ApplicationEventPublisherAware { private DynamicRouteService dynamicRouteService; private ConfigService configService; private RedisUtil redisUtil; + + /** + * 路由配置方式:database(数据库),yml(配置文件),nacos + */ + @Value("${jeecg.route.config.data-type:database}") + public String dataType; /** * 需要拼接key的路由条件 */ @@ -76,7 +85,6 @@ public class DynamicRouteLoader implements ApplicationEventPublisherAware { public void init(BaseMap baseMap) { - String dataType = GatewayRoutersConfiguration.DATA_TYPE; log.info("初始化路由,dataType:"+ dataType); if (RouterDataType.nacos.toString().endsWith(dataType)) { loadRoutesByNacos(); @@ -92,7 +100,6 @@ public class DynamicRouteLoader implements ApplicationEventPublisherAware { * @return */ public Mono refresh(BaseMap baseMap) { - String dataType = GatewayRoutersConfiguration.DATA_TYPE; if (!RouterDataType.yml.toString().endsWith(dataType)) { this.init(baseMap); } diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/loader/repository/DynamicRouteService.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/loader/repository/DynamicRouteService.java index 4e1f02ca..a0fe7fdb 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/loader/repository/DynamicRouteService.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/loader/repository/DynamicRouteService.java @@ -59,7 +59,6 @@ public class DynamicRouteService implements ApplicationEventPublisherAware { public synchronized String update(RouteDefinition definition) { try { log.info("gateway update route {}", definition); - //delete(definition.getId()); } catch (Exception e) { return "update fail,not find route routeId: " + definition.getId(); } diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/loader/vo/GatewayRouteVo.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/loader/vo/GatewayRouteVo.java index fe16d6fb..591c11a7 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/loader/vo/GatewayRouteVo.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/loader/vo/GatewayRouteVo.java @@ -2,6 +2,11 @@ package org.jeecg.loader.vo; import lombok.Data; +/** + * 路由参数模型 + * @author zyf + * @date: 2022/4/21 10:55 + */ @Data public class GatewayRouteVo { private String id; diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-monitor/src/main/java/org/jeecg/monitor/JeecgMonitorApplication.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-monitor/src/main/java/org/jeecg/monitor/JeecgMonitorApplication.java index 9d219852..ceeb033e 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-monitor/src/main/java/org/jeecg/monitor/JeecgMonitorApplication.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-monitor/src/main/java/org/jeecg/monitor/JeecgMonitorApplication.java @@ -6,6 +6,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; /** * 监控服务 + * @author zyf + * @date: 2022/4/21 10:55 */ @SpringBootApplication @EnableAdminServer diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/src/main/java/com/alibaba/nacos/JeecgNacosApplication.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/src/main/java/com/alibaba/nacos/JeecgNacosApplication.java index 7e819bc8..7d84b244 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/src/main/java/com/alibaba/nacos/JeecgNacosApplication.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/src/main/java/com/alibaba/nacos/JeecgNacosApplication.java @@ -8,8 +8,7 @@ import org.springframework.scheduling.annotation.EnableScheduling; /** * Nacos 启动类 - * 引用的nacos console 源码运行,简化开发 - * 生产建议从官网下载最新版配置运行 + * * @author zyf */ @SpringBootApplication(scanBasePackages = "com.alibaba.nacos") diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/JeecgSystemCloudApplication.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/JeecgSystemCloudApplication.java index d6b5ca31..c5e887d2 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/JeecgSystemCloudApplication.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/JeecgSystemCloudApplication.java @@ -22,6 +22,8 @@ import java.net.UnknownHostException; /** * 微服务启动类(采用此类启动项目为微服务模式) * 注意: 需要先在naocs里面创建配置文件,参考文档 http://doc.jeecg.com/2704725 + * @author zyf + * @date: 2022/4/21 10:55 */ @Slf4j @SpringBootApplication diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/constant/CloudConstant.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/constant/CloudConstant.java index 90095070..17f9f494 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/constant/CloudConstant.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/constant/CloudConstant.java @@ -2,6 +2,8 @@ package org.jeecg.modules.test.constant; /** * 微服务单元测试常量定义 + * @author: zyf + * @date: 2022/04/21 */ public interface CloudConstant { diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/feign/client/JeecgTestClient.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/feign/client/JeecgTestClient.java index 19bd6f7a..340a9518 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/feign/client/JeecgTestClient.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/feign/client/JeecgTestClient.java @@ -9,17 +9,22 @@ import org.jeecg.modules.test.feign.factory.JeecgTestClientFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.Mapping; -import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; /** * 常规feign接口定义 + * @author: zyf + * @date: 2022/04/21 */ @FeignClient(value = ServiceNameConstants.SERVICE_DEMO, configuration = FeignConfig.class,fallbackFactory = JeecgTestClientFactory.class) @Component public interface JeecgTestClient { + /** + * feign测试方法 + * @param name + * @return + */ @GetMapping(value = "/test/getMessage") String getMessage(@RequestParam(value = "name",required = false) String name); } diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/feign/controller/JeecgTestFeignController.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/feign/controller/JeecgTestFeignController.java index 2c963a83..794d1b00 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/feign/controller/JeecgTestFeignController.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/feign/controller/JeecgTestFeignController.java @@ -12,7 +12,11 @@ import com.alibaba.csp.sentinel.annotation.SentinelResource; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; - +/** + * 微服务单元测试 + * @author: zyf + * @date: 2022/04/21 + */ @Slf4j @RestController @RequestMapping("/sys/test") diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/lock/DemoLockTest.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/lock/DemoLockTest.java index 6b179034..d6c1eaa1 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/lock/DemoLockTest.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/lock/DemoLockTest.java @@ -14,6 +14,8 @@ import java.util.Map; /** * 分布式锁测试demo + * @author: zyf + * @date: 2022/04/21 */ @Slf4j @Component @@ -50,10 +52,11 @@ public class DemoLockTest { /** * 测试分布式锁【编码方式】 + * @Scheduled(cron = "0/5 * * * * ?") */ - //@Scheduled(cron = "0/5 * * * * ?") public void execute2() throws InterruptedException { - if (redissonLock.tryLock(CloudConstant.REDISSON_DEMO_LOCK_KEY2, -1, 6000)) { + int expireSeconds=6000; + if (redissonLock.tryLock(CloudConstant.REDISSON_DEMO_LOCK_KEY2, -1, expireSeconds)) { log.info("执行任务execute2开始,休眠十秒"); Thread.sleep(10000); log.info("=============业务逻辑2==================="); diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/xxljob/DemoJobHandler.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/xxljob/DemoJobHandler.java index 06a58b30..840a9022 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/xxljob/DemoJobHandler.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/xxljob/DemoJobHandler.java @@ -20,6 +20,8 @@ import java.util.Arrays; /** * xxl-job定时任务测试 + * @author: zyf + * @date: 2022/04/21 */ @Component @Slf4j @@ -113,7 +115,8 @@ public class DemoJobHandler { */ @XxlJob("httpJobHandler") public ReturnT httpJobHandler(String param) throws Exception { - + String[] methodArray=new String[]{"GET","POST"}; + int okState=200; // param parse if (param == null || param.trim().length() == 0) { log.info("param[" + param + "] invalid."); @@ -140,7 +143,7 @@ public class DemoJobHandler { log.info("url[" + url + "] invalid."); return ReturnT.FAIL; } - if (method == null || !Arrays.asList("GET", "POST").contains(method)) { + if (method == null || !Arrays.asList(methodArray).contains(method)) { log.info("method[" + method + "] invalid."); return ReturnT.FAIL; } @@ -177,7 +180,7 @@ public class DemoJobHandler { // valid StatusCode int statusCode = connection.getResponseCode(); - if (statusCode != 200) { + if (statusCode != okState) { throw new RuntimeException("Http Request StatusCode(" + statusCode + ") Invalid."); } diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/xxljob/XxclJobTest.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/xxljob/XxclJobTest.java index 222707a3..1e5a84a3 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/xxljob/XxclJobTest.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-more/src/main/java/org/jeecg/modules/test/xxljob/XxclJobTest.java @@ -6,9 +6,10 @@ import com.xxl.job.core.handler.annotation.XxlJob; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; - /** - * xxl-job定时任务测试 + * xxl-job定时任务测试 + * @author: zyf + * @date: 2022/04/21 */ @Component @Slf4j diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/constant/CloudConstant.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/constant/CloudConstant.java index 10e3e2ad..c29f497d 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/constant/CloudConstant.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/constant/CloudConstant.java @@ -2,6 +2,8 @@ package org.jeecg.modules.test.rabbitmq.constant; /** * 微服务单元测试常量定义 + * @author: zyf + * @date: 2022/04/21 */ public interface CloudConstant { diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/controller/JeecgMqTestController.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/controller/JeecgMqTestController.java index 6219c267..25c699fa 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/controller/JeecgMqTestController.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/controller/JeecgMqTestController.java @@ -19,6 +19,8 @@ import io.swagger.annotations.ApiOperation; /** * RabbitMqClient发送消息 + * @author: zyf + * @date: 2022/04/21 */ @RestController @RequestMapping("/sys/test") diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/event/DemoBusEvent.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/event/DemoBusEvent.java index 5042915d..ac2001ba 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/event/DemoBusEvent.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/event/DemoBusEvent.java @@ -11,6 +11,8 @@ import lombok.extern.slf4j.Slf4j; /** * 消息处理器【发布订阅】 + * @author: zyf + * @date: 2022/04/21 */ @Slf4j @Component(CloudConstant.MQ_DEMO_BUS_EVENT) diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/listener/HelloReceiver1.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/listener/HelloReceiver1.java index 8e474b57..77ff14ff 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/listener/HelloReceiver1.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/listener/HelloReceiver1.java @@ -21,6 +21,8 @@ import lombok.extern.slf4j.Slf4j; * * RabbitMq接受者1 * (@RabbitListener声明类上,一个类只能监听一个队列) + * @author: zyf + * @date: 2022/04/21 */ @Slf4j @RabbitListener(queues = CloudConstant.MQ_JEECG_PLACE_ORDER) diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/listener/HelloReceiver2.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/listener/HelloReceiver2.java index 7be88a28..e5601e34 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/listener/HelloReceiver2.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/listener/HelloReceiver2.java @@ -17,6 +17,8 @@ import org.springframework.messaging.handler.annotation.Header; * * RabbitMq接受者2 * (@RabbitListener声明类上,一个类只能监听一个队列) + * @author: zyf + * @date: 2022/04/21 */ @Slf4j @RabbitListener(queues = CloudConstant.MQ_JEECG_PLACE_ORDER) diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/listener/HelloReceiver3.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/listener/HelloReceiver3.java index 50a2118c..c70cb001 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/listener/HelloReceiver3.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/listener/HelloReceiver3.java @@ -16,6 +16,8 @@ import org.springframework.messaging.handler.annotation.Header; * * RabbitMq接受者3【我是处理人3】 * (@RabbitListener声明类方法上,一个类可以多监听多个队列) + * @author: zyf + * @date: 2022/04/21 */ @Slf4j @RabbitComponent(value = "helloReceiver3") diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/listener/HelloTimeReceiver.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/listener/HelloTimeReceiver.java index 73797081..2404a924 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/listener/HelloTimeReceiver.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-rabbitmq/src/main/java/org/jeecg/modules/test/rabbitmq/listener/HelloTimeReceiver.java @@ -14,6 +14,11 @@ import com.rabbitmq.client.Channel; import lombok.extern.slf4j.Slf4j; +/** + * 定义接收者(可以定义N个接受者,消息会均匀的发送到N个接收者中) + * @author: zyf + * @date: 2022/04/21 + */ @Slf4j @RabbitListener(queues = CloudConstant.MQ_JEECG_PLACE_ORDER_TIME) @RabbitComponent(value = "helloTimeReceiver") diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-account/src/main/java/org/jeecg/modules/test/seata/account/service/SeataAccountService.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-account/src/main/java/org/jeecg/modules/test/seata/account/service/SeataAccountService.java index 1cdd7e55..008b0b6c 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-account/src/main/java/org/jeecg/modules/test/seata/account/service/SeataAccountService.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-account/src/main/java/org/jeecg/modules/test/seata/account/service/SeataAccountService.java @@ -10,6 +10,7 @@ import java.math.BigDecimal; */ public interface SeataAccountService { /** + * 扣减金额 * @param userId 用户 ID * @param amount 扣减金额 */ diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-account/src/main/java/org/jeecg/modules/test/seata/account/service/impl/SeataAccountServiceImpl.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-account/src/main/java/org/jeecg/modules/test/seata/account/service/impl/SeataAccountServiceImpl.java index d87970a0..d9127fe2 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-account/src/main/java/org/jeecg/modules/test/seata/account/service/impl/SeataAccountServiceImpl.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-account/src/main/java/org/jeecg/modules/test/seata/account/service/impl/SeataAccountServiceImpl.java @@ -32,7 +32,7 @@ public class SeataAccountServiceImpl implements SeataAccountService { */ @DS("account") @Override - @Transactional(propagation = Propagation.REQUIRES_NEW) + @Transactional(propagation = Propagation.REQUIRES_NEW,rollbackFor = Exception.class) public void reduceBalance(Long userId, BigDecimal amount) { log.info("=============ACCOUNT START================="); SeataAccount account = accountMapper.selectById(userId); diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-order/src/main/java/org/jeecg/modules/test/seata/order/feign/ProductClient.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-order/src/main/java/org/jeecg/modules/test/seata/order/feign/ProductClient.java index 0acf8b42..ffc8d7ef 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-order/src/main/java/org/jeecg/modules/test/seata/order/feign/ProductClient.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-order/src/main/java/org/jeecg/modules/test/seata/order/feign/ProductClient.java @@ -6,6 +6,11 @@ import org.springframework.web.bind.annotation.RequestParam; import java.math.BigDecimal; +/** + * 分布式事务产品feign客户端 + * @author: zyf + * @date: 2022/04/21 + */ @FeignClient(value ="seata-product") public interface ProductClient { /** diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-order/src/main/java/org/jeecg/modules/test/seata/order/service/impl/SeataOrderServiceImpl.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-order/src/main/java/org/jeecg/modules/test/seata/order/service/impl/SeataOrderServiceImpl.java index 09bcb9d0..48676cd5 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-order/src/main/java/org/jeecg/modules/test/seata/order/service/impl/SeataOrderServiceImpl.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-order/src/main/java/org/jeecg/modules/test/seata/order/service/impl/SeataOrderServiceImpl.java @@ -36,7 +36,7 @@ public class SeataOrderServiceImpl implements SeataOrderService { @DS("order") @Override - @Transactional + @Transactional(rollbackFor = Exception.class) @GlobalTransactional public void placeOrder(PlaceOrderRequest request) { log.info("=============ORDER START================="); diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-product/src/main/java/org/jeecg/modules/test/seata/product/service/impl/SeataProductServiceImpl.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-product/src/main/java/org/jeecg/modules/test/seata/product/service/impl/SeataProductServiceImpl.java index e8ad3b81..f7b91f75 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-product/src/main/java/org/jeecg/modules/test/seata/product/service/impl/SeataProductServiceImpl.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-seata/jeecg-cloud-test-seata-product/src/main/java/org/jeecg/modules/test/seata/product/service/impl/SeataProductServiceImpl.java @@ -32,7 +32,7 @@ public class SeataProductServiceImpl implements SeataProductService { * 事务传播特性设置为 REQUIRES_NEW 开启新的事务 */ @DS("product") - @Transactional(propagation = Propagation.REQUIRES_NEW) + @Transactional(propagation = Propagation.REQUIRES_NEW,rollbackFor = Exception.class) @Override public BigDecimal reduceStock(Long productId, Integer count) { log.info("=============PRODUCT START================="); diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-shardingsphere/src/main/java/org/jeecg/modules/test/sharding/controller/JeecgShardingDemoController.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-shardingsphere/src/main/java/org/jeecg/modules/test/sharding/controller/JeecgShardingDemoController.java index d54f4c7f..5de357c9 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-shardingsphere/src/main/java/org/jeecg/modules/test/sharding/controller/JeecgShardingDemoController.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-shardingsphere/src/main/java/org/jeecg/modules/test/sharding/controller/JeecgShardingDemoController.java @@ -35,7 +35,8 @@ public class JeecgShardingDemoController extends JeecgController add() { - for (int i = 0; i < 10; i++) { + int size=10; + for (int i = 0; i < size; i++) { ShardingSysLog shardingSysLog = new ShardingSysLog(); shardingSysLog.setLogContent("jeecg"); shardingSysLog.setLogType(i); @@ -62,7 +63,9 @@ public class JeecgShardingDemoController extends JeecgController test2() { - for (int i = 20; i <= 30; i++) { + int start=20; + int size=30; + for (int i = start; i <= size; i++) { ShardingSysLog shardingSysLog = new ShardingSysLog(); shardingSysLog.setLogContent("双库分表测试"); shardingSysLog.setLogType(i); diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-shardingsphere/src/main/java/org/jeecg/modules/test/sharding/entity/ShardingSysLog.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-shardingsphere/src/main/java/org/jeecg/modules/test/sharding/entity/ShardingSysLog.java index 069120e3..c32cff2f 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-shardingsphere/src/main/java/org/jeecg/modules/test/sharding/entity/ShardingSysLog.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-shardingsphere/src/main/java/org/jeecg/modules/test/sharding/entity/ShardingSysLog.java @@ -14,9 +14,9 @@ import java.io.Serializable; import java.util.Date; /** - *

* 系统日志表 - *

+ * @author: zyf + * @date: 2022/04/21 */ @Data @TableName("sys_log") diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-shardingsphere/src/main/java/org/jeecg/modules/test/sharding/mapper/xml/ShardingSysLogMapper.xml b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-shardingsphere/src/main/java/org/jeecg/modules/test/sharding/mapper/xml/ShardingSysLogMapper.xml index 5baff85d..136d53a2 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-shardingsphere/src/main/java/org/jeecg/modules/test/sharding/mapper/xml/ShardingSysLogMapper.xml +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-shardingsphere/src/main/java/org/jeecg/modules/test/sharding/mapper/xml/ShardingSysLogMapper.xml @@ -1,5 +1,5 @@ - + diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-shardingsphere/src/main/java/org/jeecg/modules/test/sharding/service/impl/ShardingSysLogServiceImpl.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-shardingsphere/src/main/java/org/jeecg/modules/test/sharding/service/impl/ShardingSysLogServiceImpl.java index b063e88f..242a8a0f 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-shardingsphere/src/main/java/org/jeecg/modules/test/sharding/service/impl/ShardingSysLogServiceImpl.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-shardingsphere/src/main/java/org/jeecg/modules/test/sharding/service/impl/ShardingSysLogServiceImpl.java @@ -8,9 +8,9 @@ import org.jeecg.modules.test.sharding.service.IShardingSysLogService; import org.springframework.stereotype.Service; /** - *

* 系统日志表 服务实现类 - *

+ * @author: zyf + * @date: 2022/04/21 */ @Service @DS("sharding")