feat: add a controller for campus
This commit is contained in:
parent
88b4eb594e
commit
dfc9caf921
45
Endpoint/Controllers/V1/CampusController.cs
Normal file
45
Endpoint/Controllers/V1/CampusController.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Mirea.Api.DataAccess.Application.Cqrs.Campus.Queries.GetCampusBasicInfoList;
|
||||
using Mirea.Api.DataAccess.Application.Cqrs.Campus.Queries.GetCampusDetails;
|
||||
using Mirea.Api.Endpoint.Common.Extensions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Mirea.Api.Endpoint.Controllers.V1
|
||||
{
|
||||
public class CampusController(IMediator mediator) : BaseControllerV1
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets basic information about campuses.
|
||||
/// </summary>
|
||||
/// <returns>Basic information about campuses.</returns>
|
||||
[HttpGet]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<CampusBasicInfoVm>> GetBasicInfo()
|
||||
{
|
||||
var result = await mediator.Send(new GetCampusBasicInfoListQuery());
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets details of a specific campus by ID.
|
||||
/// </summary>
|
||||
/// <param name="id">Campus ID.</param>
|
||||
/// <returns>Details of the specified campus.</returns>
|
||||
[HttpGet("{id:int}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[BadRequestResponse]
|
||||
[NotFoundResponse]
|
||||
public async Task<ActionResult<CampusDetailsVm>> GetDetails(int id)
|
||||
{
|
||||
var result = await mediator.Send(new GetCampusDetailsQuery()
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user