mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-13 18:45:06 +08:00
Swagger 增加 tenant-id 头
This commit is contained in:
@ -44,7 +44,7 @@ public interface TenantMapper extends BaseMapperX<TenantDO> {
|
||||
return selectOne(TenantDO::getName, name);
|
||||
}
|
||||
|
||||
default Integer selectCountByPackageId(Long packageId) {
|
||||
default Long selectCountByPackageId(Long packageId) {
|
||||
return selectCount(TenantDO::getPackageId, packageId);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -95,7 +95,7 @@ public interface TenantService extends TenantFrameworkService {
|
||||
* @param packageId 租户套餐编号
|
||||
* @return 租户数量
|
||||
*/
|
||||
Integer getTenantCountByPackageId(Long packageId);
|
||||
Long getTenantCountByPackageId(Long packageId);
|
||||
|
||||
/**
|
||||
* 获得使用指定套餐的租户数组
|
||||
|
@ -301,7 +301,7 @@ public class TenantServiceImpl implements TenantService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getTenantCountByPackageId(Long packageId) {
|
||||
public Long getTenantCountByPackageId(Long packageId) {
|
||||
return tenantMapper.selectCountByPackageId(packageId);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user