package cn.superdesk.uniorder.openapicall._thirdpart.szhtxx.electronicInvoice.security;

import cn.superdesk.uniorder.openapicall.superdeskuniorder.service.OctlifeUniOrderCallApiService;
import com.github.lianjiatech.retrofit.spring.boot.interceptor.BasePathMatchInterceptor;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
import okhttp3.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @Description: Java类作用描述
 * @Author: linjinyu
 * @CreateDate: 2022/3/28 1:18 下午
 * @UpdateUser: linjinyu
 * @UpdateDate: 2022/3/28 1:18 下午
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@Component
public class SzhtxxElectronicInvoiceSignInterceptor extends BasePathMatchInterceptor {

//    @Autowired
//    private OctlifeUniOrderCallApiService octlifeUniOrderCallApiService;

    private String accessKeyId;
    private String accessKeySecret;

    public void setAccessKeyId(String accessKeyId) {
        this.accessKeyId = accessKeyId;
    }

    public void setAccessKeySecret(String accessKeySecret) {
        this.accessKeySecret = accessKeySecret;
    }

    /**
     * 在这里只想解决一个问题
     *
     * @param chain
     * @return
     * @throws IOException
     */
    @Override
    public Response doIntercept(Chain chain) throws IOException {

//		String accessToken = octlifeUniOrderCallApiService.loginBySupplier(AnLongUtils.getLong(accessKeyId), accessKeySecret);
//		String accessToken = "";

//		Request request = chain.request();
//		Request newReq = request.newBuilder().post()
//				.addHeader("accessKeyId", accessKeyId)
//				.addHeader("accessKeySecret", accessKeySecret)
////				.addHeader("token", accessToken)
//				.build();
//		return chain.proceed(newReq);

        Request request = chain.request();

        return chain.proceed(request);
    }
}