package com.develop.common.data_repo.net.interceptor

import com.blankj.utilcode.util.AppUtils
import com.develop.base.ext.getSN
import com.develop.base.util.MMkvUtils
import com.develop.common.tag.API_TOKEN
import com.drake.net.interceptor.RequestInterceptor
import com.drake.net.request.BaseRequest

/** 请求拦截器, 一般用于添加全局参数 */
class FoodRequestInterceptor : RequestInterceptor {

    /** 本方法每次请求发起都会调用, 这里添加的参数可以是动态参数 */
    override fun interceptor(request: BaseRequest) {
        val token = MMkvUtils.getString(API_TOKEN) ?: ""
        request.apply {
            addHeader("sn", getSN())
            addHeader("apkVersion", AppUtils.getAppVersionName())
            addHeader("mcuVersion", "1.0")
            addHeader("Connection","close")
            addHeader("token", token)
        }
    }
}