From fb3320fe183632af439f06129d559bf037583f39 Mon Sep 17 00:00:00 2001 From: shept Date: Sun, 27 Apr 2025 15:58:51 +0500 Subject: [PATCH] add controllers docs --- .../Controllers/AuthController.cs | 7 +++++ .../Controllers/QuestionController.cs | 15 ++++++++++ .../Controllers/SurveyController.cs | 30 +++++++++++++++++++ .../Controllers/TestController.cs | 3 ++ 4 files changed, 55 insertions(+) diff --git a/SurveyBackend/SurveyBackend.API/Controllers/AuthController.cs b/SurveyBackend/SurveyBackend.API/Controllers/AuthController.cs index f840248..a4ee704 100644 --- a/SurveyBackend/SurveyBackend.API/Controllers/AuthController.cs +++ b/SurveyBackend/SurveyBackend.API/Controllers/AuthController.cs @@ -6,12 +6,19 @@ using IAuthorizationService = SurveyBackend.Core.Services.IAuthorizationService; namespace SurveyBackend.Controllers; +/// +/// Контроллер для всего связанного с авторизацией пользователей +/// [ApiController] [Route("api/auth")] public class AuthController : ControllerBase { private readonly IAuthorizationService _authorizationService; + /// + /// Нет ну вы прикалываетесь что ли мне ща каждый контроллер описывать? + /// + /// public AuthController(IAuthorizationService authorizationService) { _authorizationService = authorizationService; diff --git a/SurveyBackend/SurveyBackend.API/Controllers/QuestionController.cs b/SurveyBackend/SurveyBackend.API/Controllers/QuestionController.cs index a8b5764..e9ac6a0 100644 --- a/SurveyBackend/SurveyBackend.API/Controllers/QuestionController.cs +++ b/SurveyBackend/SurveyBackend.API/Controllers/QuestionController.cs @@ -7,17 +7,25 @@ using SurveyLib.Core.Services; namespace SurveyBackend.Controllers; +/// [ApiController] [Route("api/surveys/{surveyId}/questions")] public class QuestionController : ControllerBase { private readonly IQuestionService _questionService; + /// public QuestionController(IQuestionService questionService, IUserContext userContext) { _questionService = questionService; } + /// + /// Возвращает список вопросов из опроса по его ID + /// + /// Получение вопросов по ID опроса. В случае отсутствия опроса с таким идентификатором выкидывает 404 + /// + /// [AllowAnonymous] [HttpGet] [ProducesResponseType(StatusCodes.Status404NotFound)] @@ -29,6 +37,13 @@ public class QuestionController : ControllerBase return Ok(result); } + /// + /// Добавить вопрос к опросу + /// + /// К опросу с указанным ID добавляет вопрос. Если я правильно написал, при отсутствии такого опроса кинет 404 + /// + /// + /// [Authorize] [HttpPost] [ProducesResponseType(StatusCodes.Status404NotFound)] diff --git a/SurveyBackend/SurveyBackend.API/Controllers/SurveyController.cs b/SurveyBackend/SurveyBackend.API/Controllers/SurveyController.cs index d471152..24f1cd2 100644 --- a/SurveyBackend/SurveyBackend.API/Controllers/SurveyController.cs +++ b/SurveyBackend/SurveyBackend.API/Controllers/SurveyController.cs @@ -10,6 +10,7 @@ using SurveyLib.Core.Services; namespace SurveyBackend.Controllers; +/// [ApiController] [Route("api/surveys")] public class SurveyController : ControllerBase @@ -17,12 +18,18 @@ public class SurveyController : ControllerBase private readonly ISurveyService _surveyService; private readonly IUserContext _userContext; + /// public SurveyController(ISurveyService surveyService, IUserContext userContext) { _surveyService = surveyService; _userContext = userContext; } + /// + /// Получить ВСЕ опросы + /// + /// Возвращает массив вообще всех опросов + /// [AllowAnonymous] [HttpGet] [ProducesResponseType(typeof(List), StatusCodes.Status200OK)] @@ -33,6 +40,12 @@ public class SurveyController : ControllerBase return Ok(result); } + /// + /// Получить опрос по ID + /// + /// А что тут говорить то + /// + /// [AllowAnonymous] [HttpGet("{id}")] [ProducesResponseType(StatusCodes.Status404NotFound)] @@ -44,6 +57,12 @@ public class SurveyController : ControllerBase return Ok(result); } + /// + /// Добавить новый опрос + /// + /// + /// + /// [Authorize] [HttpPost] [ProducesResponseType(StatusCodes.Status201Created)] @@ -56,6 +75,12 @@ public class SurveyController : ControllerBase return Created(); } + /// + /// Удалить опрос по ID + /// + /// Опрос должен быть создан тобой чтоб его удалить + /// + /// [Authorize] [HttpDelete("{id}")] [ProducesResponseType(StatusCodes.Status404NotFound)] @@ -67,6 +92,11 @@ public class SurveyController : ControllerBase return Ok(); } + /// + /// Получить МОИ опроса + /// + /// Возвращает только опросы созданные нынешним юзером + /// [Authorize] [HttpGet("my")] [ProducesResponseType(StatusCodes.Status401Unauthorized)] diff --git a/SurveyBackend/SurveyBackend.API/Controllers/TestController.cs b/SurveyBackend/SurveyBackend.API/Controllers/TestController.cs index cbf5688..2d7a6ca 100644 --- a/SurveyBackend/SurveyBackend.API/Controllers/TestController.cs +++ b/SurveyBackend/SurveyBackend.API/Controllers/TestController.cs @@ -3,6 +3,9 @@ using SurveyLib.Core.Services; namespace SurveyBackend.Controllers; +/// +/// Удалим когда-нибудь +/// [ApiController] [Route("api/test")] public class TestController : ControllerBase