34 lines
932 B
C#
34 lines
932 B
C#
using Asp.Versioning;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using StoreHub.Framework.Commons;
|
|
using System.ComponentModel;
|
|
|
|
namespace StoreHub.Controllers
|
|
{
|
|
[ApiController]
|
|
[Description("测试温度")]
|
|
[ApiVersion("1.0")]
|
|
[Route("api/v{version:apiVersion}/[controller]")]
|
|
public class WeatherForecastController : ControllerBase
|
|
{
|
|
private static readonly string[] Summaries =
|
|
[
|
|
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
|
];
|
|
|
|
[HttpGet(Name = "GetWeatherForecast")]
|
|
public ApiResult<IEnumerable<WeatherForecast>> Get()
|
|
{
|
|
IEnumerable<WeatherForecast> data = Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
|
{
|
|
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
|
TemperatureC = Random.Shared.Next(-20, 55),
|
|
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
|
})
|
|
.ToArray();
|
|
|
|
return ApiResult.Success(data);
|
|
}
|
|
}
|
|
}
|