提交 a621dfda 编写于 作者: sq3536's avatar sq3536

移除无效

上级 f45f7346
package cn.ibizlab.web.filter;
import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
/**
* 将应用实体映射到对应的系统服务接口
*/
@Component
public class webDataEntitySysApiMappingFilter extends ZuulFilter {
private static Map<String, String> AppDataEntitySysApiMapping = new HashMap<>();
@PostConstruct
private void initDataEntitySysApiMapping() {
AppDataEntitySysApiMapping.put("ibzdictitem", "dictapi");
AppDataEntitySysApiMapping.put("ibzdict", "dictapi");
}
@Override
public Object run() {
RequestContext context = RequestContext.getCurrentContext();
Object entity = context.get(FilterConstants.PROXY_KEY);
Object requestPath = context.get(FilterConstants.REQUEST_URI_KEY);
if (ObjectUtils.isEmpty(requestPath) || ObjectUtils.isEmpty(entity)) {
return null;
}
String sysApiPrefix = AppDataEntitySysApiMapping.get(entity);
if (StringUtils.isEmpty(sysApiPrefix)) {
return null;
}
context.put(FilterConstants.REQUEST_URI_KEY, String.format("/%s%s", sysApiPrefix,requestPath));
return null;
}
@Override
public String filterType() {
return FilterConstants.PRE_TYPE;
}
@Override
public int filterOrder() {
return FilterConstants.PRE_DECORATION_FILTER_ORDER + 1;
}
@Override
public boolean shouldFilter() {
return true;
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册