add controllers docs
This commit is contained in:
parent
bfcba0beb7
commit
fb3320fe18
4 changed files with 55 additions and 0 deletions
|
|
@ -6,12 +6,19 @@ using IAuthorizationService = SurveyBackend.Core.Services.IAuthorizationService;
|
|||
|
||||
namespace SurveyBackend.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// Контроллер для всего связанного с авторизацией пользователей
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("api/auth")]
|
||||
public class AuthController : ControllerBase
|
||||
{
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
|
||||
/// <summary>
|
||||
/// Нет ну вы прикалываетесь что ли мне ща каждый контроллер описывать?
|
||||
/// </summary>
|
||||
/// <param name="authorizationService"></param>
|
||||
public AuthController(IAuthorizationService authorizationService)
|
||||
{
|
||||
_authorizationService = authorizationService;
|
||||
|
|
|
|||
|
|
@ -7,17 +7,25 @@ using SurveyLib.Core.Services;
|
|||
|
||||
namespace SurveyBackend.Controllers;
|
||||
|
||||
/// <inheritdoc />
|
||||
[ApiController]
|
||||
[Route("api/surveys/{surveyId}/questions")]
|
||||
public class QuestionController : ControllerBase
|
||||
{
|
||||
private readonly IQuestionService _questionService;
|
||||
|
||||
/// <inheritdoc />
|
||||
public QuestionController(IQuestionService questionService, IUserContext userContext)
|
||||
{
|
||||
_questionService = questionService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает список вопросов из опроса по его ID
|
||||
/// </summary>
|
||||
/// <remarks>Получение вопросов по ID опроса. В случае отсутствия опроса с таким идентификатором выкидывает 404</remarks>
|
||||
/// <param name="surveyId"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
|
|
@ -29,6 +37,13 @@ public class QuestionController : ControllerBase
|
|||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавить вопрос к опросу
|
||||
/// </summary>
|
||||
/// <remarks>К опросу с указанным ID добавляет вопрос. Если я правильно написал, при отсутствии такого опроса кинет 404</remarks>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="surveyId"></param>
|
||||
/// <returns></returns>
|
||||
[Authorize]
|
||||
[HttpPost]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ using SurveyLib.Core.Services;
|
|||
|
||||
namespace SurveyBackend.Controllers;
|
||||
|
||||
/// <inheritdoc />
|
||||
[ApiController]
|
||||
[Route("api/surveys")]
|
||||
public class SurveyController : ControllerBase
|
||||
|
|
@ -17,12 +18,18 @@ public class SurveyController : ControllerBase
|
|||
private readonly ISurveyService _surveyService;
|
||||
private readonly IUserContext _userContext;
|
||||
|
||||
/// <inheritdoc />
|
||||
public SurveyController(ISurveyService surveyService, IUserContext userContext)
|
||||
{
|
||||
_surveyService = surveyService;
|
||||
_userContext = userContext;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получить ВСЕ опросы
|
||||
/// </summary>
|
||||
/// <remarks>Возвращает массив вообще всех опросов</remarks>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(List<OutputSurveyDto>), StatusCodes.Status200OK)]
|
||||
|
|
@ -33,6 +40,12 @@ public class SurveyController : ControllerBase
|
|||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получить опрос по ID
|
||||
/// </summary>
|
||||
/// <remarks>А что тут говорить то</remarks>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("{id}")]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
|
|
@ -44,6 +57,12 @@ public class SurveyController : ControllerBase
|
|||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавить новый опрос
|
||||
/// </summary>
|
||||
/// <remarks></remarks>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
[Authorize]
|
||||
[HttpPost]
|
||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||
|
|
@ -56,6 +75,12 @@ public class SurveyController : ControllerBase
|
|||
return Created();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удалить опрос по ID
|
||||
/// </summary>
|
||||
/// <remarks>Опрос должен быть создан тобой чтоб его удалить</remarks>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[Authorize]
|
||||
[HttpDelete("{id}")]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
|
|
@ -67,6 +92,11 @@ public class SurveyController : ControllerBase
|
|||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получить МОИ опроса
|
||||
/// </summary>
|
||||
/// <remarks>Возвращает только опросы созданные нынешним юзером</remarks>
|
||||
/// <returns></returns>
|
||||
[Authorize]
|
||||
[HttpGet("my")]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ using SurveyLib.Core.Services;
|
|||
|
||||
namespace SurveyBackend.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// Удалим когда-нибудь
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("api/test")]
|
||||
public class TestController : ControllerBase
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue