Files
Yi.Framework/CC.Yi.API/Controllers/WeatherForecastController.cs
454313500@qq.com 59a42ae48f v1.0.0
2021-03-20 14:12:24 +08:00

48 lines
1.4 KiB
C#

using CC.Yi.IBLL;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace CC.Yi.API.Controllers
{
[ApiController]
[Route("[controller]/[action]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
private IstudentBll _studentBll;
public WeatherForecastController(ILogger<WeatherForecastController> logger, IstudentBll studentBll)
{
_studentBll = studentBll;
_logger = logger;
}
[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
})
.ToArray();
}
[HttpGet]
public IActionResult Test()
{
var data= _studentBll.GetEntities(n => n.id >= 0).ToList();
return Content(Common.JsonFactory.JsonToString(data));
}
}
}