97 lines
2.8 KiB
C#
97 lines
2.8 KiB
C#
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Yi.Framework.Common.Models;
|
|
using Yi.Framework.DtoModel.RABC.Student;
|
|
using Yi.Framework.Interface.RABC;
|
|
|
|
namespace Brick.IFServer.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("[controller]")]
|
|
public class StudentController : ControllerBase
|
|
{
|
|
|
|
private readonly ILogger<StudentController> _logger;
|
|
private readonly IStudentService _studentService;
|
|
public StudentController(ILogger<StudentController> logger, IStudentService studentService)
|
|
{
|
|
_logger = logger;
|
|
_studentService = studentService;
|
|
}
|
|
|
|
[HttpDelete]
|
|
[Route("ErrorTest")]
|
|
public Result<bool> ErrorTest()
|
|
{
|
|
_studentService.GetError();
|
|
return Result<bool>.Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ôö
|
|
/// </summary>
|
|
/// <param name="studentCreateInput"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<Result<StudentGetOutput>> Create(StudentCreateInput studentCreateInput)
|
|
{
|
|
var result = await _studentService.CreateAsync(studentCreateInput);
|
|
|
|
return Result<StudentGetOutput>.Success().SetData(result);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// ²é
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[Route("{id}")]
|
|
public async Task<Result<StudentGetOutput>> GetById(Guid id)
|
|
{
|
|
var result = await _studentService.GetByIdAsync(id);
|
|
return Result<StudentGetOutput>.Success().SetData(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// ²é
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public async Task<Result<List<StudentListOutput>>> GetLsit()
|
|
{
|
|
var result = await _studentService.GetListAsync();
|
|
|
|
return Result<List<StudentListOutput>>.Success().SetData(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// ɾ
|
|
/// </summary>
|
|
/// <param name="ids"></param>
|
|
/// <returns></returns>
|
|
[HttpDelete]
|
|
public async Task<Result<bool>> Del(List<Guid> ids)
|
|
{
|
|
await _studentService.DeleteAsync(ids);
|
|
return Result<bool>.Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ¸ü
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="studentUpdateInput"></param>
|
|
/// <returns></returns>
|
|
[HttpPut]
|
|
[Route("{id}")]
|
|
public async Task<Result<StudentGetOutput>> Update(Guid id, StudentUpdateInput studentUpdateInput)
|
|
{
|
|
var result = await _studentService.UpdateAsync(id, studentUpdateInput);
|
|
return Result<StudentGetOutput>.Success().SetData(result);
|
|
}
|
|
|
|
|
|
}
|
|
} |