fix:新增租户同步spdm data服务数据

This commit is contained in:
2025-12-29 10:29:57 +08:00
parent a5b10d1b35
commit 3b133c19dd
4 changed files with 35 additions and 1 deletions

View File

@@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.honeycombis.honeycom.common.core.util.R;
import com.honeycombis.honeycom.spdm.dto.TenantPageQueryDto;
import com.honeycombis.honeycom.spdm.feign.RemoteTenantServiceFeign;
import com.honeycombis.honeycom.spdm.feign.SpdmServiceFeignClient;
import com.honeycombis.honeycom.spdm.util.PageResult;
import com.honeycombis.honeycom.spdm.util.ResponseR;
import com.honeycombis.honeycom.tenant.vo.tenant.SysTenantVO;
@@ -32,6 +33,7 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.web.bind.annotation.*;
@@ -42,11 +44,14 @@ import java.util.List;
@AllArgsConstructor
@RequestMapping("/spdm-tenant")
@Tag(description = "spdm", name = "提供给SPDM的租户模块")
@Slf4j
public class SpdmTenantController {
@Resource
private RemoteTenantServiceFeign remoteTenantServiceFeign;
@Resource
private SpdmServiceFeignClient spdmServiceFeignClient;
@Resource
private ObjectMapper objectMapper;
@@ -68,7 +73,7 @@ public class SpdmTenantController {
if (listTenantForPage.getData() != null && CollectionUtils.isNotEmpty(listTenantForPage.getData().getRecords())) {
return ResponseR.ok(listTenantForPage.getData().getRecords().get(0));
}
return ResponseR.ok();
return ResponseR.ok();
}
@Operation(summary = "查询所有租户" , description = "查询所有租户" )
@@ -77,4 +82,10 @@ public class SpdmTenantController {
return ResponseR.ok(remoteTenantServiceFeign.getAll().getData());
}
@PostMapping("/initNewTenant")
public void initNewTenant(@RequestParam Long tenantId) {
ResponseR responseR = spdmServiceFeignClient.initNewTenant(tenantId);
log.info("[initNewTenant] tenantId:{}, responseR:{}", tenantId, responseR);
}
}

View File

@@ -3,6 +3,7 @@ package com.honeycombis.honeycom.spdm.feign;
import com.honeycombis.honeycom.common.core.util.R;
import com.honeycombis.honeycom.spdm.dto.ApproveResultDto;
import com.honeycombis.honeycom.spdm.dto.SysLogDto;
import com.honeycombis.honeycom.spdm.util.ResponseR;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
@@ -18,4 +19,7 @@ public interface SpdmServiceFeignClient {
@PostMapping("/systemLog/saveLog")
R saveLog(@RequestBody SysLogDto sysLogDto);
@PostMapping("/tenant/initNewTenant")
ResponseR initNewTenant(@RequestParam Long tenantId);
}

View File

@@ -0,0 +1,15 @@
package com.honeycombis.honeycom.tenant.feign;
import com.honeycombis.honeycom.common.core.constant.ServiceNameConstants;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(contextId = "remoteSpdmTenantService", value = ServiceNameConstants.SPDM_SERVICE)
public interface RemoteSpdmService {
@PostMapping("/honeycom-spdm/spdm-tenant/initNewTenant")
void initNewTenant(@RequestParam Long tenantId);
}

View File

@@ -25,6 +25,7 @@ import com.honeycombis.honeycom.tenant.dto.SysInviteSendDTO;
import com.honeycombis.honeycom.tenant.dto.SysTenantAddDTO;
import com.honeycombis.honeycom.tenant.dto.SysTenantUpdateDTO;
import com.honeycombis.honeycom.tenant.entity.*;
import com.honeycombis.honeycom.tenant.feign.RemoteSpdmService;
import com.honeycombis.honeycom.tenant.mapper.SysTenantMapper;
import com.honeycombis.honeycom.tenant.service.*;
import com.honeycombis.honeycom.tenant.utils.BeanUtils;
@@ -74,6 +75,7 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
private final SysRoleFunctionService sysRoleFunctionService;
private final RemoteMessageService remoteMessageService;
private final RemoteSpdmService remoteSpdmService;
/**
* 根据员工id查询所属租户
@@ -280,6 +282,8 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
SysTenantVO sysTenantVO = new SysTenantVO(entity);
// 初始化租户消息模板
remoteMessageService.initTenantMessageConfig(entity.getTenantId(),SecurityConstants.FROM_IN);
// 通知spdm初始化租户桶
remoteSpdmService.initNewTenant(entity.getTenantId());
return sysTenantVO;
}