refactor: change the api path
All checks were successful
.NET Test Pipeline / build-and-test (pull_request) Successful in 1m59s

This commit is contained in:
Polianin Nikita 2024-05-28 07:09:40 +03:00
parent 3f30b98cf9
commit ae0b9daefa
9 changed files with 314 additions and 320 deletions

View File

@ -2,6 +2,7 @@
namespace Mirea.Api.Endpoint.Controllers; namespace Mirea.Api.Endpoint.Controllers;
[Produces("application/json")]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiController] [ApiController]
[Route("api/[controller]/[action]")]
public class BaseController : ControllerBase; public class BaseController : ControllerBase;

View File

@ -1,8 +0,0 @@
using Microsoft.AspNetCore.Mvc;
namespace Mirea.Api.Endpoint.Controllers.V1;
[ApiVersion("1.0")]
[Produces("application/json")]
[Route("api/v{version:apiVersion}/[controller]/[action]")]
public class BaseControllerV1 : BaseController;

View File

@ -9,10 +9,11 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Mirea.Api.Endpoint.Controllers.V1 namespace Mirea.Api.Endpoint.Controllers.V1;
[ApiVersion("1.0")]
public class CampusController(IMediator mediator) : BaseController
{ {
public class CampusController(IMediator mediator) : BaseControllerV1
{
/// <summary> /// <summary>
/// Gets basic information about campuses. /// Gets basic information about campuses.
/// </summary> /// </summary>
@ -57,5 +58,4 @@ namespace Mirea.Api.Endpoint.Controllers.V1
Address = result.Address Address = result.Address
}); });
} }
}
} }

View File

@ -9,10 +9,11 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Mirea.Api.Endpoint.Controllers.V1 namespace Mirea.Api.Endpoint.Controllers.V1;
[ApiVersion("1.0")]
public class DisciplineController(IMediator mediator) : BaseController
{ {
public class DisciplineController(IMediator mediator) : BaseControllerV1
{
/// <summary> /// <summary>
/// Gets a paginated list of disciplines. /// Gets a paginated list of disciplines.
/// </summary> /// </summary>
@ -61,5 +62,4 @@ namespace Mirea.Api.Endpoint.Controllers.V1
Name = result.Name Name = result.Name
}); });
} }
}
} }

View File

@ -9,10 +9,11 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Mirea.Api.Endpoint.Controllers.V1 namespace Mirea.Api.Endpoint.Controllers.V1;
[ApiVersion("1.0")]
public class FacultyController(IMediator mediator) : BaseController
{ {
public class FacultyController(IMediator mediator) : BaseControllerV1
{
/// <summary> /// <summary>
/// Gets a paginated list of faculties. /// Gets a paginated list of faculties.
/// </summary> /// </summary>
@ -65,5 +66,4 @@ namespace Mirea.Api.Endpoint.Controllers.V1
CampusName = result.CampusName CampusName = result.CampusName
}); });
} }
}
} }

View File

@ -10,10 +10,11 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Mirea.Api.Endpoint.Controllers.V1 namespace Mirea.Api.Endpoint.Controllers.V1;
[ApiVersion("1.0")]
public class GroupController(IMediator mediator) : BaseController
{ {
public class GroupController(IMediator mediator) : BaseControllerV1
{
private static int GetCourseNumber(string groupName) private static int GetCourseNumber(string groupName)
{ {
var current = DateTime.Now; var current = DateTime.Now;
@ -86,7 +87,7 @@ namespace Mirea.Api.Endpoint.Controllers.V1
/// </summary> /// </summary>
/// <param name="id">The ID of the faculty.</param> /// <param name="id">The ID of the faculty.</param>
/// <returns>A list of groups belonging to the specified faculty.</returns> /// <returns>A list of groups belonging to the specified faculty.</returns>
[HttpGet("{id:int}")] [HttpGet("GetByFaculty/{id:int}")]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status200OK)]
[BadRequestResponse] [BadRequestResponse]
[NotFoundResponse] [NotFoundResponse]
@ -104,5 +105,4 @@ namespace Mirea.Api.Endpoint.Controllers.V1
FacultyId = g.FacultyId FacultyId = g.FacultyId
})); }));
} }
}
} }

View File

@ -9,10 +9,11 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Mirea.Api.Endpoint.Controllers.V1 namespace Mirea.Api.Endpoint.Controllers.V1;
[ApiVersion("1.0")]
public class LectureHallController(IMediator mediator) : BaseController
{ {
public class LectureHallController(IMediator mediator) : BaseControllerV1
{
/// <summary> /// <summary>
/// Retrieves a list of all lecture halls. /// Retrieves a list of all lecture halls.
/// </summary> /// </summary>
@ -64,7 +65,7 @@ namespace Mirea.Api.Endpoint.Controllers.V1
/// </summary> /// </summary>
/// <param name="id">The ID of the campus.</param> /// <param name="id">The ID of the campus.</param>
/// <returns>A list of lecture halls in the specified campus.</returns> /// <returns>A list of lecture halls in the specified campus.</returns>
[HttpGet("{id:int}")] [HttpGet("GetByCampus/{id:int}")]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status200OK)]
[BadRequestResponse] [BadRequestResponse]
[NotFoundResponse] [NotFoundResponse]
@ -80,5 +81,4 @@ namespace Mirea.Api.Endpoint.Controllers.V1
CampusId = l.CampusId CampusId = l.CampusId
})); }));
} }
}
} }

View File

@ -11,7 +11,8 @@ using System.Threading.Tasks;
namespace Mirea.Api.Endpoint.Controllers.V1; namespace Mirea.Api.Endpoint.Controllers.V1;
public class ProfessorController(IMediator mediator) : BaseControllerV1 [ApiVersion("1.0")]
public class ProfessorController(IMediator mediator) : BaseController
{ {
/// <summary> /// <summary>
/// Retrieves a list of professors. /// Retrieves a list of professors.

View File

@ -12,7 +12,8 @@ using System.Threading.Tasks;
namespace Mirea.Api.Endpoint.Controllers.V1; namespace Mirea.Api.Endpoint.Controllers.V1;
public class ScheduleController(IMediator mediator) : BaseControllerV1 [ApiVersion("1.0")]
public class ScheduleController(IMediator mediator) : BaseController
{ {
/// <summary> /// <summary>
/// Retrieves schedules based on various filters. /// Retrieves schedules based on various filters.
@ -25,7 +26,6 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
[BadRequestResponse] [BadRequestResponse]
[NotFoundResponse] [NotFoundResponse]
public async Task<ActionResult<List<ScheduleResponse>>> Get([FromBody] ScheduleRequest request) public async Task<ActionResult<List<ScheduleResponse>>> Get([FromBody] ScheduleRequest request)
{ {
if ((request.Groups == null || request.Groups.Length == 0) && if ((request.Groups == null || request.Groups.Length == 0) &&
(request.Disciplines == null || request.Disciplines.Length == 0) && (request.Disciplines == null || request.Disciplines.Length == 0) &&
@ -85,7 +85,7 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
/// <param name="professors">An array of professor IDs.</param> /// <param name="professors">An array of professor IDs.</param>
/// <param name="lectureHalls">An array of lecture hall IDs.</param> /// <param name="lectureHalls">An array of lecture hall IDs.</param>
/// <returns>A response containing schedules for the specified group.</returns> /// <returns>A response containing schedules for the specified group.</returns>
[HttpGet("{id:int}")] [HttpGet("GetByGroup/{id:int}")]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)] [ProducesResponseType(StatusCodes.Status204NoContent)]
[BadRequestResponse] [BadRequestResponse]
@ -142,7 +142,7 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
/// <param name="groups">An array of group IDs.</param> /// <param name="groups">An array of group IDs.</param>
/// <param name="lectureHalls">An array of lecture hall IDs.</param> /// <param name="lectureHalls">An array of lecture hall IDs.</param>
/// <returns>A response containing schedules for the specified professor.</returns> /// <returns>A response containing schedules for the specified professor.</returns>
[HttpGet("{id:int}")] [HttpGet("GetByProfessor/{id:int}")]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)] [ProducesResponseType(StatusCodes.Status204NoContent)]
[BadRequestResponse] [BadRequestResponse]
@ -203,7 +203,7 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
/// <param name="professors">An array of professor IDs.</param> /// <param name="professors">An array of professor IDs.</param>
/// <param name="groups">An array of group IDs.</param> /// <param name="groups">An array of group IDs.</param>
/// <returns>A response containing schedules for the specified lecture hall.</returns> /// <returns>A response containing schedules for the specified lecture hall.</returns>
[HttpGet("{id:int}")] [HttpGet("GetByLectureHall/{id:int}")]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)] [ProducesResponseType(StatusCodes.Status204NoContent)]
[BadRequestResponse] [BadRequestResponse]
@ -264,7 +264,7 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
/// <param name="professors">An array of professor IDs.</param> /// <param name="professors">An array of professor IDs.</param>
/// <param name="lectureHalls">An array of lecture hall IDs.</param> /// <param name="lectureHalls">An array of lecture hall IDs.</param>
/// <returns>A response containing schedules for the specified discipline.</returns> /// <returns>A response containing schedules for the specified discipline.</returns>
[HttpGet("{id:int}")] [HttpGet("GetByDiscipline/{id:int}")]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)] [ProducesResponseType(StatusCodes.Status204NoContent)]
[BadRequestResponse] [BadRequestResponse]