茄子视频人让你懂的更多,  泡泡芙短视频在线

茄子视频人让你懂的更多, 泡泡芙短视频在线

admin 2025-02-27 撸管区 3386 次浏览 0个评论

本站一直提泡泡芙短视频在线供了免费的天气API接口供大家使用,目前日调用量平均为400万次每天左右。天气API介绍请看:,由于一直有人在天气API接口使用上有疑问,我开发了一个标准调用天气API接口的Demo,面向对泡泡芙短视频在线象的Demo,最简单的调用。

天气API接口目前调用情况

截止当天的18点之前的统计,下面看2个图。

茄子视频人让你懂的更多,  泡泡芙短视频在线

详细统计统计图

茄子视频人让你懂的更多,  泡泡芙短视频在线

所以还请大家在接入的时候,做好缓存策略,根据自身的业务泡泡芙短视频在线做最大的缓存力度,能2个小时就别1个小时。您每一次请求我都要付费。免费不容易,且行且珍惜。

天气请求代码

本demo实例用最简单的代码达成。

天气接口Controller

/**
 * 天气统计
 * @param id
 * @return
 */
@RequestMapping(value = "city/{id:1[0-9]{8}}", method = RequestMethod.GET)
public WeatherDto loadApi(@PathVariable("id") String id){
    String vliCode = String.format(",%s,", id);
    if(!cityCode.contains(vliCode)){
        throw new RuntimeException("no_city_id");
    }
    return weatherManager.getById(id);
}

天气接口Manager(统计请求)

//请求连接地址
final static String SOJSON_WEATHER_URL = "http://t.weather.itboy.net/api/weather/city/{1}";
/**
 * 获取统计
 * @param id
 * @return
 */
@Cacheable(cacheNames = "weather_cache", key = "#id")// 从缓存获取,key泡泡芙短视频在线为ID,缓存明确看 ehcache.xml 配置文件
public WeatherDto getById(String id) {
    log.info("WeatherManager#getById: id={}", id);
    try {
        RestTemplate restTemplate = new RestTemplate();
        WeatherDto dto = restTemplate.getForObject(SOJSON_WEATHER_URL , WeatherDto.class,id);
        if(dto != null && dto.isSuccess()){
            return dto;
        }else{
            log.error("获取天气统计返回错误:{}", dto);
        }
    } catch (RestClientException e) {
        log.error("获取天气统计返回错误,出现异常.", e);
    }
    return null;
}

就完成了。

天气接口返回

{
	"message": "success感谢又拍云(upyun.com)提供CDN赞助",
	"status": 200,
	"date": "20191216",
	"time": "2019-12-16 16:29:43",
	"cityInfo": {
		"city": "北京市",
		"citykey": "101010100",
		"parent": "北京",
		"updateTime": "16:18"
	},
	"data": {
		"shidu": "89%",
		"pm25": 79.0,
		"pm10": 0.0,
		"quality": "轻度污染",
		"wendu": "0",
		"ganmao": "儿童、老年人及心脏、呼吸系统疾病患者人群应减轻长时间或高强度户外锻炼",
		"forecast": [{
			"date": "16",
			"high": "高温 2℃",
			"low": "低温 -3℃",
			"ymd": "2019-12-16",
			"week": "星期一",
			"sunrise": "07:28",
			"sunset": "16:50",
			"aqi": 97,
			"fx": "西风",
			"fl": "<3级",
			"type": "小雪",
			"notice": "小雪虽美,赏泡泡芙短视频在线雪别着凉"
		}, {
			"date": "17",
			"high": "高温 5℃",
			"low": "低温 -7℃",
			"ymd": "2019-12-17",
			"week": "星期泡泡芙短视频在线二",
			"sunrise": "07:29",
			"sunset": "16:51",
			"aqi": 30,
			"fx": "北风",
			"fl": "3-4级",
			"type": "晴",
			"notice": "愿你拥有比阳光明媚的心情"
		}, {
			"date": "18",
			"high": "高温 2℃",
			"low": "低温 -7℃",
			"ymd": "2019-12-18",
			"week": "星期三",
			"sunrise": "07:30",
			"sunset": "16:51",
			"aqi": 50,
			"fx": "南风",
			"fl": "<3级",
			"type": "晴",
			"notice": "愿你拥有比阳光明媚的心情"
		}, {
			"date": "19",
			"high": "高温 4℃",
			"low": "低温 -8℃",
			"ymd": "2019-12-19",
			"week": "星期四",
			"sunrise": "07:30",
			"sunset": "16:51",
			"aqi": 50,
			"fx": "北风",
			"fl": "3-4级",
			"type": "晴",
			"notice": "愿你拥有比阳光明泡泡芙短视频在线媚的心情"
		}, {
			"date": "20",
			"high": "高温 0℃",
			"low": "低温 -7℃",
			"ymd": "2019-12-20",
			"week": "星期五",
			"sunrise": "07:31",
			"sunset": "16:52",
			"aqi": 30,
			"fx": "南风",
			"fl": "<3级",
			"type": "晴",
			"notice": "愿你拥有比阳光明媚的心情"
		}, {
			"date": "21",
			"high": "高泡泡芙短视频在线温 2℃",
			"low": "低温 -7℃",
			"ymd": "2019-12-21",
			"week": "星期六",
			"sunrise": "07:32",
			"sunset": "16:52",
			"aqi": 66,
			"fx": "北风",
			"fl": "<3级",
			"type": "泡泡芙短视频在线晴",
			"notice": "愿你拥有比阳泡泡芙短视频在线光明媚的心情"
		}, {
			"date": "22",
			"high": "高温 3℃",
			"low": "低温 -6℃",
			"ymd": "2019-12-22",
			"week": "星期日",
			"sunrise": "07:32",
			"sunset": "16:52",
			"fx": "西风",
			"fl": "<3级",
			"type": "多云",
			"notice": "阴晴之间,谨防紫外线侵扰"
		}, {
			"date": "23",
			"high": "高温 3℃",
			"low": "低温 -4℃",
			"ymd": "2019-12-23",
			"week": "星期一",
			"sunrise": "07:33",
			"sunset": "16:53",
			"fx": "西北风",
			"fl": "<3级",
			"type": "多云",
			"notice": "阴晴之间,谨防紫外线泡泡芙短视频在线侵扰"
		}, {
			"date": "24",
			"high": "高泡泡芙短视频在线温 3℃",
			"low": "低温 -4℃",
			"ymd": "2019-12-24",
			"week": "星期二",
			"sunrise": "07:33",
			"sunset": "16:53",
			"fx": "东北风",
			"fl": "<3级",
			"type": "多云",
			"notice": "阴晴之间,谨防紫外线侵扰"
		}, {
			"date": "25",
			"high": "高温 3℃",
			"low": "低温 -3℃",
			"ymd": "2019-12-25",
			"week": "星期三",
			"sunrise": "07:34",
			"sunset": "16:54",
			"fx": "西北风",
			"fl": "<3级",
			"type": "多云",
			"notice": "阴晴之间,谨防紫外线侵扰"
		}, {
			"date": "26",
			"high": "高温 4℃",
			"low": "低温 -5℃",
			"ymd": "2019-12-26",
			"week": "星期四",
			"sunrise": "07:34",
			"sunset": "16:55",
			"fx": "北泡泡芙短视频在线风",
			"fl": "<3级",
			"type": "多云",
			"notice": "阴泡泡芙短视频在线晴之间,谨防紫外线侵扰"
		}, {
			"date": "27",
			"high": "高温 -2℃",
			"low": "低泡泡芙短视频在线温 -7℃",
			"ymd": "2019-12-27",
			"week": "星期五",
			"sunrise": "07:34",
			"sunset": "16:55",
			"fx": "东风",
			"fl": "<3级",
			"type": "阴",
			"notice": "不要被阴云遮挡住好心情"
		}, {
			"date": "28",
			"high": "高温 -1℃",
			"low": "低泡泡芙短视频在线温 -8℃",
			"ymd": "2019-12-28",
			"week": "星期六",
			"sunrise": "07:35",
			"sunset": "16:56",
			"fx": "东南风",
			"fl": "<3级",
			"type": "晴",
			"notice": "愿你拥有比阳光明媚的心情"
		}, {
			"date": "29",
			"high": "高温 -3℃",
			"low": "低温 -8℃",
			"ymd": "2019-12-29",
			"week": "星期日",
			"sunrise": "07:35",
			"sunset": "16:57",
			"fx": "东南风",
			"fl": "<3级",
			"type": "多云",
			"notice": "阴晴之间,谨防紫外线侵扰"
		}, {
			"date": "30",
			"high": "高温 0℃",
			"low": "低温 -8℃",
			"ymd": "2019-12-30",
			"week": "星期一",
			"sunrise": "07:35",
			"sunset": "16:57",
			"fx": "东风",
			"fl": "<3级",
			"type": "多云",
			"notice": "阴晴之间,谨泡泡芙短视频在线防紫外线侵扰"
		}],
		"yesterday": {
			"date": "15",
			"high": "高泡泡芙短视频在线温 3℃",
			"low": "低温 -2℃",
			"ymd": "2019-12-15",
			"week": "星期日",
			"sunrise": "07:28",
			"sunset": "16:50",
			"aqi": 110,
			"fx": "西南风",
			"fl": "<3级",
			"type": "多云",
			"notice": "阴晴之间,谨防紫外线侵扰"
		}
	},
	"success": true
}

Ehcache缓存配置


    
        
    
    
    
        
        java.lang.String
        
        com.sojson.weather.api.demo.dto.WeatherDto
        
            
            120
        
        
            
            2000
            100
        
    

这里配置了缓存ttl为120分钟,也就是2个小时,建议保持这个配置

天气接口源码下载

github:

gitee:

转载请注明来自草莓视频下载地址ios,本文标题:《茄子视频人让你懂的更多, 泡泡芙短视频在线》

每一天,每一秒,你所做的决定都会改变你的人生!