package com.za.base

import com.za.common.GlobalData

object AppConfig {
    var isRelease = false

    // API 相关地址
    lateinit var BASE_URL: String        // API 主地址
    lateinit var IMG_BASE_URL: String    // 图片服务器地址
    lateinit var Resource_URL: String    // 资源服务器地址

    // H5 相关地址
    lateinit var TRAIN_URL: String       // 培训文档地址
    lateinit var DOCMENT_URL: String     // 中道资料地址

    /**
     * 正式环境配置
     */
    fun release() {
        isRelease = true

        // API 配置
        BASE_URL = "https://api.sinoassist.com"
        IMG_BASE_URL = "https://api.sinoassist.com"
        Resource_URL = "https://www.sinoassist.com/res"

        // H5 配置
        TRAIN_URL = "https://www.sinoassist.com/h5/supplier/dispatch/diverTrainDocment"
        DOCMENT_URL = "https://www.sinoassist.com/h5/supplier/dispatch/docmentList"
    }

    /**
     * 审核环境配置
     */
    fun review() {
        isRelease = true

        // API 配置
        BASE_URL = "http://interface.review.sino-assist.com"
        IMG_BASE_URL = "http://interface.review.sino-assist.com"
        Resource_URL = "https://www.sinoassist.com/res"
    }

    /**
     * CRM1 环境配置
     */
    fun crm1() {
        isRelease = false

        // API 配置
        BASE_URL = "https://api1.sino-assist.com"
        IMG_BASE_URL = "https://api1.sino-assist.com"
        Resource_URL = "https://crm1.sino-assist.com/res"

        // H5 配置
        TRAIN_URL = "https://crm1.sino-assist.com/h5/supplier/dispatch/diverTrainDocment"
        DOCMENT_URL = "https://crm1.sino-assist.com/h5/supplier/dispatch/docmentList"
    }

    /**
     * CRM2 环境配置
     */
    fun crm2() {
        isRelease = false

        // API 配置
        BASE_URL = "https://api2.sino-assist.com"
        IMG_BASE_URL = "https://api2.sino-assist.com"
        Resource_URL = "https://crm2.sino-assist.com/res"
    }

    /**
     * 获取培训文档完整地址
     * @param driverId 司机ID
     * @param keyword 关键字
     * @return 完整的培训文档URL
     */
    fun getTrainUrl(keyWord: String = ""): String {
        if (keyWord.isEmpty()) {
            return TRAIN_URL + "?token=${GlobalData.token}&driverId=${GlobalData.driverInfoBean?.userId}"
        }
        return TRAIN_URL + "?token=${GlobalData.token}&driverId=${GlobalData.driverInfoBean?.userId}&keyword=$keyWord"
    }

    /**
     * 获取中道资料完整地址
     * @param driverId 司机ID
     * @param keyword 关键字
     * @return 完整的中道资料URL
     */
    fun getDocmentUrl(keyWord: String = ""): String {
        if (keyWord.isEmpty()) {
            return DOCMENT_URL + "?token=${GlobalData.token}&driverId=${GlobalData.driverInfoBean?.userId}"
        }
        return DOCMENT_URL + "?token=${GlobalData.token}&driverId=${GlobalData.driverInfoBean?.userId}&keyword=$keyWord"
    }
}