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 560959f..3f55b8c 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 @@ -126,7 +126,7 @@ public class GatewayInterfaceInfoDetailedVO { private String mockDefaultResponse; @ApiModelProperty("Mock默认响应,json格式") - private List mockExpectations; + private List mockExpectations; public static GatewayInterfaceInfoDetailedVO convert(GatewayInterfaceInfo gatewayInterfaceInfo @@ -155,7 +155,8 @@ public class GatewayInterfaceInfoDetailedVO { vo.setMockDefaultHttpStatus(gatewayInterfaceInfo.getMockDefaultHttpStatus()); vo.setMockDefaultResponse(gatewayInterfaceInfo.getMockDefaultResponse()); // mock配置 - vo.setMockExpectations(mockExpectations); + List mockExpectationVOs = mockExpectations.stream().map(GatewayInterfaceMockVO::convert).collect(Collectors.toList()); + vo.setMockExpectations(mockExpectationVOs); // 策略信息 List strategyListVOList = strategyList.stream() .map(GatewayStrategyListVO::convert) diff --git a/sf-service/src/main/java/com/sf/service/gateway/domain/vo/GatewayInterfaceMockVO.java b/sf-service/src/main/java/com/sf/service/gateway/domain/vo/GatewayInterfaceMockVO.java new file mode 100644 index 0000000..04744da --- /dev/null +++ b/sf-service/src/main/java/com/sf/service/gateway/domain/vo/GatewayInterfaceMockVO.java @@ -0,0 +1,69 @@ +package com.sf.service.gateway.domain.vo; + +import com.alibaba.fastjson2.JSON; +import com.sf.service.gateway.domain.GatewayInterfaceMock; +import com.sf.service.gateway.domain.GatewayRoute; +import com.sf.vertx.api.pojo.MockMatchCondition; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** +* 网关服务-接口Mock +*/ +@Data +public class GatewayInterfaceMockVO { + + /** + * ID + */ + @ApiModelProperty("ID") + private Long id; + /** + * 接口id + */ + @ApiModelProperty("接口id") + private Long interfaceId; + /** + * http状态码 + */ + @ApiModelProperty("http状态码") + private Integer httpStatus; + /** + * 匹配条件 + */ + @ApiModelProperty("匹配条件") + private List matchConditions; + /** + * Mock响应,JSON字符串 + */ + @ApiModelProperty("Mock响应,JSON字符串") + private String mockResponse; + /** + * 状态(0停用 1启用) + */ + @ApiModelProperty("状态(0停用 1启用)") + private String status; + /** + * 排序 + */ + @ApiModelProperty("排序") + private Integer orderNum; + + public static GatewayInterfaceMockVO convert(GatewayInterfaceMock mock){ + if (mock == null) { + return null; + } + GatewayInterfaceMockVO vo = new GatewayInterfaceMockVO(); + vo.setId(mock.getId()); + vo.setInterfaceId(mock.getInterfaceId()); + vo.setHttpStatus(mock.getHttpStatus()); + vo.setMatchConditions(JSON.parseArray(mock.getMatchConditions(),MockMatchCondition.class)); + vo.setMockResponse(mock.getMockResponse()); + vo.setStatus(mock.getStatus()); + vo.setOrderNum(mock.getOrderNum()); + + return vo; + } +}