content: package io.github.xxyopen.novel.book.config;
  
  import io.github.xxyopen.novel.common.constant.ApiRouterConsts;
  import io.github.xxyopen.novel.config.interceptor.TokenParseInterceptor;
  import lombok.RequiredArgsConstructor;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
  import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  
  /**
   * Spring Web Mvc 相关配置不要加 @EnableWebMvc 注解，否则会导致 jackson 的全局配置失效。因为 @EnableWebMvc 注解会导致 WebMvcAutoConfiguration 自动配置失效
   *
   * @author xiongxiaoyang
   * @date 2022/5/18
   */
  @Configuration
  @RequiredArgsConstructor
  public class WebConfig implements WebMvcConfigurer {
  
      private final TokenParseInterceptor tokenParseInterceptor;
  
      @Override
      public void addInterceptors(InterceptorRegistry registry) {
  
          // Token 解析拦截器
          registry.addInterceptor(tokenParseInterceptor)
              // 拦截小说内容查询接口，需要解析 token 以判断该用户是否有权阅读该章节（付费章节是否已购买）
              .addPathPatterns(ApiRouterConsts.API_FRONT_BOOK_URL_PREFIX + "/content/*");
  
  
      }
  
  }
  