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