| | 1 | | namespace Syki.Back.Features.Cross.GetUserNotifications; |
| | 2 | |
|
| | 3 | | [ApiController, AuthBearer] |
| | 4 | | [EnableRateLimiting("Medium")] |
| | 5 | | public class GetUserNotificationsController(GetUserNotificationsService service) : ControllerBase |
| | 6 | | { |
| | 7 | | /// <summary> |
| | 8 | | /// Notificações |
| | 9 | | /// </summary> |
| | 10 | | /// <remarks> |
| | 11 | | /// Retorna as notificações do usuário. |
| | 12 | | /// </remarks> |
| | 13 | | [HttpGet("notifications/user")] |
| | 14 | | [ProducesResponseType(typeof(List<UserNotificationOut>), 200)] |
| | 15 | | [SwaggerResponseExample(200, typeof(ResponseExamples))] |
| | 16 | | public async Task<IActionResult> Get() |
| | 17 | | { |
| | 18 | | var notifications = await service.Get(User.InstitutionId, User.Id); |
| | 19 | | return Ok(notifications); |
| | 20 | | } |
| | 21 | | } |
| | 22 | |
|
| | 23 | | internal class ResponseExamples : IMultipleExamplesProvider<List<UserNotificationOut>> |
| | 24 | | { |
| | 25 | | public IEnumerable<SwaggerExample<List<UserNotificationOut>>> GetExamples() |
| | 26 | | { |
| 0 | 27 | | yield return SwaggerExample.Create( |
| 0 | 28 | | "Nofitications", |
| 0 | 29 | | new List<UserNotificationOut>() |
| 0 | 30 | | { |
| 0 | 31 | | new() |
| 0 | 32 | | { |
| 0 | 33 | | NotificationId = Guid.CreateVersion7(), |
| 0 | 34 | | Title = "Boas-vindas!", |
| 0 | 35 | | Description = "Agradecemos a confiança na nossa instituição, que seja uma jornada cheia de aprendizado!", |
| 0 | 36 | | CreatedAt = DateTime.UtcNow.AddDays(-50), |
| 0 | 37 | | ViewedAt = DateTime.UtcNow.AddDays(-48), |
| 0 | 38 | | }, |
| 0 | 39 | | new() |
| 0 | 40 | | { |
| 0 | 41 | | NotificationId = Guid.CreateVersion7(), |
| 0 | 42 | | Title = "Semana de prova chegando!", |
| 0 | 43 | | Description = "Preparado(a) pras avaliações? Elas começam semana que vem, revise os assuntos e boas provas!", |
| 0 | 44 | | CreatedAt = DateTime.UtcNow, |
| 0 | 45 | | ViewedAt = null, |
| 0 | 46 | | } |
| 0 | 47 | | } |
| 0 | 48 | | ); |
| 0 | 49 | | } |
| | 50 | | } |