package com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.feign.intercept;

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

/**
 * @author zws
 * @date 2024/8/7
 */
public class XlwClientFeignIntercept implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
        //跳过登录接口
        if(!XlwConstants.LOGIN_INTERFACE_LIST.contains(requestTemplate.url())){
            AuthMapper authMapper = SpringUtil.getBean(AuthMapper.class);
            String token = authMapper.getXlwLoginToken();
            //请求头中添加sessionId
            requestTemplate.header(XlwConstants.AUTH_HEADER,token);
        }
    }
}
