Files
NTBug/backend/src/Helpdesk.Api/Controllers/UsersController.cs
T

34 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Helpdesk.Application.Abstractions;
using Helpdesk.Application.Issues;
using Helpdesk.Application.Users;
using Helpdesk.Api.Infrastructure;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Helpdesk.Api.Controllers;
/// <summary>Profil přihlášeného uživatele.</summary>
[ApiController]
[Authorize]
[Route("api/users")]
[Produces("application/json")]
public sealed class UsersController(UserService users, ICurrentUser currentUser, IssueService issues) : ControllerBase
{
/// <summary>Můj profil.</summary>
[HttpGet("me")]
public Task<UserDto> GetMe(CancellationToken ct) => users.GetMeAsync(currentUser, ct);
/// <summary>Úprava profilu – jméno, telefon (ukládá se šifrovaně), e-mailové notifikace.</summary>
[HttpPut("me")]
[ProducesResponseType<UserDto>(StatusCodes.Status200OK)]
[ProducesResponseType<ValidationProblemDetails>(StatusCodes.Status400BadRequest)]
public Task<UserDto> UpdateMe(UpdateProfileRequest request, CancellationToken ct) => users.UpdateMeAsync(currentUser, request, ct);
/// <summary>Aktivní řešitelé s počtem otevřených závad.</summary>
[HttpGet("assignable")]
[Authorize(Roles = Roles.Management)]
[ResponseCache(NoStore = true, Location = ResponseCacheLocation.None)]
[ProducesResponseType<ProblemDetails>(StatusCodes.Status403Forbidden)]
public Task<IReadOnlyList<AssignableUserDto>> GetAssignable(CancellationToken ct) => issues.GetAssignableAsync(ct);
}