package com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.sdgk;

import cn.hutool.extra.spring.SpringUtil;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.common.constatnt.SdgkConstants;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.AuthMapper;
import feign.RequestInterceptor;
import feign.RequestTemplate;

/**
 * 隧道管控，接口head处理
 * @author rfx
 * @date 2024/11/17
 */
public class SdgkClientFeignIntercept implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
        //跳过登录接口
        if(!requestTemplate.url().equals(SdgkConstants.LOGIN_INTERFACE)){
            AuthMapper authMapper = SpringUtil.getBean(AuthMapper.class);
            String token = authMapper.getSdgkLoginToken();
            //请求头中添加Authorization
            requestTemplate.header(SdgkConstants.AUTH_HEADER,token);
        }
    }
}
