package com.cretin.webservices.helper.translate

import com.cretin.webcore.exception.WholeException
import com.cretin.webcore.utils.GsonGet
import com.cretin.webdb.self.TranslateInfoResp
import org.springframework.web.client.RestTemplate

object TranslateNetworkHelper {

    /**
     * 翻译
     */
    fun getTranslate(restTemplate: RestTemplate?, content: String, from: String, to: String): TranslateInfoResp? {
        val transResult = TransApi().getTransResult(restTemplate, content, from, to)
        val resp = TranslateInfoResp()
        if (transResult?.from != null && transResult.to != null && transResult.trans_result != null) {
            val resultList = transResult.trans_result
            if (resultList != null && resultList.isNotEmpty()) {
                resp.origin = resultList[0].src
                resp.result = resultList[0].dst
            }
            resp.originLanguage = transResult.from
            resp.resultLanguage = transResult.to
            return resp
        }
        return null
    }

    fun covertToFanti() {
//        https://www.mxnzp.com/api/convert/zh?content=%E5%BD%93%E4%BD%A0%E8%80%81%E4%BA%86&app_id=xgjftdiauwetheop&app_secret=NlBselBJVUdDOVZKKyt5MXU0Ym5lUT09
    }
}
