diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java index 8766d0458..6ebd29b12 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java @@ -9,7 +9,9 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.ExampleBuilder; import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestParameterBuilder; import springfox.documentation.service.*; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.service.contexts.SecurityContext; @@ -55,9 +57,12 @@ public class YudaoSwaggerAutoConfiguration { .paths(PathSelectors.any()) .build() .securitySchemes(securitySchemes()) + .globalRequestParameters(globalRequestParameters()) .securityContexts(securityContexts()); } + // ========== apiInfo ========== + /** * API 摘要信息 */ @@ -70,6 +75,8 @@ public class YudaoSwaggerAutoConfiguration { .build(); } + // ========== securitySchemes ========== + /** * 安全模式,这里配置通过请求头 Authorization 传递 token 参数 */ @@ -98,4 +105,12 @@ public class YudaoSwaggerAutoConfiguration { return new AuthorizationScope[]{new AuthorizationScope("global", "accessEverything")}; } + // ========== globalRequestParameters ========== + + private static List globalRequestParameters() { + RequestParameterBuilder tenantParameter = new RequestParameterBuilder().name("tenant-id").description("租户编号") + .in(ParameterType.HEADER).example(new ExampleBuilder().value(1L).build()); + return Collections.singletonList(tenantParameter.build()); + } + } diff --git a/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/test/BaseRedisUnitTest.java b/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/test/BaseRedisUnitTest.java index 11933c9fd..500456307 100644 --- a/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/test/BaseRedisUnitTest.java +++ b/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/test/BaseRedisUnitTest.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.pay.test; import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; +import cn.iocoder.yudao.framework.test.config.RedisTestConfiguration; import org.redisson.spring.starter.RedissonAutoConfiguration; import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/tenant/TenantMapper.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/tenant/TenantMapper.java index f7cb22c0c..6c3287342 100755 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/tenant/TenantMapper.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/tenant/TenantMapper.java @@ -44,7 +44,7 @@ public interface TenantMapper extends BaseMapperX { return selectOne(TenantDO::getName, name); } - default Integer selectCountByPackageId(Long packageId) { + default Long selectCountByPackageId(Long packageId) { return selectCount(TenantDO::getPackageId, packageId); } diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java index 78b204d5c..c54a490a6 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java @@ -18,6 +18,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Multimap; import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Lazy; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -71,6 +72,7 @@ public class MenuServiceImpl implements MenuService { @Resource private PermissionService permissionService; @Resource + @Lazy // 延迟,避免循环依赖报错 private TenantService tenantService; @Resource diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantService.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantService.java index dd4efa1ae..1743991d8 100755 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantService.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantService.java @@ -95,7 +95,7 @@ public interface TenantService extends TenantFrameworkService { * @param packageId 租户套餐编号 * @return 租户数量 */ - Integer getTenantCountByPackageId(Long packageId); + Long getTenantCountByPackageId(Long packageId); /** * 获得使用指定套餐的租户数组 diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java index 27611e098..2cc877066 100755 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java @@ -301,7 +301,7 @@ public class TenantServiceImpl implements TenantService { } @Override - public Integer getTenantCountByPackageId(Long packageId) { + public Long getTenantCountByPackageId(Long packageId) { return tenantMapper.selectCountByPackageId(packageId); } diff --git a/yudao-module-system/yudao-module-system-impl/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantPackageServiceImplTest.java b/yudao-module-system/yudao-module-system-impl/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantPackageServiceImplTest.java index 226469466..2f21fc08a 100755 --- a/yudao-module-system/yudao-module-system-impl/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantPackageServiceImplTest.java +++ b/yudao-module-system/yudao-module-system-impl/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantPackageServiceImplTest.java @@ -102,7 +102,7 @@ public class TenantPackageServiceImplTest extends BaseDbUnitTest { // 准备参数 Long id = dbTenantPackage.getId(); // mock 租户未使用该套餐 - when(tenantService.getTenantCountByPackageId(eq(id))).thenReturn(0); + when(tenantService.getTenantCountByPackageId(eq(id))).thenReturn(0L); // 调用 tenantPackageService.deleteTenantPackage(id); @@ -127,7 +127,7 @@ public class TenantPackageServiceImplTest extends BaseDbUnitTest { // 准备参数 Long id = dbTenantPackage.getId(); // mock 租户在使用该套餐 - when(tenantService.getTenantCountByPackageId(eq(id))).thenReturn(1); + when(tenantService.getTenantCountByPackageId(eq(id))).thenReturn(1L); // 调用, 并断言异常 assertServiceException(() -> tenantPackageService.deleteTenantPackage(id), TENANT_PACKAGE_USED); diff --git a/yudao-module-system/yudao-module-system-impl/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImplTest.java b/yudao-module-system/yudao-module-system-impl/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImplTest.java index 53c77a20f..cd0a72329 100644 --- a/yudao-module-system/yudao-module-system-impl/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImplTest.java +++ b/yudao-module-system/yudao-module-system-impl/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImplTest.java @@ -431,7 +431,7 @@ public class TenantServiceImplTest extends BaseDbUnitTest { tenantMapper.insert(dbTenant2);// @Sql: 先插入出一条存在的数据 // 调用 - Integer count = tenantService.getTenantCountByPackageId(1L); + Long count = tenantService.getTenantCountByPackageId(1L); assertEquals(1, count); }