diff --git a/sf-file/src/main/java/com/sf/file/service/impl/SysOssServiceImpl.java b/sf-file/src/main/java/com/sf/file/service/impl/SysOssServiceImpl.java index a937a9b..316f7c4 100644 --- a/sf-file/src/main/java/com/sf/file/service/impl/SysOssServiceImpl.java +++ b/sf-file/src/main/java/com/sf/file/service/impl/SysOssServiceImpl.java @@ -59,6 +59,9 @@ public class SysOssServiceImpl implements ISysOssService { */ @Override public SysOss selectSysOssById(String id) { + if (StringUtils.isBlank(id)) { + return null; + } return sysOssMapper.selectSysOssById(id); } diff --git a/sf-service/pom.xml b/sf-service/pom.xml index 0fed441..81e9bc9 100644 --- a/sf-service/pom.xml +++ b/sf-service/pom.xml @@ -47,6 +47,10 @@ sf-vertx-api + + com.smarterFramework + sf-file + \ No newline at end of file diff --git a/sf-service/src/main/java/com/sf/service/gateway/controller/GatewayInterfaceInfoController.java b/sf-service/src/main/java/com/sf/service/gateway/controller/GatewayInterfaceInfoController.java index 51d33e3..7394d6e 100644 --- a/sf-service/src/main/java/com/sf/service/gateway/controller/GatewayInterfaceInfoController.java +++ b/sf-service/src/main/java/com/sf/service/gateway/controller/GatewayInterfaceInfoController.java @@ -1,14 +1,13 @@ package com.sf.service.gateway.controller; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; import com.sf.common.utils.AppUtils; +import com.sf.file.domain.SysOss; +import com.sf.file.service.ISysOssService; import com.sf.service.gateway.domain.GatewayInterfaceInfo; import com.sf.service.gateway.domain.GatewayInterfaceLinkStrategy; import com.sf.service.gateway.domain.GatewayServer; @@ -18,7 +17,6 @@ import com.sf.service.gateway.domain.dto.UpdateDataStatusDTO; import com.sf.service.gateway.domain.dto.UpdateGatewayInterfaceInfoDTO; import com.sf.service.gateway.domain.vo.GatewayInterfaceInfoDetailedVO; import com.sf.service.gateway.domain.vo.GatewayInterfaceInfoListVO; -import com.sf.service.gateway.domain.vo.GatewayStrategyListVO; import com.sf.service.gateway.enums.GatewayDataStatus; import com.sf.service.gateway.service.IGatewayInterfaceInfoService; import com.sf.service.gateway.service.IGatewayServerService; @@ -62,6 +60,9 @@ public class GatewayInterfaceInfoController extends BaseController { @Autowired private IGatewayStrategyService gatewayStrategyService; + @Autowired + private ISysOssService sysOssService; + @ApiOperation("查询接口信息列表") @PreAuthorize("@ss.hasPermi('gateway:interface:list')") @GetMapping("/list") @@ -100,7 +101,8 @@ public class GatewayInterfaceInfoController extends BaseController { List linkList = gatewayInterfaceInfoService.selectGatewayInterfaceLinkStrategyByInterfaceIds(Collections.singleton(id)); GatewayServer gatewayServer = gatewayServerService.selectGatewayServerById(gatewayInterfaceInfo.getServerId()); List strategyList = gatewayStrategyService.selectGatewayStrategyByIds(linkList.stream().map(GatewayInterfaceLinkStrategy::getStrategyId).collect(Collectors.toSet())); - GatewayInterfaceInfoDetailedVO vo = GatewayInterfaceInfoDetailedVO.convert(gatewayInterfaceInfo,gatewayServer,strategyList); + SysOss document = sysOssService.selectSysOssById(gatewayInterfaceInfo.getDocument()); + GatewayInterfaceInfoDetailedVO vo = GatewayInterfaceInfoDetailedVO.convert(gatewayInterfaceInfo,gatewayServer,strategyList,document); // TODO 调用次数和平均时间暂时没有来源 vo.setNumberOfCalls(0L); vo.setAverageResponseTime(0L); diff --git a/sf-service/src/main/java/com/sf/service/gateway/domain/dto/InsertGatewayInterfaceInfoDTO.java b/sf-service/src/main/java/com/sf/service/gateway/domain/dto/InsertGatewayInterfaceInfoDTO.java index fb302c0..06c1377 100644 --- a/sf-service/src/main/java/com/sf/service/gateway/domain/dto/InsertGatewayInterfaceInfoDTO.java +++ b/sf-service/src/main/java/com/sf/service/gateway/domain/dto/InsertGatewayInterfaceInfoDTO.java @@ -2,6 +2,7 @@ package com.sf.service.gateway.domain.dto; import com.sf.common.annotation.Excel; import com.sf.common.core.domain.BaseEntity; +import com.sf.file.domain.SysOss; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -55,7 +56,7 @@ public class InsertGatewayInterfaceInfoDTO { private String version; @ApiModelProperty("接口文档(文档地址)") - private String document; + private SysOss document; @NotNull(message = "网关服务不能为空") @ApiModelProperty("网关服务id") diff --git a/sf-service/src/main/java/com/sf/service/gateway/domain/dto/UpdateGatewayInterfaceInfoDTO.java b/sf-service/src/main/java/com/sf/service/gateway/domain/dto/UpdateGatewayInterfaceInfoDTO.java index aae57fa..9bc288c 100644 --- a/sf-service/src/main/java/com/sf/service/gateway/domain/dto/UpdateGatewayInterfaceInfoDTO.java +++ b/sf-service/src/main/java/com/sf/service/gateway/domain/dto/UpdateGatewayInterfaceInfoDTO.java @@ -1,6 +1,7 @@ package com.sf.service.gateway.domain.dto; import com.sf.common.annotation.Excel; +import com.sf.file.domain.SysOss; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -58,7 +59,7 @@ public class UpdateGatewayInterfaceInfoDTO { private String version; @ApiModelProperty("接口文档(文档地址)") - private String document; + private SysOss document; @NotNull(message = "网关服务不能为空") @ApiModelProperty("网关服务id") diff --git a/sf-service/src/main/java/com/sf/service/gateway/domain/vo/GatewayInterfaceInfoDetailedVO.java b/sf-service/src/main/java/com/sf/service/gateway/domain/vo/GatewayInterfaceInfoDetailedVO.java index eb13df6..c292c7c 100644 --- a/sf-service/src/main/java/com/sf/service/gateway/domain/vo/GatewayInterfaceInfoDetailedVO.java +++ b/sf-service/src/main/java/com/sf/service/gateway/domain/vo/GatewayInterfaceInfoDetailedVO.java @@ -2,6 +2,7 @@ package com.sf.service.gateway.domain.vo; import com.fasterxml.jackson.annotation.JsonFormat; import com.sf.common.annotation.Excel; +import com.sf.file.domain.SysOss; import com.sf.service.gateway.domain.GatewayInterfaceInfo; import com.sf.service.gateway.domain.GatewayServer; import com.sf.service.gateway.domain.GatewayStrategy; @@ -88,7 +89,7 @@ public class GatewayInterfaceInfoDetailedVO { */ @Excel(name = "接口文档", readConverterExp = "文档地址") @ApiModelProperty("接口文档(文档地址)") - private String document; + private SysOss document; @ApiModelProperty("调用次数") private Long numberOfCalls; @@ -119,7 +120,9 @@ public class GatewayInterfaceInfoDetailedVO { public static GatewayInterfaceInfoDetailedVO convert(GatewayInterfaceInfo gatewayInterfaceInfo , GatewayServer gatewayServer - , List strategyList) { + , List strategyList + , SysOss document + ) { GatewayInterfaceInfoDetailedVO vo = new GatewayInterfaceInfoDetailedVO(); vo.setId(gatewayInterfaceInfo.getId()); vo.setInterfaceName(gatewayInterfaceInfo.getInterfaceName()); @@ -129,7 +132,7 @@ public class GatewayInterfaceInfoDetailedVO { vo.setDescription(gatewayInterfaceInfo.getDescription()); vo.setVersion(gatewayInterfaceInfo.getVersion()); vo.setStatus(gatewayInterfaceInfo.getStatus()); - vo.setDocument(gatewayInterfaceInfo.getDocument()); + vo.setDocument(document); vo.setCreateTime(gatewayInterfaceInfo.getCreateTime()); vo.setUpdateTime(gatewayInterfaceInfo.getUpdateTime()); vo.setServerId(gatewayInterfaceInfo.getServerId()); diff --git a/sf-service/src/main/java/com/sf/service/gateway/domain/vo/GatewayInterfaceInfoListVO.java b/sf-service/src/main/java/com/sf/service/gateway/domain/vo/GatewayInterfaceInfoListVO.java index fb36b6b..2d31f9e 100644 --- a/sf-service/src/main/java/com/sf/service/gateway/domain/vo/GatewayInterfaceInfoListVO.java +++ b/sf-service/src/main/java/com/sf/service/gateway/domain/vo/GatewayInterfaceInfoListVO.java @@ -2,11 +2,8 @@ package com.sf.service.gateway.domain.vo; import com.fasterxml.jackson.annotation.JsonFormat; import com.sf.common.annotation.Excel; -import com.sf.common.core.domain.BaseEntity; import com.sf.service.gateway.domain.GatewayInterfaceInfo; -import com.sf.service.gateway.domain.GatewayRoute; import com.sf.service.gateway.domain.GatewayServer; -import com.sf.service.gateway.enums.GatewayServiceModel; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; diff --git a/sf-service/src/main/java/com/sf/service/gateway/service/impl/GatewayInterfaceInfoServiceImpl.java b/sf-service/src/main/java/com/sf/service/gateway/service/impl/GatewayInterfaceInfoServiceImpl.java index 26f0d2f..b071f07 100644 --- a/sf-service/src/main/java/com/sf/service/gateway/service/impl/GatewayInterfaceInfoServiceImpl.java +++ b/sf-service/src/main/java/com/sf/service/gateway/service/impl/GatewayInterfaceInfoServiceImpl.java @@ -26,6 +26,8 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; +import static org.apache.commons.lang3.StringUtils.EMPTY; + /** * 接口管理Service业务层处理 * @@ -94,8 +96,8 @@ public class GatewayInterfaceInfoServiceImpl implements IGatewayInterfaceInfoSer } private void checkGatewayInterfaceInfoCanInsertOrUpdate(GatewayInterfaceInfo gatewayInterfaceInfo) { - if (GatewayDataStatus.ENABLE.getCode().equals(gatewayInterfaceInfo.getMockStatus())){ - Assert.isTrue(JSON.isJSONObject(gatewayInterfaceInfo.getMockResponse()),"请输入正确格式的响应信息"); + if (GatewayDataStatus.ENABLE.getCode().equals(gatewayInterfaceInfo.getMockStatus())) { + Assert.isTrue(JSON.isJSONObject(gatewayInterfaceInfo.getMockResponse()), "请输入正确格式的响应信息"); } } @@ -186,7 +188,8 @@ public class GatewayInterfaceInfoServiceImpl implements IGatewayInterfaceInfoSer gatewayInterfaceInfo.setDescription(dto.getDescription()); gatewayInterfaceInfo.setVersion(dto.getVersion()); gatewayInterfaceInfo.setStatus(GatewayDataStatus.DISABLE.getCode()); - gatewayInterfaceInfo.setDocument(dto.getDocument()); + String document = dto.getDocument() == null ? EMPTY : dto.getDocument().getId(); + gatewayInterfaceInfo.setDocument(document); gatewayInterfaceInfo.setServerId(dto.getServerId()); gatewayInterfaceInfo.setMockStatus(dto.getMockStatus()); gatewayInterfaceInfo.setMockResponse(dto.getMockResponse()); @@ -212,7 +215,8 @@ public class GatewayInterfaceInfoServiceImpl implements IGatewayInterfaceInfoSer gatewayInterfaceInfo.setRequestMethod(dto.getRequestMethod()); gatewayInterfaceInfo.setDescription(dto.getDescription()); gatewayInterfaceInfo.setVersion(dto.getVersion()); - gatewayInterfaceInfo.setDocument(dto.getDocument()); + String document = dto.getDocument() == null ? EMPTY : dto.getDocument().getId(); + gatewayInterfaceInfo.setDocument(document); gatewayInterfaceInfo.setServerId(dto.getServerId()); gatewayInterfaceInfo.setMockStatus(dto.getMockStatus()); gatewayInterfaceInfo.setMockResponse(dto.getMockResponse());