WeatherForecastController.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using Hotline.Api.Sdk;
  2. using Hotline.Share.Dtos.Order;
  3. using Microsoft.AspNetCore.Mvc;
  4. namespace WebApplication1.Controllers
  5. {
  6. [ApiController]
  7. [Route("[controller]")]
  8. public class WeatherForecastController : ControllerBase
  9. {
  10. private static readonly string[] Summaries = new[]
  11. {
  12. "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
  13. };
  14. private readonly IHotlineClient _hotlineClient;
  15. private readonly ILogger<WeatherForecastController> _logger;
  16. public WeatherForecastController(
  17. IHotlineClient hotlineClient,
  18. ILogger<WeatherForecastController> logger)
  19. {
  20. _hotlineClient = hotlineClient;
  21. _logger = logger;
  22. }
  23. [HttpGet(Name = "GetWeatherForecast")]
  24. public IEnumerable<WeatherForecast> Get()
  25. {
  26. return Enumerable.Range(1, 5).Select(index => new WeatherForecast
  27. {
  28. Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
  29. TemperatureC = Random.Shared.Next(-20, 55),
  30. Summary = Summaries[Random.Shared.Next(Summaries.Length)]
  31. })
  32. .ToArray();
  33. }
  34. [HttpGet("test")]
  35. public async Task Test()
  36. {
  37. await _hotlineClient.DelayProvinceResultAsync(
  38. new DelayProvinceResultDto { IsPass = true, No = "123", Opinion = "aaa" }, HttpContext.RequestAborted);
  39. }
  40. }
  41. }