Skip to content

Commit

Permalink
fix: 临时改动,修复登录无效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
flben233 committed Sep 18, 2024
1 parent 9cfdf84 commit 31abc1d
Showing 1 changed file with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
package org.shirakawatyu.handixikebackend.config;

import lombok.RequiredArgsConstructor;
import org.shirakawatyu.handixikebackend.config.interfaces.MatchableHandlerInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;
import java.util.function.Consumer;

/**
* @author ShirakawaTyu
*/
@Configuration
@RequiredArgsConstructor
public class MvcConfig implements WebMvcConfigurer {
private final List<MatchableHandlerInterceptor> interceptors;
// private final List<MatchableHandlerInterceptor> interceptors;

@Autowired
private LoginInterceptor loginInterceptor;
@Autowired
private SessionInterceptor sessionInterceptor;
@Autowired
private TimeInterceptor timeInterceptor;

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(sessionInterceptor)
.excludePathPatterns(sessionInterceptor.excludes())
.addPathPatterns(sessionInterceptor.includes());
registry.addInterceptor(timeInterceptor)
.excludePathPatterns(timeInterceptor.excludes())
.addPathPatterns(timeInterceptor.includes());
registry.addInterceptor(loginInterceptor)
.excludePathPatterns(loginInterceptor.excludes())
.addPathPatterns(loginInterceptor.includes());

Consumer<MatchableHandlerInterceptor> register = (i) -> registry.addInterceptor(i)
.excludePathPatterns(i.excludes())
.addPathPatterns(i.includes());

interceptors.forEach(register);
// Consumer<MatchableHandlerInterceptor> register = (i) -> registry.addInterceptor(i)
// .excludePathPatterns(i.excludes())
// .addPathPatterns(i.includes());
//
// interceptors.forEach(register);
}
}

0 comments on commit 31abc1d

Please sign in to comment.