网关管理联调调整

This commit is contained in:
akun 2024-04-29 11:47:36 +08:00
parent 78f816ce3e
commit 01d95a19a6
17 changed files with 249 additions and 33 deletions

View File

@ -4,6 +4,7 @@ import lombok.experimental.UtilityClass;
import org.hibernate.validator.internal.util.DomainNameUtil;
import javax.security.auth.x500.X500Principal;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.regex.Matcher;
@ -78,6 +79,28 @@ public class URLUtils {
return valueHolder;
}
public static boolean isUrlAlive(String urlString,int connectTimeout,int readTimeout) {
HttpURLConnection connection = null;
try {
URL url = new URL(urlString);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setConnectTimeout(connectTimeout); // 设置连接超时时间
connection.setReadTimeout(readTimeout); // 设置读取超时时间
int responseCode = connection.getResponseCode();
// 判断响应码是否表示成功200-399 范围内
return (200 <= responseCode && responseCode <= 399);
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
if (connection != null) {
connection.disconnect(); // 断开连接
}
}
}
private static class ValueHolder {
private final String protocol;
private final String host;

View File

@ -84,6 +84,16 @@ public class GlobalExceptionHandler
return AjaxResult.error(String.format("请求参数类型不匹配,参数[%s]要求类型为:'%s',但输入值为:'%s'", e.getName(), e.getRequiredType().getName(), e.getValue()));
}
/**
* 请求参数错误
*/
@ExceptionHandler(IllegalArgumentException.class)
public AjaxResult handleIllegalArgumentException(IllegalArgumentException e)
{
log.error(e.getMessage(), e);
return AjaxResult.error(HttpStatus.BAD_REQUEST,e.getMessage());
}
/**
* 拦截未知的运行时异常
*/

View File

@ -1,24 +1,24 @@
package com.sf.service.gateway.controller;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
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.domain.*;
import com.sf.service.gateway.domain.dto.QueryGatewayServerDTO;
import com.sf.service.gateway.domain.dto.QueryGatewayStrategyDTO;
import com.sf.service.gateway.domain.dto.UpdateDataStatusDTO;
import com.sf.service.gateway.domain.vo.GatewayInterfaceInfoListVO;
import com.sf.service.gateway.domain.vo.GatewayServerDetailedVO;
import com.sf.service.gateway.domain.vo.GatewayServerListVO;
import com.sf.service.gateway.domain.vo.GatewayStrategyListVO;
import com.sf.service.gateway.enums.GatewayDataStatus;
import com.sf.service.gateway.enums.GatewayServiceModel;
import com.sf.service.gateway.service.IGatewayInterfaceInfoService;
import com.sf.service.gateway.service.IGatewayRouteService;
import com.sf.service.gateway.service.IGatewayServerService;
import com.sf.service.gateway.service.IGatewayStrategyService;
import com.sf.service.index.util.AppUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
@ -57,6 +57,9 @@ public class GatewayServerController extends BaseController {
@Autowired
private IGatewayInterfaceInfoService gatewayInterfaceInfoService;
@Autowired
private IGatewayStrategyService gatewayStrategyService;
/**
* 查询服务管理列表
*/
@ -78,6 +81,7 @@ public class GatewayServerController extends BaseController {
vo.setServerName(item.getServerName());
vo.setServerAddress(GatewayServiceModel.ROUTE.getCode().equals(item.getServiceModel()) ?
routeIdAndNameMap.get(item.getRouteId()) : item.getServerAddress());
vo.setRemark(item.getRemark());
vo.setStatus(item.getStatus());
vo.setCreated(item.getCreated());
vo.setModified(item.getModified());
@ -111,6 +115,10 @@ public class GatewayServerController extends BaseController {
GatewayServerDetailedVO vo = new GatewayServerDetailedVO();
GatewayServer gatewayServer = gatewayServerService.selectGatewayServerById(id);
List<GatewayInterfaceInfo> interfaceInfoList = gatewayInterfaceInfoService.selectGatewayInterfaceInfoByServerIds(Collections.singleton(id));
List<GatewayInterfaceLinkStrategy> linkList = gatewayInterfaceInfoService.selectGatewayInterfaceLinkStrategyByInterfaceIds(interfaceInfoList.stream().map(GatewayInterfaceInfo::getId).collect(Collectors.toSet()));
Map<Long, List<GatewayInterfaceLinkStrategy>> groupByInterfaceLinkMap = linkList.stream().collect(Collectors.groupingBy(GatewayInterfaceLinkStrategy::getInterfaceId));
List<GatewayStrategy> strategyList = gatewayStrategyService.selectGatewayStrategyByIds(linkList.stream().map(GatewayInterfaceLinkStrategy::getStrategyId).collect(Collectors.toSet()));
Map<Long, GatewayStrategy> strategyMap = strategyList.stream().collect(Collectors.toMap(GatewayStrategy::getId, Function.identity()));
if (GatewayServiceModel.ROUTE.getCode().equals(gatewayServer.getServiceModel())){
GatewayRoute route = gatewayRouteService.selectGatewayRouteById(gatewayServer.getRouteId());
vo.setServerAddress(route.getRouteName());
@ -119,6 +127,7 @@ public class GatewayServerController extends BaseController {
}
vo.setId(gatewayServer.getId());
vo.setServerName(gatewayServer.getServerName());
vo.setRemark(gatewayServer.getRemark());
vo.setStatus(gatewayServer.getStatus());
vo.setCreated(gatewayServer.getCreated());
vo.setModified(gatewayServer.getModified());
@ -136,9 +145,24 @@ public class GatewayServerController extends BaseController {
interfaceInfoListVO.setVersion(info.getVersion());
interfaceInfoListVO.setStatus(info.getStatus());
interfaceInfoListVO.setDocument(info.getDocument());
// 策略信息
List<GatewayInterfaceLinkStrategy> currentLinks = groupByInterfaceLinkMap.getOrDefault(info.getId(), Collections.emptyList());
List<GatewayStrategyListVO> strategyListVOList = currentLinks.stream().map(link -> {
GatewayStrategy strategy = strategyMap.get(link.getStrategyId());
GatewayStrategyListVO strategyListVO = new GatewayStrategyListVO();
strategyListVO.setId(strategy.getId());
strategyListVO.setStrategyName(strategy.getStrategyName());
strategyListVO.setStrategyType(strategy.getStrategyType());
strategyListVO.setDescription(strategy.getDescription());
strategyListVO.setStatus(strategy.getStatus());
return strategyListVO;
})
.collect(Collectors.toList());
interfaceInfoListVO.setStrategyList(strategyListVOList);
return interfaceInfoListVO;
}).collect(Collectors.toList());
vo.setInterfaceInfoList(interfaceInfoListVOList);
return success(vo);
}
@ -182,4 +206,38 @@ public class GatewayServerController extends BaseController {
public AjaxResult updateStatus(@Validated @RequestBody UpdateDataStatusDTO dto) {
return toAjax(gatewayServerService.updateGatewayServerStatusByIds(dto.getIds(), GatewayDataStatus.getByCode(dto.getStatus())));
}
/**
* 查询可绑定的策略列表状态为启用的,不分页
*/
@GetMapping("/bindableList")
public List<GatewayServerListVO> bindableList(QueryGatewayServerDTO dto)
{
GatewayServer gatewayServer = new GatewayServer();
gatewayServer.setStatus(GatewayDataStatus.ENABLE.getCode());
gatewayServer.setServiceModel(dto.getServiceModel());
gatewayServer.setAppCode(AppUtils.getAppCodeFromRequestHeader());
Map<String, Object> params = new HashMap<>(8);
params.put("ids",dto.getIds());
params.put("excludedIds",dto.getExcludedIds());
gatewayServer.setParams(params);
List<GatewayServer> list = gatewayServerService.selectGatewayServerList(gatewayServer);
// 如果是路由模式的服务查询对应的路由服务信息
Collection<Long> routeIds = list.stream().filter(item -> GatewayServiceModel.ROUTE.getCode().equals(item.getServiceModel()))
.map(GatewayServer::getRouteId)
.collect(Collectors.toSet());
List<GatewayRoute> routeList = gatewayRouteService.selectGatewayRouteByIds(routeIds);
Map<Long, String> routeIdAndNameMap = routeList.stream().collect(Collectors.toMap(GatewayRoute::getId, GatewayRoute::getRouteName));
return list.stream().map(item -> {
GatewayServerListVO vo = new GatewayServerListVO();
vo.setId(item.getId());
vo.setServerName(item.getServerName());
vo.setServerAddress(GatewayServiceModel.ROUTE.getCode().equals(item.getServiceModel()) ?
routeIdAndNameMap.get(item.getRouteId()) : item.getServerAddress());
vo.setStatus(item.getStatus());
vo.setServiceModel(item.getServiceModel());
vo.setRouteId(item.getRouteId());
return vo;
}).collect(Collectors.toList());
}
}

View File

@ -8,6 +8,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
@ -47,6 +48,7 @@ public class InsertGatewayInterfaceInfoDTO {
@ApiModelProperty("接口文档(文档地址)")
private String document;
@NotNull(message = "网关服务不能为空")
@ApiModelProperty("网关服务id")
private Long serverId;

View File

@ -0,0 +1,32 @@
package com.sf.service.gateway.domain.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 功能描述:
* 查询网关服务
* @author a_kun
* @date 2024/4/23 10:38
*/
@ApiModel("查询网关服务DTO")
@Data
public class QueryGatewayServerDTO {
@ApiModelProperty("ids")
private List<Long> ids;
@ApiModelProperty("状态0停用 1启用")
private String status;
@ApiModelProperty("需要排除的id")
private List<Long> excludedIds;
@ApiModelProperty("服务模式NORMAL=普通模式ROUTE=路由模式)")
private String serviceModel;
}

View File

@ -50,6 +50,7 @@ public class UpdateGatewayInterfaceInfoDTO {
@ApiModelProperty("接口文档(文档地址)")
private String document;
@NotNull(message = "网关服务不能为空")
@ApiModelProperty("网关服务id")
private Long serverId;

View File

@ -27,6 +27,9 @@ public class GatewayServerDetailedVO {
@ApiModelProperty("服务地址,路由模式为路由名称")
private String serverAddress;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("服务状态")
private String status;

View File

@ -29,6 +29,9 @@ public class GatewayServerListVO {
@ApiModelProperty("服务地址,路由模式为路由名称")
private String serverAddress;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("服务状态")
private String status;

View File

@ -1,5 +1,7 @@
package com.sf.service.gateway.enums;
import org.springframework.util.StringUtils;
/**
* 支持的加密算法
* 目前支持 ECCRSA 和国密SM2
@ -33,9 +35,11 @@ public enum EncryptionAlgorithm
}
public static EncryptionAlgorithm getByCode(String code){
for (EncryptionAlgorithm value : EncryptionAlgorithm.values()) {
if (value.code.equals(code)){
return value;
if (StringUtils.hasText(code)){
for (EncryptionAlgorithm value : EncryptionAlgorithm.values()) {
if (value.code.equals(code)){
return value;
}
}
}
return null;

View File

@ -4,6 +4,7 @@ import com.sf.service.gateway.domain.GatewayInterfaceLinkStrategy;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -29,6 +30,8 @@ public interface GatewayInterfaceLinkStrategyMapper {
void deleteByInterfaceIds(@Param("interfaceIds") Collection<Long> interfaceIds);
List<GatewayInterfaceLinkStrategy> selectGatewayInterfaceLinkStrategyByInterfaceIds(@Param("interfaceIds") Collection<Long> interfaceIds);
List<GatewayInterfaceLinkStrategy> selectGatewayInterfaceLinkStrategyByStrategyIds(@Param("strategyIds") Collection<Long> strategyIds);
}

View File

@ -1,13 +1,17 @@
package com.sf.service.gateway.service.impl;
import apijson.JSON;
import com.sf.common.utils.DateUtils;
import com.sf.common.utils.SecurityUtils;
import com.sf.service.gateway.domain.GatewayConfig;
import com.sf.service.gateway.enums.EncryptionAlgorithm;
import com.sf.service.gateway.enums.GatewayDataStatus;
import com.sf.service.gateway.mapper.GatewayConfigMapper;
import com.sf.service.gateway.service.IGatewayConfigService;
import com.sf.service.index.util.AppUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import java.util.Date;
@ -34,6 +38,7 @@ public class GatewayConfigServiceImpl implements IGatewayConfigService {
@Override
public void updateGatewayConfig(GatewayConfig gatewayConfig) {
checkInsertOrUpdateGatewayConfig(gatewayConfig);
String appCode = AppUtils.getAppCodeFromRequestHeader();
String username = SecurityUtils.getUsername();
Date nowDate = DateUtils.getNowDate();
@ -52,4 +57,37 @@ public class GatewayConfigServiceImpl implements IGatewayConfigService {
gatewayConfigMapper.updateByAppCodeSelective(gatewayConfig);
}
}
private void checkInsertOrUpdateGatewayConfig(GatewayConfig gatewayConfig) {
if (GatewayDataStatus.ENABLE.getCode().equals(gatewayConfig.getDataEncryptionStatus())){
EncryptionAlgorithm encryptionAlgorithm = EncryptionAlgorithm.getByCode(gatewayConfig.getEncryptionAlgorithm());
Assert.notNull(encryptionAlgorithm,"不支持的加密算法");
Assert.hasText(gatewayConfig.getPrivateKey(),"密钥内容不能为空");
if (EncryptionAlgorithm.RSA.equals(encryptionAlgorithm)){
Assert.hasText(gatewayConfig.getPublicKey(),"公钥内容不能为空");
}
}
if (GatewayDataStatus.ENABLE.getCode().equals(gatewayConfig.getApiCurrentLimitingStatus())){
Assert.notNull(gatewayConfig.getApiCurrentLimitingThreshold(),"限流值不能为空");
Assert.isTrue(gatewayConfig.getApiCurrentLimitingThreshold() >= 0,"限流值>=0");
// 页面没有,这里给个默认值
if (gatewayConfig.getApiCurrentLimitingTimeWindow() == null) {
gatewayConfig.setApiCurrentLimitingTimeWindow(1);
}else {
Assert.isTrue(gatewayConfig.getApiCurrentLimitingTimeWindow() >= 0,"限流窗口值>=0");
}
Assert.isTrue(JSON.isJSONObject(gatewayConfig.getApiCurrentLimitingDefaultResponse()),"请输入正确的JSON格式限流响应信息");
}
if (GatewayDataStatus.ENABLE.getCode().equals(gatewayConfig.getAppCurrentLimitingStatus())){
Assert.notNull(gatewayConfig.getAppCurrentLimitingThreshold(),"限流值不能为空");
Assert.isTrue(gatewayConfig.getAppCurrentLimitingThreshold() >= 0,"限流值>=0");
// 页面没有,这里给个默认值
if (gatewayConfig.getAppCurrentLimitingTimeWindow() == null) {
gatewayConfig.setAppCurrentLimitingTimeWindow(1);
}else {
Assert.isTrue(gatewayConfig.getAppCurrentLimitingTimeWindow() >= 0,"限流窗口值>=0");
}
Assert.isTrue(JSON.isJSONObject(gatewayConfig.getAppCurrentLimitingDefaultResponse()),"请输入正确的JSON格式限流响应信息");
}
}
}

View File

@ -11,6 +11,7 @@ import com.sf.service.gateway.domain.GatewayStrategy;
import com.sf.service.gateway.domain.dto.InsertGatewayInterfaceInfoDTO;
import com.sf.service.gateway.domain.dto.UpdateGatewayInterfaceInfoDTO;
import com.sf.service.gateway.enums.GatewayDataStatus;
import com.sf.service.gateway.enums.GatewayStrategyType;
import com.sf.service.gateway.mapper.GatewayInterfaceInfoMapper;
import com.sf.service.gateway.mapper.GatewayInterfaceLinkStrategyMapper;
import com.sf.service.gateway.service.IGatewayInterfaceInfoService;
@ -221,7 +222,7 @@ public class GatewayInterfaceInfoServiceImpl implements IGatewayInterfaceInfoSer
List<GatewayStrategy> strategyList = gatewayStrategyService.selectGatewayStrategyByIds(strategyIds);
Map<String, List<GatewayStrategy>> groupByStrategyTypeMap = strategyList.stream().collect(Collectors.groupingBy(GatewayStrategy::getStrategyType));
groupByStrategyTypeMap.forEach((type,strategies) ->{
Assert.isTrue(strategies.size() == 1,type + "类型只能选择一个!");
Assert.isTrue(strategies.size() == 1, Objects.requireNonNull(GatewayStrategyType.getByCode(type)).getInfo() + "类型只能选择一个!");
});
}

View File

@ -123,12 +123,15 @@ public class GatewayRouteServiceImpl implements IGatewayRouteService
default:
break;
}
}
if (GatewayRouteType.WEIGHT_ROUTE.equals(routeType)){
Assert.isTrue(sumWeight == 100,"权重总值为100");
}
if (GatewayDataStatus.ENABLE.getCode().equals(dto.getRouteStatusActiveMonitoring())){
Long routeActiveMonitoringTimeout = dto.getRouteActiveMonitoringTimeout();
Assert.notNull(routeActiveMonitoringTimeout,"路由探活超时时间不能为空");
Assert.isTrue(0 <= routeActiveMonitoringTimeout && routeActiveMonitoringTimeout <= 30000,"路由探活超时时间在0-30000之间");
}
}
/**

View File

@ -4,10 +4,16 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import apijson.JSON;
import cn.hutool.core.collection.CollUtil;
import com.sf.common.utils.DateUtils;
import com.sf.service.gateway.domain.GatewayInterfaceLinkStrategy;
import com.sf.service.gateway.domain.GatewayServer;
import com.sf.service.gateway.domain.GatewayStrategy;
import com.sf.service.gateway.enums.GatewayDataStatus;
import com.sf.service.gateway.enums.GatewayStrategyType;
import com.sf.service.gateway.mapper.GatewayInterfaceLinkStrategyMapper;
import com.sf.service.gateway.mapper.GatewayStrategyMapper;
import com.sf.service.gateway.service.IGatewayStrategyService;
import lombok.extern.slf4j.Slf4j;
@ -31,6 +37,9 @@ public class GatewayStrategyServiceImpl implements IGatewayStrategyService
@Autowired
private GatewayStrategyMapper gatewayStrategyMapper;
@Autowired
private GatewayInterfaceLinkStrategyMapper gatewayInterfaceLinkStrategyMapper;
/**
* 查询策略管理
*
@ -118,15 +127,15 @@ public class GatewayStrategyServiceImpl implements IGatewayStrategyService
Integer currentLimitingThreshold = gatewayStrategy.getCurrentLimitingThreshold();
Integer currentLimitingTimeWindow = gatewayStrategy.getCurrentLimitingTimeWindow();
String currentLimitingResponse = gatewayStrategy.getCurrentLimitingResponse();
if (currentLimitingThreshold == null){
gatewayStrategy.setCurrentLimitingThreshold(1);
}
if (currentLimitingTimeWindow == null){
Assert.notNull(currentLimitingThreshold,"限流值不能为空");
Assert.isTrue(currentLimitingThreshold >= 0,"限流值>=0");
// 页面没有,这里给个默认值
if (currentLimitingTimeWindow == null) {
gatewayStrategy.setCurrentLimitingTimeWindow(1);
}else {
Assert.isTrue(currentLimitingTimeWindow >= 0,"限流窗口值>=0");
}
if (!StringUtils.hasText(currentLimitingResponse)){
gatewayStrategy.setCurrentLimitingResponse("{}");
}
Assert.isTrue(JSON.isJSONObject(currentLimitingResponse),"请输入正确的JSON格式限流响应信息");
}
/**
@ -139,18 +148,13 @@ public class GatewayStrategyServiceImpl implements IGatewayStrategyService
Integer circuitBreakerTimeWindow = gatewayStrategy.getCircuitBreakerTimeWindow();
Integer circuitBreakerRecoveryInterval = gatewayStrategy.getCircuitBreakerRecoveryInterval();
String circuitBreakerResponse = gatewayStrategy.getCircuitBreakerResponse();
if (circuitBreakerThreshold == null){
gatewayStrategy.setCircuitBreakerThreshold(1);
}
if (circuitBreakerTimeWindow == null){
gatewayStrategy.setCircuitBreakerTimeWindow(1);
}
if (circuitBreakerRecoveryInterval == null){
gatewayStrategy.setCircuitBreakerRecoveryInterval(1);
}
if (!StringUtils.hasText(circuitBreakerResponse)){
gatewayStrategy.setCircuitBreakerResponse("{}");
}
Assert.notNull(circuitBreakerThreshold,"接口调用失败阈值不能为空");
Assert.isTrue(circuitBreakerThreshold >= 0,"限流值>=0");
Assert.notNull(circuitBreakerTimeWindow,"调用失败阈值对应的单位时间不能为空");
Assert.isTrue(circuitBreakerTimeWindow >= 0,"调用失败阈值对应的单位时间>=0");
Assert.notNull(circuitBreakerRecoveryInterval,"熔断后恢复的时间间隔不能为空");
Assert.isTrue(circuitBreakerRecoveryInterval >= 0,"熔断后恢复的时间间隔>=0");
Assert.isTrue(JSON.isJSONObject(circuitBreakerResponse),"请输入正确的JSON格式熔断响应信息");
}
/**
@ -182,6 +186,7 @@ public class GatewayStrategyServiceImpl implements IGatewayStrategyService
if (ids == null || ids.length == 0) {
return 0;
}
checkDeleteConditions(CollUtil.newHashSet(ids));
return gatewayStrategyMapper.deleteGatewayStrategyByIds(ids);
}
@ -197,9 +202,14 @@ public class GatewayStrategyServiceImpl implements IGatewayStrategyService
if (id == null) {
return 0;
}
checkDeleteConditions(Collections.singleton(id));
return gatewayStrategyMapper.deleteGatewayStrategyById(id);
}
private void checkDeleteConditions(Collection<Long> ids) {
List<GatewayInterfaceLinkStrategy> linkList = gatewayInterfaceLinkStrategyMapper.selectGatewayInterfaceLinkStrategyByStrategyIds(ids);
Assert.isTrue(CollUtil.isEmpty(linkList),"策略已关联接口,删除失败");}
@Override
public int updateGatewayStrategyStatusByIds(List<Long> ids, GatewayDataStatus status) {
if (CollectionUtils.isEmpty(ids) || status == null){

View File

@ -67,6 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="created != null">created,</if>
<if test="modified != null">modified,</if>
<if test="uriRegular != null">uri_regular,</if>
<if test="serverId != null">server_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="interfaceName != null and interfaceName != ''">#{interfaceName},</if>
@ -82,6 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="created != null">#{created},</if>
<if test="modified != null">#{modified},</if>
<if test="uriRegular != null">#{uriRegular},</if>
<if test="serverId != null">#{serverId},</if>
</trim>
</insert>
@ -98,6 +100,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="modified != null">modified = #{modified},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="uriRegular != null">uri_regular = #{uriRegular},</if>
<if test="serverId != null">server_id = #{serverId},</if>
</trim>
where id = #{id}
</update>

View File

@ -28,6 +28,15 @@
#{id}
</foreach>
</select>
<select id="selectGatewayInterfaceLinkStrategyByStrategyIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from Gateway_interface_link_strategy
where strategy_id in
<foreach item="id" collection="strategyIds" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from Gateway_interface_link_strategy
@ -60,7 +69,7 @@
</insert>
<insert id="batchInsertGatewayInterfaceLinkStrategy">
insert into Gateway_interface_link_strategy (interfaceId,strategyId)
insert into Gateway_interface_link_strategy (interface_id,strategy_id)
values
<foreach collection="linkList" index="" item="link" separator=",">
(

View File

@ -31,9 +31,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="serverName != null and serverName != ''"> and server_name like concat('%', #{serverName}, '%')</if>
<if test="serverAddress != null and serverAddress != ''"> and server_address = #{serverAddress}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="serviceModel != null"> and service_model = #{serviceModel}</if>
<if test="created != null "> and created = #{created}</if>
<if test="appCode != null "> and app_code = #{appCode}</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
<if test="params.ids != null and params.ids.size() > 0">
and id in
<foreach item="id" collection="params.ids" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="params.excludedIds != null and params.excludedIds.size() > 0">
and id not in
<foreach item="id" collection="params.excludedIds" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</where>
</select>