package cn.stylefeng.guns.core.security;

import cn.stylefeng.roses.kernel.rule.util.HttpServletUtil;
import cn.stylefeng.roses.kernel.security.blackwhite.BlackWhiteValidateService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

@Component
@Slf4j
public class BlackWhiteInterceptor implements HandlerInterceptor {

    @Resource
    private BlackWhiteValidateService blackWhiteValidateService;

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {

        blackWhiteValidateService.totalValidate(HttpServletUtil.getRequestClientIp(request));

        return true;
    }

}
