package org.xyzh.common.annotation.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.xyzh.common.annotation.resolver.HttpLoginArgumentResolver;

import java.util.List;

/**
 * @description    WebMvcConfig.java文件描述 Web MVC配置
 * @filename    WebMvcConfig.java
 * @author    yslg
 * @copyright xyzh
 * @since 2025-10-06
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    private final HttpLoginArgumentResolver httpLoginArgumentResolver;

    /**
     * 使用构造器注入
     * 通过接口抽象解决了循环依赖问题，不再需要@Lazy注解
     */
    public WebMvcConfig(HttpLoginArgumentResolver httpLoginArgumentResolver) {
        this.httpLoginArgumentResolver = httpLoginArgumentResolver;
    }

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
        resolvers.add(httpLoginArgumentResolver);
    }
}
