网关接口详情调整

This commit is contained in:
akun 2024-05-21 15:28:06 +08:00
parent c9c0575014
commit 074ff9d67b
2 changed files with 72 additions and 2 deletions

View File

@ -126,7 +126,7 @@ public class GatewayInterfaceInfoDetailedVO {
private String mockDefaultResponse; private String mockDefaultResponse;
@ApiModelProperty("Mock默认响应json格式") @ApiModelProperty("Mock默认响应json格式")
private List<GatewayInterfaceMock> mockExpectations; private List<GatewayInterfaceMockVO> mockExpectations;
public static GatewayInterfaceInfoDetailedVO convert(GatewayInterfaceInfo gatewayInterfaceInfo public static GatewayInterfaceInfoDetailedVO convert(GatewayInterfaceInfo gatewayInterfaceInfo
@ -155,7 +155,8 @@ public class GatewayInterfaceInfoDetailedVO {
vo.setMockDefaultHttpStatus(gatewayInterfaceInfo.getMockDefaultHttpStatus()); vo.setMockDefaultHttpStatus(gatewayInterfaceInfo.getMockDefaultHttpStatus());
vo.setMockDefaultResponse(gatewayInterfaceInfo.getMockDefaultResponse()); vo.setMockDefaultResponse(gatewayInterfaceInfo.getMockDefaultResponse());
// mock配置 // mock配置
vo.setMockExpectations(mockExpectations); List<GatewayInterfaceMockVO> mockExpectationVOs = mockExpectations.stream().map(GatewayInterfaceMockVO::convert).collect(Collectors.toList());
vo.setMockExpectations(mockExpectationVOs);
// 策略信息 // 策略信息
List<GatewayStrategyListVO> strategyListVOList = strategyList.stream() List<GatewayStrategyListVO> strategyListVOList = strategyList.stream()
.map(GatewayStrategyListVO::convert) .map(GatewayStrategyListVO::convert)

View File

@ -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<MockMatchCondition> 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;
}
}