mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-22 12:48:59 +08:00
commit
d9ba8b8621
@ -18,7 +18,8 @@ public class InterceptorConfiguration implements WebMvcConfigurer {
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
//注册拦截器
|
||||
registry.addInterceptor(bloomInterceptorHandler())
|
||||
.addPathPatterns("/app-api/v1/goods/**");
|
||||
.addPathPatterns("/app-api/v1/goods/**")
|
||||
.excludePathPatterns("/app-api/v1/goods/sku/**");
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
@ -34,7 +34,13 @@ public class BloomFilterInterceptor implements HandlerInterceptor {
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
String currentUrl = request.getRequestURI();
|
||||
PathMatcher matcher = new AntPathMatcher();
|
||||
Map<String, String> pathVariable = matcher.extractUriTemplateVariables("/app-api/v1/goods/{id}", currentUrl);
|
||||
Map<String, String> pathVariable;
|
||||
try {
|
||||
pathVariable = matcher.extractUriTemplateVariables("/app-api/v1/goods/{id}", currentUrl);
|
||||
} catch (IllegalStateException e) {
|
||||
// 路径不匹配则放行
|
||||
return true;
|
||||
}
|
||||
if (bloomRedisService.includeByBloomFilter(PmsConstants.PRODUCT_REDIS_BLOOM_FILTER, pathVariable.get("id"))) {
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user