refactor: rewrite the api for the dto project
This commit is contained in:
@ -3,7 +3,10 @@ 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 Mirea.Api.Dto.Responses;
|
||||
using Mirea.Api.Endpoint.Common.Attributes;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Mirea.Api.Endpoint.Controllers.V1
|
||||
@ -16,11 +19,18 @@ namespace Mirea.Api.Endpoint.Controllers.V1
|
||||
/// <returns>Basic information about campuses.</returns>
|
||||
[HttpGet]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<CampusBasicInfoVm>> GetBasicInfo()
|
||||
public async Task<ActionResult<List<CampusBasicInfoResponse>>> GetBasicInfo()
|
||||
{
|
||||
var result = await mediator.Send(new GetCampusBasicInfoListQuery());
|
||||
|
||||
return Ok(result);
|
||||
return Ok(result.Campuses
|
||||
.Select(c => new CampusBasicInfoResponse()
|
||||
{
|
||||
Id = c.Id,
|
||||
CodeName = c.CodeName,
|
||||
FullName = c.FullName
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -32,14 +42,20 @@ namespace Mirea.Api.Endpoint.Controllers.V1
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[BadRequestResponse]
|
||||
[NotFoundResponse]
|
||||
public async Task<ActionResult<CampusDetailsVm>> GetDetails(int id)
|
||||
public async Task<ActionResult<CampusDetailsResponse>> GetDetails(int id)
|
||||
{
|
||||
var result = await mediator.Send(new GetCampusDetailsQuery()
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
|
||||
return Ok(result);
|
||||
return Ok(new CampusDetailsResponse()
|
||||
{
|
||||
Id = result.Id,
|
||||
CodeName = result.CodeName,
|
||||
FullName = result.FullName,
|
||||
Address = result.Address
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user