From ad0e5be5ac6b1f9457f9efbfd0570755bc54c078 Mon Sep 17 00:00:00 2001 From: dengtao <981376577@qq.com> Date: Tue, 20 Aug 2024 17:44:58 +0800 Subject: [PATCH] xx --- build.gradle | 81 +------------------ .../cloud/ddd/api/dubbo/DictRpcService.java | 34 ++++++-- .../taotao/cloud/ddd/api/feign/DictApi.java | 26 +++--- .../taotao/cloud/ddd/api/feign/FileApi.java | 47 +++++------ .../cloud/ddd/api/feign/LogisticsApi.java | 2 +- .../taotao/cloud/ddd/api/feign/MenuApi.java | 2 +- .../cloud/ddd/api/feign/QuartzJobApi.java | 5 +- .../taotao/cloud/ddd/api/feign/RoleApi.java | 2 +- .../cloud/ddd/api/feign/SettingApi.java | 2 +- .../taotao/cloud/ddd/api/feign/SysLogApi.java | 2 +- .../cloud/ddd/api/feign/SysLogLoginApi.java | 2 +- .../taotao/cloud/ddd/api/feign/UserApi.java | 29 ++++--- .../main/resources/META-INF/spring.factories | 11 +++ ...ot.autoconfigure.AutoConfiguration.imports | 4 +- ...ot.autoconfigure.AutoConfiguration.imports | 0 taotao-cloud-ddd-assembly/build.gradle | 79 ++++++++++++++++++ .../cloud/ddd/TaoTaoCloudDDDApplication.java | 7 +- .../src/main/resources/application-dev.yml | 61 +++++++------- ...ot.autoconfigure.AutoConfiguration.imports | 0 .../controller/buy/BuyerDictController.java | 9 +++ .../ddd/facade/grpc/DictGrpcServiceImpl.java | 18 +++++ ...ot.autoconfigure.AutoConfiguration.imports | 0 ...ot.autoconfigure.AutoConfiguration.imports | 0 .../goods/proxy/GoodsClientProxy.java | 7 +- .../integration/sku/proxy/SkuClientProxy.java | 8 +- ...ot.autoconfigure.AutoConfiguration.imports | 0 26 files changed, 255 insertions(+), 183 deletions(-) create mode 100644 taotao-cloud-ddd-application/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 taotao-cloud-ddd-domain/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 taotao-cloud-ddd-facade/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 taotao-cloud-ddd-infrastructure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 taotao-cloud-ddd-integration/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports diff --git a/build.gradle b/build.gradle index fb5c2f5..d2519b6 100644 --- a/build.gradle +++ b/build.gradle @@ -151,7 +151,7 @@ plugins { //smart-doc gradle 插件 // https://plugins.gradle.org/plugin/com.ly.smart-doc - id "com.ly.smart-doc" version "3.0.6" + id "com.ly.smart-doc" version "3.0.7-release" //OWASP 依赖检查插件。 //https://plugins.gradle.org/plugin/org.owasp.dependencycheck @@ -323,23 +323,6 @@ allprojects { } -import org.apache.tools.ant.filters.ReplaceTokens - - -def getProperty(String key, String defaultValue) { - def keyValue = findProperty(key) ?: System.getenv(key) - if (keyValue != null) { - return keyValue; - } - // 加载根路径自定义配置属性 - Properties envProps = new Properties() - envProps.load(new FileInputStream("${rootProject.projectDir.absolutePath}${File.separator}release.properties")) - - keyValue = envProps.getProperty(key, defaultValue) - println("打包profile环境==============" + keyValue) - return keyValue -} - subprojects { apply plugin: 'java' apply plugin: 'java-library' @@ -430,69 +413,7 @@ subprojects { jvmArgs += enablePreview } - //多项目分环境打包 - //gradle构建过程中的默认任务processResources,重写 - //gradle build -x test -Pprofile=dev - //gradle -x test clean bootJar -Pprofile=dev - processResources { - doFirst { - //过滤器会将用 @var@ 包裹的变量,替换为指定的值。 - filter ReplaceTokens, tokens: [activeProfile: getProperty("profile", "dev")] - - - //${profile}变量 - //filesMatching("**/*.yml"){ - // expand(project.properties) - //} - - //inputs.property('version', version) - - //filesMatching("**/version.properties") { - // expand version: version - //} - } - } - tasks.register('createProperties') { - dependsOn processResources - doLast { - def fileDir = new File("${project.layout.buildDirectory.asFile.get()}/resources/main"); - if (fileDir.exists() && fileDir.isDirectory()) { - def pro = ["application.properties", "bootstrap.properties"] - pro.forEach(item -> { - new File("${project.layout.buildDirectory.asFile.get()}/resources/main/$item").withWriter { w -> - def projectProperties = project.properties - Properties p = new Properties() - projectProperties.each { entry -> - p[entry.key.toString()] = entry.value.toString() - } - - p.store w, null - } - }) - } - } - } - - classes { - dependsOn 'createProperties' - } - - task bootJarTest { - dependsOn 'clean' - doFirst { - System.setProperty("profile", "test") - } - finalizedBy("bootJar") - } - - task bootJarProduction { - dependsOn 'clean' - doFirst { - System.setProperty("profile", "prod") - } - finalizedBy("bootJar") - } } diff --git a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/dubbo/DictRpcService.java b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/dubbo/DictRpcService.java index 1f9cb71..93a7f04 100644 --- a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/dubbo/DictRpcService.java +++ b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/dubbo/DictRpcService.java @@ -16,6 +16,13 @@ package com.taotao.cloud.ddd.api.dubbo; +import static com.taotao.cloud.common.support.info.ApiVersionEnum.V2022_07; +import static com.taotao.cloud.common.support.info.ApiVersionEnum.V2022_08; + +import com.taotao.cloud.common.support.info.Caller; +import com.taotao.cloud.common.support.info.Create; +import com.taotao.cloud.common.support.info.RpcInfo; +import com.taotao.cloud.common.support.info.Update; import com.taotao.cloud.ddd.api.dubbo.response.DictRpcResponse; /** @@ -27,12 +34,23 @@ */ public interface DictRpcService { - /** - * 字典code查询 - * - * @param code 代码 - * @return {@link DictRpcResponse } - * @since 2022-06-29 21:45:44 - */ - DictRpcResponse findByCode(Integer code); + /** + * 字典code查询 + * + * @param code 代码 + * @return {@link DictRpcResponse } + * @since 2022-06-29 21:45:44 + */ + @RpcInfo( + create = @Create(version = V2022_07, date = "2022-07-01 17:11:55"), + update = { + @Update(version = V2022_07, content = "主要修改了配置信息的接口查询", date = "2022-07-01 17:11:55"), + @Update(version = V2022_08, content = "主要修改了配置信息的接口查询08", date = "2022-07-08 15:12:55") + }, + caller = { + @Caller(contacts = "张三", desc = "支付系统", sys = "支付系统", use = "调用字典查询获取详情"), + @Caller(contacts = "李四", desc = "后台管理-字典管理-添加页面", sys = "后台管理", use = "查询字典") + } + ) + DictRpcResponse findByCode(Integer code); } diff --git a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/DictApi.java b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/DictApi.java index d8d3bc8..68eb12c 100644 --- a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/DictApi.java +++ b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/DictApi.java @@ -16,21 +16,22 @@ package com.taotao.cloud.ddd.api.feign; +import static com.taotao.cloud.common.support.info.ApiVersionEnum.V2022_07; +import static com.taotao.cloud.common.support.info.ApiVersionEnum.V2022_08; + import com.taotao.cloud.common.constant.ServiceName; -import com.taotao.cloud.openfeign.annotation.ApiInfo; -import com.taotao.cloud.openfeign.annotation.ApiInfo.Create; -import com.taotao.cloud.openfeign.annotation.ApiInfo.Update; -import com.taotao.cloud.openfeign.annotation.FeignInner; -import com.taotao.cloud.openfeign.annotation.FeignRetry; +import com.taotao.cloud.common.support.info.ApiInfo; +import com.taotao.cloud.common.support.info.Caller; +import com.taotao.cloud.common.support.info.Create; +import com.taotao.cloud.common.support.info.Update; import com.taotao.cloud.ddd.api.feign.fallback.DictApiFallback; import com.taotao.cloud.ddd.api.feign.response.DictApiResponse; +import com.taotao.cloud.openfeign.annotation.FeignInner; +import com.taotao.cloud.openfeign.annotation.FeignRetry; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; -import static com.taotao.cloud.openfeign.annotation.ApiVersionEnum.V2022_07; -import static com.taotao.cloud.openfeign.annotation.ApiVersionEnum.V2022_08; - /** * 远程调用后台用户模块 @@ -39,6 +40,7 @@ * @since 2020/5/2 16:42 */ @FeignClient( + contextId = "DictApi", name = ServiceName.TAOTAO_CLOUD_SYS, fallbackFactory = DictApiFallback.class) public interface DictApi { @@ -54,9 +56,13 @@ public interface DictApi { create = @Create(version = V2022_07, date = "2022-07-01 17:11:55"), update = { @Update(version = V2022_07, content = "主要修改了配置信息的接口查询", date = "2022-07-01 17:11:55"), - @Update(version = V2022_08, content = "主要修改了配置信息的接口查询08", date = "2022-07-01 17:11:55") + @Update(version = V2022_08, content = "主要修改了配置信息的接口查询08", date = "2022-07-08 15:12:55") + }, + caller = { + @Caller(contacts = "张三", desc = "支付系统", sys = "支付系统", use = "调用字典查询获取详情"), + @Caller(contacts = "李四", desc = "后台管理-字典管理-添加页面", sys = "后台管理", use = "查询字典") }) - @FeignRetry(maxAttempt= 6, backoff = @FeignRetry.Backoff(delay = 500L, maxDelay = 20000L, multiplier = 4)) + @FeignRetry(maxAttempt = 6, backoff = @FeignRetry.Backoff(delay = 500L, maxDelay = 20000L, multiplier = 4)) @FeignInner @GetMapping("/sys/feign/dict/code") DictApiResponse findByCode(@RequestParam(value = "code") String code); diff --git a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/FileApi.java b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/FileApi.java index 4f61a5d..ba73075 100644 --- a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/FileApi.java +++ b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/FileApi.java @@ -17,13 +17,13 @@ package com.taotao.cloud.ddd.api.feign; -import static com.taotao.cloud.openfeign.annotation.ApiVersionEnum.V2022_07; -import static com.taotao.cloud.openfeign.annotation.ApiVersionEnum.V2022_08; +import static com.taotao.cloud.common.support.info.ApiVersionEnum.V2022_07; +import static com.taotao.cloud.common.support.info.ApiVersionEnum.V2022_08; import com.taotao.cloud.common.constant.ServiceName; -import com.taotao.cloud.openfeign.annotation.ApiInfo; -import com.taotao.cloud.openfeign.annotation.ApiInfo.Create; -import com.taotao.cloud.openfeign.annotation.ApiInfo.Update; +import com.taotao.cloud.common.support.info.ApiInfo; +import com.taotao.cloud.common.support.info.Create; +import com.taotao.cloud.common.support.info.Update; import com.taotao.cloud.ddd.api.feign.fallback.FileApiFallback; import com.taotao.cloud.ddd.api.feign.response.FileApiResponse; import org.springframework.cloud.openfeign.FeignClient; @@ -37,24 +37,25 @@ * @since 2020/5/2 16:42 */ @FeignClient( - name = ServiceName.TAOTAO_CLOUD_FILE, - contextId = "feignDictApi", - fallbackFactory = FileApiFallback.class) + name = ServiceName.TAOTAO_CLOUD_FILE, + contextId = "FileApi", + fallbackFactory = FileApiFallback.class) public interface FileApi { - /** - * 字典列表code查询 - * - * @param code 代码 - * @return {@link FileApiResponse } - * @since 2022-06-29 21:40:21 - */ - @ApiInfo( - create = @Create(version = V2022_07, date = "2022-07-01 17:11:55"), - update = { - @Update(version = V2022_07, content = "主要修改了配置信息的接口查询", date = "2022-07-01 17:11:55"), - @Update(version = V2022_08, content = "主要修改了配置信息的接口查询08", date = "2022-07-01 17:11:55") - }) - @GetMapping("/file/feign/file/code") - FileApiResponse findByCode(@RequestParam(value = "code") String code); + /** + * 字典列表code查询 + * + * @param code 代码 + * @return {@link FileApiResponse } + * @since 2022-06-29 21:40:21 + */ + @ApiInfo( + create = @Create(version = V2022_07, date = "2022-07-01 17:11:55"), + update = { + @Update(version = V2022_07, content = "主要修改了配置信息的接口查询", date = "2022-07-01 17:11:55"), + @Update(version = V2022_08, content = "主要修改了配置信息的接口查询08", date = "2022-07-01 17:11:55") + } + ) + @GetMapping("/file/feign/file/code") + FileApiResponse findByCode(@RequestParam(value = "code") String code); } diff --git a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/LogisticsApi.java b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/LogisticsApi.java index 8422ac5..f5cc85b 100644 --- a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/LogisticsApi.java +++ b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/LogisticsApi.java @@ -35,7 +35,7 @@ */ @FeignClient( name = ServiceName.TAOTAO_CLOUD_SYS, - contextId = "IFeignLogisticsApi", + contextId = "LogisticsApi", fallbackFactory = LogisticsApiFallback.class) public interface LogisticsApi { diff --git a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/MenuApi.java b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/MenuApi.java index 9cdb840..2b5c648 100644 --- a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/MenuApi.java +++ b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/MenuApi.java @@ -34,7 +34,7 @@ */ @FeignClient( name = ServiceName.TAOTAO_CLOUD_SYS, - contextId = "IFeignMenuApi", + contextId = "MenuApi", fallbackFactory = MenuApiFallback.class) public interface MenuApi { diff --git a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/QuartzJobApi.java b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/QuartzJobApi.java index 4808e50..f0a24b4 100644 --- a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/QuartzJobApi.java +++ b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/QuartzJobApi.java @@ -30,7 +30,10 @@ * @author shuigedeng * @since 2020/5/2 16:42 */ -@FeignClient(value = ServiceName.TAOTAO_CLOUD_JOB, fallbackFactory = QuartzJobApiFallback.class) +@FeignClient( + contextId = "QuartzJobApi", + value = ServiceName.TAOTAO_CLOUD_JOB, + fallbackFactory = QuartzJobApiFallback.class) public interface QuartzJobApi { @PostMapping("/job/addQuartzJobDTOTestSeata") diff --git a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/RoleApi.java b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/RoleApi.java index 8b83020..84fd9c1 100644 --- a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/RoleApi.java +++ b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/RoleApi.java @@ -33,7 +33,7 @@ */ @FeignClient( name = ServiceName.TAOTAO_CLOUD_SYS, - contextId = "IFeignRoleApi", + contextId = "RoleApi", fallbackFactory = RoleApiFallback.class) public interface RoleApi { diff --git a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/SettingApi.java b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/SettingApi.java index d6ea7ba..842c0a1 100644 --- a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/SettingApi.java +++ b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/SettingApi.java @@ -43,7 +43,7 @@ */ @FeignClient( name = ServiceName.TAOTAO_CLOUD_SYS, - contextId = "IFeignSettingApi", + contextId = "SettingApi", fallbackFactory = SettingApiFallback.class) public interface SettingApi { diff --git a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/SysLogApi.java b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/SysLogApi.java index 8fad15a..0b70b46 100644 --- a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/SysLogApi.java +++ b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/SysLogApi.java @@ -26,7 +26,7 @@ @FeignClient( name = ServiceName.TAOTAO_CLOUD_LOG, - contextId = "feignDictApi", + contextId = "SysLogApi", fallbackFactory = SysLogApiFallback.class) public interface SysLogApi { diff --git a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/SysLogLoginApi.java b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/SysLogLoginApi.java index ede07ed..b11e3b0 100644 --- a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/SysLogLoginApi.java +++ b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/SysLogLoginApi.java @@ -26,7 +26,7 @@ @FeignClient( name = ServiceName.TAOTAO_CLOUD_LOG, - contextId = "feignDictApi", + contextId = "SysLogLoginApi", fallbackFactory = SysLogLoginApiFallback.class) public interface SysLogLoginApi { diff --git a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/UserApi.java b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/UserApi.java index 14e3879..1cab2c2 100644 --- a/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/UserApi.java +++ b/taotao-cloud-ddd-api/src/main/java/com/taotao/cloud/ddd/api/feign/UserApi.java @@ -17,20 +17,20 @@ package com.taotao.cloud.ddd.api.feign; +import static com.taotao.cloud.common.support.info.ApiVersionEnum.V2022_07; +import static com.taotao.cloud.common.support.info.ApiVersionEnum.V2022_08; + import com.taotao.cloud.common.constant.ServiceName; import com.taotao.cloud.common.model.BaseSecurityUser; -import com.taotao.cloud.openfeign.annotation.ApiInfo; -import com.taotao.cloud.openfeign.annotation.ApiInfo.Create; -import com.taotao.cloud.openfeign.annotation.ApiInfo.Update; +import com.taotao.cloud.common.support.info.ApiInfo; +import com.taotao.cloud.common.support.info.Create; +import com.taotao.cloud.common.support.info.Update; import com.taotao.cloud.ddd.api.feign.fallback.UserApiFallback; import com.taotao.cloud.ddd.api.feign.response.UserQueryApiResponse; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; -import static com.taotao.cloud.openfeign.annotation.ApiVersionEnum.V2022_07; -import static com.taotao.cloud.openfeign.annotation.ApiVersionEnum.V2022_08; - /** * 远程调用后台用户模块 * @@ -39,7 +39,7 @@ */ @FeignClient( name = ServiceName.TAOTAO_CLOUD_SYS, - contextId = "IFeignUserApi", + contextId = "UserApi", fallbackFactory = UserApiFallback.class) public interface UserApi { @@ -55,7 +55,8 @@ public interface UserApi { update = { @Update(version = V2022_07, content = "主要修改了配置信息的接口查询", date = "2022-07-01 17:11:55"), @Update(version = V2022_08, content = "主要修改了配置信息的接口查询08", date = "2022-07-01 17:11:55") - }) + } + ) @GetMapping(value = "/sys/feign/user/info/username") UserQueryApiResponse findUserInfoByUsername(@RequestParam(value = "username") String username); @@ -72,12 +73,15 @@ public interface UserApi { update = { @Update(version = V2022_07, content = "主要修改了配置信息的接口查询", date = "2022-07-01 17:11:55"), @Update(version = V2022_08, content = "主要修改了配置信息的接口查询08", date = "2022-07-01 17:11:55") - }) + } + ) @GetMapping( value = "/sys/feign/user/info/social/{social}", - headers = {"from=in"}) + headers = {"from=in"} + ) BaseSecurityUser getUserInfoBySocial( - @RequestParam("providerId") String providerId, @RequestParam("providerUserId") int providerUserId); + @RequestParam("providerId") String providerId, + @RequestParam("providerUserId") int providerUserId); /** * 通过用户名查询用户包括角色权限等 @@ -91,7 +95,8 @@ BaseSecurityUser getUserInfoBySocial( update = { @Update(version = V2022_07, content = "主要修改了配置信息的接口查询", date = "2022-07-01 17:11:55"), @Update(version = V2022_08, content = "主要修改了配置信息的接口查询08", date = "2022-07-01 17:11:55") - }) + } + ) @GetMapping(value = "/sys/feign/info/security") BaseSecurityUser getSysSecurityUser(String nicknameOrUserNameOrPhoneOrEmail); } diff --git a/taotao-cloud-ddd-api/src/main/resources/META-INF/spring.factories b/taotao-cloud-ddd-api/src/main/resources/META-INF/spring.factories index e69de29..6776705 100644 --- a/taotao-cloud-ddd-api/src/main/resources/META-INF/spring.factories +++ b/taotao-cloud-ddd-api/src/main/resources/META-INF/spring.factories @@ -0,0 +1,11 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +com.taotao.cloud.ddd.api.feign.fallback.DictApiFallback, \ +com.taotao.cloud.ddd.api.feign.fallback.FileApiFallback, \ +com.taotao.cloud.ddd.api.feign.fallback.LogisticsApiFallback, \ +com.taotao.cloud.ddd.api.feign.fallback.MenuApiFallback, \ +com.taotao.cloud.ddd.api.feign.fallback.QuartzJobApiFallback, \ +com.taotao.cloud.ddd.api.feign.fallback.RoleApiFallback, \ +com.taotao.cloud.ddd.api.feign.fallback.SettingApiFallback, \ +com.taotao.cloud.ddd.api.feign.fallback.sysLogApiFallback, \ +com.taotao.cloud.ddd.api.feign.fallback.sysLogLoginApiFallback, \ +com.taotao.cloud.ddd.api.feign.fallback.UserApiFallback diff --git a/taotao-cloud-ddd-api/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/taotao-cloud-ddd-api/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 9a64204..bd5c961 100644 --- a/taotao-cloud-ddd-api/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/taotao-cloud-ddd-api/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -5,8 +5,8 @@ com.taotao.cloud.ddd.api.feign.fallback.MenuApiFallback com.taotao.cloud.ddd.api.feign.fallback.QuartzJobApiFallback com.taotao.cloud.ddd.api.feign.fallback.RoleApiFallback com.taotao.cloud.ddd.api.feign.fallback.SettingApiFallback -com.taotao.cloud.ddd.api.feign.fallback.dddLogApiFallback -com.taotao.cloud.ddd.api.feign.fallback.dddLogLoginApiFallback +com.taotao.cloud.ddd.api.feign.fallback.sysLogApiFallback +com.taotao.cloud.ddd.api.feign.fallback.sysLogLoginApiFallback com.taotao.cloud.ddd.api.feign.fallback.UserApiFallback diff --git a/taotao-cloud-ddd-application/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/taotao-cloud-ddd-application/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000..e69de29 diff --git a/taotao-cloud-ddd-assembly/build.gradle b/taotao-cloud-ddd-assembly/build.gradle index d8fae17..0a297ec 100644 --- a/taotao-cloud-ddd-assembly/build.gradle +++ b/taotao-cloud-ddd-assembly/build.gradle @@ -1,3 +1,4 @@ +import org.apache.tools.ant.filters.ReplaceTokens apply from: rootProject.file('gradle/project-report.gradle') apply from: rootProject.file('gradle/git.gradle') @@ -20,6 +21,84 @@ dependencies { implementation project(":taotao-cloud-ddd-common") } + +def getProperty(String key, String defaultValue) { + def keyValue = findProperty(key) ?: System.getenv(key) + if (keyValue != null) { + return keyValue; + } + // 加载根路径自定义配置属性 + Properties envProps = new Properties() + envProps.load(new FileInputStream("${rootProject.projectDir.absolutePath}${File.separator}release.properties")) + + keyValue = envProps.getProperty(key, defaultValue) + println("打包profile环境==============" + keyValue) + return keyValue +} +//多项目分环境打包 +//gradle构建过程中的默认任务processResources,重写 +//gradle build -x test -Pprofile=dev +//gradle -x test clean bootJar -Pprofile=dev +processResources { + doFirst { + //过滤器会将用 @var@ 包裹的变量,替换为指定的值。 + filter ReplaceTokens, tokens: [activeProfile: getProperty("profile", "dev")] + + + //${profile}变量 + //filesMatching("**/*.yml"){ + // expand(project.properties) + //} + + //inputs.property('version', version) + + //filesMatching("**/version.properties") { + // expand version: version + //} + } +} + +tasks.register('createProperties') { + dependsOn processResources + doLast { + def fileDir = new File("${project.layout.buildDirectory.asFile.get()}/resources/main"); + if (fileDir.exists() && fileDir.isDirectory()) { + def pro = ["application.properties", "bootstrap.properties"] + pro.forEach(item -> { + new File("${project.layout.buildDirectory.asFile.get()}/resources/main/$item").withWriter { w -> + def projectProperties = project.properties + Properties p = new Properties() + projectProperties.each { entry -> + p[entry.key.toString()] = entry.value.toString() + } + + p.store w, null + } + }) + } + } +} + +classes { + dependsOn 'createProperties' +} + +task bootJarTest { + dependsOn 'clean' + doFirst { + System.setProperty("profile", "test") + } + finalizedBy("bootJar") +} + +task bootJarProduction { + dependsOn 'clean' + doFirst { + System.setProperty("profile", "prod") + } + finalizedBy("bootJar") +} + configurations { all { resolutionStrategy.cacheChangingModulesFor 0, "seconds" diff --git a/taotao-cloud-ddd-assembly/src/main/java/com/taotao/cloud/ddd/TaoTaoCloudDDDApplication.java b/taotao-cloud-ddd-assembly/src/main/java/com/taotao/cloud/ddd/TaoTaoCloudDDDApplication.java index 785ec46..b9952bf 100644 --- a/taotao-cloud-ddd-assembly/src/main/java/com/taotao/cloud/ddd/TaoTaoCloudDDDApplication.java +++ b/taotao-cloud-ddd-assembly/src/main/java/com/taotao/cloud/ddd/TaoTaoCloudDDDApplication.java @@ -19,10 +19,12 @@ import com.taotao.cloud.common.utils.common.PropertyUtils; import com.taotao.cloud.core.startup.StartupSpringApplication; import com.taotao.cloud.data.jpa.extend.JpaExtendRepositoryFactoryBean; +import com.taotao.cloud.goods.api.feign.fallback.GoodsApiFallback; import com.taotao.cloud.web.annotation.TaoTaoCloudApplication; import org.mybatis.spring.annotation.MapperScan; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Import; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; /** @@ -59,9 +61,6 @@ * @version 2022.03 * @since 2020/11/30 下午3:33 */ -//@ComponentScan(basePackages = { -// "com.taotao.cloud.ddd" -//}) @MapperScan(basePackages = {"com.taotao.cloud.ddd.infrastructure.persistent.*.mapper"}) @EnableJpaRepositories( basePackages = {"com.taotao.cloud.ddd.infrastructure.persistent.*.repository.inf"}, @@ -69,7 +68,7 @@ //@ComponentScan(basePackages = { // "com.taotao.cloud.ddd.biz.repository.cls" //} ) -//@EnableFeignClients(basePackages = {"com.taotao.cloud.ddd.api.feign"}) +//@EnableFeignClients(basePackages = {"com.taotao.cloud.ddd.api.feign","com.taotao.cloud.goods.api.feign"}) @TaoTaoCloudApplication public class TaoTaoCloudDDDApplication { diff --git a/taotao-cloud-ddd-assembly/src/main/resources/application-dev.yml b/taotao-cloud-ddd-assembly/src/main/resources/application-dev.yml index 768e83d..cafb196 100644 --- a/taotao-cloud-ddd-assembly/src/main/resources/application-dev.yml +++ b/taotao-cloud-ddd-assembly/src/main/resources/application-dev.yml @@ -1264,7 +1264,7 @@ taotao: remoteServiceName: p6spy-${spring.application.name} springdoc: enabled: true - group: ${spring.applicaion.name} + group: ${spring.application.name} version: ${ttcVersion} title: 系统管理模块 metrics: @@ -1679,35 +1679,36 @@ grpc: shutdownGrace: 30 enabled: true -# server: -# port: 7052 #服务端端口 -# #in-process-name: test #自己的应用程序中调用自己的 grpc服务 使用 grpc 的 InProcessServer 来节省网络间开销 -# #security: #为了允许 grpc-server 使用 TLS 您必须使用以下选项来配置它: -# # enabled: true -# # certificateChain: file:certificates/server.crt -# # privateKey: file:certificates/server.key -# # privateKeyPassword: MyStrongPassword -# client: -# #inProcess: -# # address: in-process:test #这允许客户端在同一应用程序内使用以下配置连接到服务器: -# grpc-server: -# address: 'static://127.0.0.1:9898' -# # 服务名(不同服务名可对应不同配置) -# #grpc-sb-server: -# # # 服务端地址 -# # address: 'static://127.0.0.1:9898' -# # # 是否开启保持连接(长连接) -# # enableKeepAlive: true -# # # 保持连接时长(默认20s) -# # keepAliveTimeout: 20s -# # # 没有RPC调用时是否保持连接(默认false,可禁用避免额外消耗CPU) -# # keepAliveWithoutCalls: false -# # # 客户端负载均衡策略(round_robin(默认), pick_first) -# # defaultLoadBalancingPolicy: round_robin -# # # 通信类型 -# # # plaintext | plaintext_upgrade | tls -# # # 明文通信且http/2 | 明文通信且升级http/1.1为http/2 | 使用TLS(ALPN/NPN)通信 -# # negotiationType: plaintext + server: + port: 9899 #服务端端口 + #in-process-name: test #自己的应用程序中调用自己的 grpc服务 使用 grpc 的 InProcessServer 来节省网络间开销 + #security: #为了允许 grpc-server 使用 TLS 您必须使用以下选项来配置它: + # enabled: true + # certificateChain: file:certificates/server.crt + # privateKey: file:certificates/server.key + # privateKeyPassword: MyStrongPassword + health-service-enabled: false + client: + #inProcess: + # address: in-process:test #这允许客户端在同一应用程序内使用以下配置连接到服务器: + grpc-server: + address: 'static://127.0.0.1:9899' + # 服务名(不同服务名可对应不同配置) + #grpc-sb-server: + # # 服务端地址 + # address: 'static://127.0.0.1:9898' + # # 是否开启保持连接(长连接) + # enableKeepAlive: true + # # 保持连接时长(默认20s) + # keepAliveTimeout: 20s + # # 没有RPC调用时是否保持连接(默认false,可禁用避免额外消耗CPU) + # keepAliveWithoutCalls: false + # # 客户端负载均衡策略(round_robin(默认), pick_first) + # defaultLoadBalancingPolicy: round_robin + # # 通信类型 + # # plaintext | plaintext_upgrade | tls + # # 明文通信且http/2 | 明文通信且升级http/1.1为http/2 | 使用TLS(ALPN/NPN)通信 + # negotiationType: plaintext herodotus: endpoint: diff --git a/taotao-cloud-ddd-domain/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/taotao-cloud-ddd-domain/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000..e69de29 diff --git a/taotao-cloud-ddd-facade/src/main/java/com/taotao/cloud/ddd/facade/controller/buy/BuyerDictController.java b/taotao-cloud-ddd-facade/src/main/java/com/taotao/cloud/ddd/facade/controller/buy/BuyerDictController.java index e162ada..62a2058 100644 --- a/taotao-cloud-ddd-facade/src/main/java/com/taotao/cloud/ddd/facade/controller/buy/BuyerDictController.java +++ b/taotao-cloud-ddd-facade/src/main/java/com/taotao/cloud/ddd/facade/controller/buy/BuyerDictController.java @@ -17,6 +17,9 @@ package com.taotao.cloud.ddd.facade.controller.buy; import com.taotao.cloud.common.model.Result; +import com.taotao.cloud.common.utils.log.LogUtils; +import com.taotao.cloud.goods.api.feign.GoodsApi; +import com.taotao.cloud.goods.api.feign.GoodsSkuApi; import com.taotao.cloud.security.springsecurity.annotation.NotAuth; import com.taotao.cloud.ddd.application.service.DeptsService; import com.taotao.cloud.ddd.application.service.DictsService; @@ -26,6 +29,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import java.sql.SQLIntegrityConstraintViolationException; import lombok.AllArgsConstructor; +import lombok.val; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -51,6 +55,7 @@ public class BuyerDictController { private final DeptsService deptsService; private final DictDomainService dictDomainService; private final DeptDomainService deptDomainService; + private final GoodsApi goodsApi; @NotAuth @@ -58,6 +63,10 @@ public class BuyerDictController { @Operation(summary = "通过code查询所有字典列表") public Result add(@PathVariable String type) throws SQLIntegrityConstraintViolationException { + Long result = goodsApi.countStoreGoodsNum(1L); + + LogUtils.info("调用-商品API---结果:{}", result); + return Result.success(true); } diff --git a/taotao-cloud-ddd-facade/src/main/java/com/taotao/cloud/ddd/facade/grpc/DictGrpcServiceImpl.java b/taotao-cloud-ddd-facade/src/main/java/com/taotao/cloud/ddd/facade/grpc/DictGrpcServiceImpl.java index 58cbb50..48531ed 100644 --- a/taotao-cloud-ddd-facade/src/main/java/com/taotao/cloud/ddd/facade/grpc/DictGrpcServiceImpl.java +++ b/taotao-cloud-ddd-facade/src/main/java/com/taotao/cloud/ddd/facade/grpc/DictGrpcServiceImpl.java @@ -16,6 +16,14 @@ package com.taotao.cloud.ddd.facade.grpc; +import static com.taotao.cloud.common.support.info.ApiVersionEnum.V2022_07; +import static com.taotao.cloud.common.support.info.ApiVersionEnum.V2022_08; + +import com.taotao.cloud.common.support.info.Caller; +import com.taotao.cloud.common.support.info.Create; +import com.taotao.cloud.common.support.info.GrpcInfo; +import com.taotao.cloud.common.support.info.RpcInfo; +import com.taotao.cloud.common.support.info.Update; import com.taotao.cloud.ddd.api.grpc.DictGrpcRequest; import com.taotao.cloud.ddd.api.grpc.DictGrpcResponse; import com.taotao.cloud.ddd.api.grpc.DictGrpcServiceGrpc.DictGrpcServiceImplBase; @@ -31,6 +39,16 @@ public class DictGrpcServiceImpl extends DictGrpcServiceImplBase { // @Autowired // private IDevicesFixService deviceService; + @GrpcInfo( + create = @Create(version = V2022_07, date = "2022-07-01 17:11:55"), + update = { + @Update(version = V2022_07, content = "主要修改了配置信息的接口查询", date = "2022-07-01 17:11:55"), + @Update(version = V2022_08, content = "主要修改了配置信息的接口查询08", date = "2022-07-08 15:12:55") + }, + caller = { + @Caller(contacts = "张三", desc = "支付系统", sys = "支付系统", use = "调用字典查询获取详情"), + @Caller(contacts = "李四", desc = "后台管理-字典管理-添加页面", sys = "后台管理", use = "查询字典") + }) @Override public void findByCode(DictGrpcRequest request, StreamObserver responseObserver) { diff --git a/taotao-cloud-ddd-facade/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/taotao-cloud-ddd-facade/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000..e69de29 diff --git a/taotao-cloud-ddd-infrastructure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/taotao-cloud-ddd-infrastructure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000..e69de29 diff --git a/taotao-cloud-ddd-integration/src/main/java/com/taotao/cloud/ddd/integration/goods/proxy/GoodsClientProxy.java b/taotao-cloud-ddd-integration/src/main/java/com/taotao/cloud/ddd/integration/goods/proxy/GoodsClientProxy.java index 4c94dbf..7fdb067 100644 --- a/taotao-cloud-ddd-integration/src/main/java/com/taotao/cloud/ddd/integration/goods/proxy/GoodsClientProxy.java +++ b/taotao-cloud-ddd-integration/src/main/java/com/taotao/cloud/ddd/integration/goods/proxy/GoodsClientProxy.java @@ -26,12 +26,13 @@ import com.taotao.cloud.ddd.integration.goods.vo.GoodsVO; import jakarta.annotation.Resource; import org.openjdk.nashorn.internal.ir.annotations.Reference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class GoodsClientProxy { - @Resource + @Autowired private GoodsApi goodsApi; @Resource private GoodsClientAdapter userIntegrationAdapter; @@ -42,10 +43,10 @@ public class GoodsClientProxy { // 查询用户 public GoodsVO getGoodsVO(Long storeId) { - Long goodsNum = goodsApi.countStoreGoodsNum(storeId); +// Long goodsNum = goodsApi.countStoreGoodsNum(storeId); GoodsQueryRpcResponse goods = goodsRpcService.queryGoodsByParams(new GoodsQueryRpcRequest()); CountStoreGoodsNumGrpcResponse helloReply = goodsGrpcClient.countStoreGoodsNum("sfdasdf"); - return userIntegrationAdapter.convert(goodsNum, goods, helloReply); + return userIntegrationAdapter.convert(0L, goods, helloReply); } } diff --git a/taotao-cloud-ddd-integration/src/main/java/com/taotao/cloud/ddd/integration/sku/proxy/SkuClientProxy.java b/taotao-cloud-ddd-integration/src/main/java/com/taotao/cloud/ddd/integration/sku/proxy/SkuClientProxy.java index d7da79a..ff53d22 100644 --- a/taotao-cloud-ddd-integration/src/main/java/com/taotao/cloud/ddd/integration/sku/proxy/SkuClientProxy.java +++ b/taotao-cloud-ddd-integration/src/main/java/com/taotao/cloud/ddd/integration/sku/proxy/SkuClientProxy.java @@ -32,8 +32,8 @@ @Component public class SkuClientProxy { - @Resource - private GoodsSkuApi goodsSkuApi; + //@Resource + //private GoodsSkuApi goodsSkuApi; @Resource private SkuClientAdapter skuClientAdapter; @Resource @@ -43,11 +43,11 @@ public class SkuClientProxy { // 查询用户 public SkuVO getUserInfo(Long skuId) { - GoodsSkuSpecGalleryApiResponse user = goodsSkuApi.getGoodsSkuByIdFromCache(skuId); +// GoodsSkuSpecGalleryApiResponse user = goodsSkuApi.getGoodsSkuByIdFromCache(skuId); GoodsQueryRpcResponse goodsQueryResponse = goodsRpcService.queryGoodsByParams(new GoodsQueryRpcRequest()); GoodsSkuGrpcResponse helloReply = skuGrpcClient.getGoodsSkuByIdFromCache(""); - return skuClientAdapter.convert(user, goodsQueryResponse, helloReply); + return skuClientAdapter.convert(null, goodsQueryResponse, helloReply); } } diff --git a/taotao-cloud-ddd-integration/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/taotao-cloud-ddd-integration/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000..e69de29