using ChouBox.Code.AppExtend; using ChouBox.Model.Entities; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using System.Threading.Tasks; namespace ChouBox.WebApi.Controllers { [ApiController] [Route("[controller]")] public class WeatherForecastController : ControllerBase { private static readonly string[] Summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" }; private readonly ILogger _logger; private readonly YoudaContext _dbContext; private readonly ChouBoxCodeBase _chouBoxCodeBase; public WeatherForecastController(ILogger logger, YoudaContext dbContext, ChouBoxCodeBase chouBoxCodeBase) { _logger = logger; _dbContext = dbContext; _chouBoxCodeBase = chouBoxCodeBase; } [HttpGet(Name = "GetWeatherForecast")] public async Task> Get() { var list = await _dbContext.Config.ToListAsync(); var c = await _chouBoxCodeBase.RedisCache.StringGetAsync("aaa"); return 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(); } } }