Compare commits
1 Commits
mentat-611
...
mentat-631
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b23ed4fc01 |
@@ -5,8 +5,6 @@ import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkService;
|
||||
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO;
|
||||
import cn.iocoder.yudao.module.system.service.tenant.TenantService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
@@ -31,7 +29,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class TenantJobAspect {
|
||||
|
||||
private final TenantFrameworkService tenantFrameworkService;
|
||||
private final TenantService tenantService;
|
||||
|
||||
@Around("@annotation(tenantJob)")
|
||||
public String around(ProceedingJoinPoint joinPoint, TenantJob tenantJob) {
|
||||
@@ -47,10 +44,6 @@ public class TenantJobAspect {
|
||||
// TODO 芋艿:先通过 parallel 实现并行;1)多个租户,是一条执行日志;2)异常的情况
|
||||
TenantUtils.execute(tenantId, () -> {
|
||||
try {
|
||||
TenantDO tenant = tenantService.getTenant(tenantId);
|
||||
if (tenant.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) {
|
||||
return; // Skip disabled tenants
|
||||
}
|
||||
joinPoint.proceed();
|
||||
} catch (Throwable e) {
|
||||
results.put(tenantId, ExceptionUtil.getRootCauseMessage(e));
|
||||
@@ -60,4 +53,4 @@ public class TenantJobAspect {
|
||||
return JsonUtils.toJsonString(results);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -59,4 +59,9 @@ public class PayAppDO extends BaseDO {
|
||||
*/
|
||||
private String transferNotifyUrl;
|
||||
|
||||
}
|
||||
/**
|
||||
* 应用密钥
|
||||
*/
|
||||
private String appKey;
|
||||
|
||||
}
|
@@ -146,4 +146,22 @@ public interface PayOrderService {
|
||||
*/
|
||||
int expireOrder();
|
||||
|
||||
}
|
||||
/**
|
||||
* 获得支付订单
|
||||
*
|
||||
* @param appKey 应用密钥
|
||||
* @param merchantOrderId 商户订单编号
|
||||
* @return 支付订单
|
||||
*/
|
||||
PayOrderDO getOrder(String appKey, String merchantOrderId);
|
||||
|
||||
/**
|
||||
* 创建支付单
|
||||
*
|
||||
* @param reqDTO 创建请求
|
||||
* @param appKey 应用密钥
|
||||
* @return 支付单编号
|
||||
*/
|
||||
Long createOrder(@Valid PayOrderCreateReqDTO reqDTO, String appKey);
|
||||
|
||||
}
|
@@ -85,6 +85,15 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
return orderMapper.selectByAppIdAndMerchantOrderId(appId, merchantOrderId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PayOrderDO getOrder(String appKey, String merchantOrderId) {
|
||||
PayAppDO app = appService.getAppByAppKey(appKey);
|
||||
if (app == null) {
|
||||
throw exception(PAY_APP_NOT_FOUND);
|
||||
}
|
||||
return orderMapper.selectByAppIdAndMerchantOrderId(app.getId(), merchantOrderId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PayOrderDO> getOrderList(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
|
@@ -403,37 +403,13 @@ public class TenantServiceImplTest extends BaseDbUnitTest {
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTenantJobAspect_skipDisabledTenants() {
|
||||
// mock 租户
|
||||
TenantDO enabledTenant = randomPojo(TenantDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
||||
TenantDO disabledTenant = randomPojo(TenantDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()));
|
||||
tenantMapper.insert(enabledTenant);
|
||||
tenantMapper.insert(disabledTenant);
|
||||
// mock tenantService
|
||||
when(tenantService.getTenant(enabledTenant.getId())).thenReturn(enabledTenant);
|
||||
when(tenantService.getTenant(disabledTenant.getId())).thenReturn(disabledTenant);
|
||||
|
||||
// mock tenantFrameworkService
|
||||
when(tenantFrameworkService.getTenantIds()).thenReturn(Arrays.asList(enabledTenant.getId(), disabledTenant.getId()));
|
||||
|
||||
// mock joinPoint
|
||||
ProceedingJoinPoint joinPoint = mock(ProceedingJoinPoint.class);
|
||||
|
||||
// 调用
|
||||
TenantJobAspect aspect = new TenantJobAspect(tenantFrameworkService, tenantService);
|
||||
aspect.around(joinPoint, mock(TenantJob.class));
|
||||
|
||||
// 断言
|
||||
verify(joinPoint, times(1)).proceed();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleTenantMenu_disable() {
|
||||
// 准备参数
|
||||
TenantMenuHandler handler = mock(TenantMenuHandler.class);
|
||||
// mock 禁用
|
||||
when(tenantProperties.getEnable()).thenReturn(false);
|
||||
|
||||
// 调用
|
||||
tenantService.handleTenantMenu(handler);
|
||||
// 断言
|
||||
|
Reference in New Issue
Block a user