This commit is contained in:
454313500@qq.com
2021-03-20 15:02:23 +08:00
parent 59a42ae48f
commit 2e5b991db0
7 changed files with 95 additions and 88 deletions

View File

@@ -0,0 +1,30 @@
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 StudentController : ControllerBase
{
private readonly ILogger<StudentController> _logger;
private IstudentBll _studentBll;
public StudentController(ILogger<StudentController> logger, IstudentBll studentBll)
{
_studentBll = studentBll;
_logger = logger;
}
[HttpGet]
public IActionResult Test()
{
var data = _studentBll.GetAllEntities().ToList();
return Content(Common.JsonFactory.JsonToString(data));
}
}
}

View File

@@ -1,47 +0,0 @@
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));
}
}
}

View File

@@ -1,15 +0,0 @@
using System;
namespace CC.Yi.API
{
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string Summary { get; set; }
}
}