using System.Collections.Generic; using System.Threading.Tasks; using Furion.RemoteRequest.Extensions; namespace Myshipping.Core; /// /// 天气预报工具类 /// public static class WeatherUtil { private static readonly string _getWeatherUrl = "http://wthrcdn.etouch.cn/weather_mini"; public static async Task GetWeatherInfo(string cityName = "北京") { var weatherOutPut = await $"{_getWeatherUrl}?city={cityName}".SetClient("wthrcdn").GetAsAsync(); if (weatherOutPut.Status != 1000 || weatherOutPut.Desc != "OK") { return new WeatherInfoOutPut { Success = false, Desc = weatherOutPut.Desc }; } weatherOutPut.Data.Success = true; return weatherOutPut.Data; } } /// /// 天气信息 /// public class WeatherInfo { /// /// 时间 /// public string Date { get; set; } /// /// 最高温度 /// public string High { get; set; } /// /// 风力 /// public string Fengli { get; set; } /// /// 最低温度 /// public string Low { get; set; } /// /// 分向 /// public string Fengxiang { get; set; } /// /// 类型 /// public string Type { get; set; } } public class WeatherInfoOutPut { /// /// 昨日天气 /// public WeatherInfo Yesterday { get; set; } /// /// 城市 /// public string City { get; set; } /// /// 未来五天天气 /// public List Forecast { get; set; } /// /// 感冒 /// public string Ganmao { get; set; } /// /// 温度 /// public string Wendu { get; set; } /// /// 是否成功 /// public bool Success { get; set; } /// /// 失败描述 /// public string Desc { get; set; } } public class WeatherOutPut { /// /// 数据 /// public WeatherInfoOutPut Data { get; set; } /// /// 状态 /// public int Status { get; set; } /// /// 描述 /// public string Desc { get; set; } }