package qweather import ( "cc/db/model" ) var ( // 开发者密钥 c_DEVKEY = "ecac5888fd314a5d883c0f9126145969" // 生产环境密钥 c_PROKEY = "ecac5888fd314a5d883c0f9126145969" // 开发环境url c_DEVURL = "https://devapi.qweather.com/" // 生产环境url c_PROURL = "https://api.qweather.com/" // 版本号 c_VERSION = "v7/weather/" ) // makeURL 生成url func makeURL(dev bool, location_id int, weather_type_name string) (rv string, rer error) { // 获取位置信息 localtion := model.Localtion{ID: location_id} err := localtion.GetLocaltionByID() if err != nil { return "", err } if dev { rv = c_DEVURL } else { rv = c_PROURL } rv += c_VERSION rv += weather_type_name rv += "?key=" if dev { rv += c_DEVKEY } else { rv += c_PROKEY } rv += "&location=" rv += localtion.Code return }