package com.cico.nest.lcdp.boot.core.system.context;

import com.cico.nest.lcdp.boot.core.system.service.user.AdminUserService;
import com.cico.nest.lcdp.boot.security.config.SecurityProperties;
import com.cico.nest.lcdp.framework.common.enums.WebFilterOrderEnum;
import jakarta.annotation.Resource;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zws
 * @date 2024/7/26
 */

@Configuration
public class LcdpGlobalContextConfig {

    @Resource
    private SecurityProperties securityProperties;
    @Resource
    private AdminUserService adminUserService;


    @Bean
    public FilterRegistrationBean<LcdpGlobalContextFilter> lcdpGlobalContextFilterFilter(){
        FilterRegistrationBean<LcdpGlobalContextFilter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(new LcdpGlobalContextFilter(securityProperties, adminUserService));
        registrationBean.setOrder(WebFilterOrderEnum.GLOBAL_CONTEXT_FILTER);
        return registrationBean;
    }


}
