You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
using XUnitDIStudy.Model;
|
|
|
|
|
using XUnitDIStudy.Service;
|
|
|
|
|
|
|
|
|
|
namespace XUnitDIStudy.WebApp.Controllers
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 默认控制器
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiController]
|
|
|
|
|
[Route("[controller]/[action]")]
|
|
|
|
|
public class DefaultController : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger<DefaultController> _logger;
|
|
|
|
|
private readonly IStudentService _studentService;
|
|
|
|
|
|
|
|
|
|
public DefaultController(ILogger<DefaultController> logger, IStudentService studentService)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_studentService = studentService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取所有学生
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<Student> GetAll()
|
|
|
|
|
{
|
|
|
|
|
var list = _studentService.GetAll();
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取学生
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public Student Get()
|
|
|
|
|
{
|
|
|
|
|
return new Student() { Id=10,Name="小三",Age =90};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|