✨ Introducing new features. close #3230 为单独某个接口设置网关超时的时间的实现
This commit is contained in:
1 parent
6c1cadadbe
commit
0ac7776cbb
3 files changed
+13
-1
No files matched your search
+3
@@ -85,6 +85,9 @@ public class SysRouteConf extends Model<SysRouteConf> {
|
||||
@ApiModelProperty(value = "排序值")
|
||||
private Integer order;
|
||||
|
||||
@ApiModelProperty(value = "元数据")
|
||||
private String metadata;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
||||
+2
-1
@@ -40,6 +40,7 @@ import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
@@ -74,7 +75,7 @@ public class DynamicRouteInitRunner {
|
||||
vo.setFilters(filterObj.toList(FilterDefinition.class));
|
||||
JSONArray predicateObj = JSONUtil.parseArray(route.getPredicates());
|
||||
vo.setPredicates(predicateObj.toList(PredicateDefinition.class));
|
||||
|
||||
vo.setMetadata(JSONUtil.toBean(route.getMetadata(), Map.class));
|
||||
log.info("加载路由ID:{},{}", route.getRouteId(), vo);
|
||||
redisTemplate.setHashValueSerializer(new Jackson2JsonRedisSerializer<>(RouteDefinitionVo.class));
|
||||
redisTemplate.opsForHash().put(CacheConstants.ROUTE_KEY, route.getRouteId(), vo);
|
||||
|
||||
+8
@@ -116,6 +116,13 @@ public class SysRouteConfServiceImpl extends ServiceImpl<SysRouteConfMapper, Sys
|
||||
if (order != null) {
|
||||
vo.setOrder(Integer.parseInt(String.valueOf(order)));
|
||||
}
|
||||
|
||||
Object metadata = map.get("metadata");
|
||||
if (metadata != null) {
|
||||
Map<String, Object> metadataMap = JSONUtil.toBean(String.valueOf(metadata), Map.class);
|
||||
vo.setMetadata(metadataMap);
|
||||
}
|
||||
|
||||
redisTemplate.setHashValueSerializer(new Jackson2JsonRedisSerializer<>(RouteDefinitionVo.class));
|
||||
redisTemplate.opsForHash().put(CacheConstants.ROUTE_KEY, vo.getId(), vo);
|
||||
routeDefinitionVoList.add(vo);
|
||||
@@ -135,6 +142,7 @@ public class SysRouteConfServiceImpl extends ServiceImpl<SysRouteConfMapper, Sys
|
||||
routeConf.setPredicates(JSONUtil.toJsonStr(vo.getPredicates()));
|
||||
routeConf.setOrder(vo.getOrder());
|
||||
routeConf.setUri(vo.getUri().toString());
|
||||
routeConf.setMetadata(JSONUtil.toJsonStr(vo.getMetadata()));
|
||||
return routeConf;
|
||||
}).collect(Collectors.toList());
|
||||
this.saveBatch(routeConfList);
|
||||
|
||||
Reference in new issue
Block a user