2026-10-28 21:43:17 +01:00
|
|
|
|
using Helpdesk.Application.Abstractions;
|
2026-11-18 18:32:59 +01:00
|
|
|
|
using Helpdesk.Application.Issues;
|
2026-10-28 21:43:17 +01:00
|
|
|
|
using Helpdesk.Application.Users;
|
2026-11-18 18:32:59 +01:00
|
|
|
|
using Helpdesk.Api.Infrastructure;
|
2026-10-28 21:43:17 +01:00
|
|
|
|
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")]
|
2026-11-18 18:32:59 +01:00
|
|
|
|
public sealed class UsersController(UserService users, ICurrentUser currentUser, IssueService issues) : ControllerBase
|
2026-10-28 21:43:17 +01:00
|
|
|
|
{
|
|
|
|
|
|
/// <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);
|
2026-11-18 18:32:59 +01:00
|
|
|
|
|
|
|
|
|
|
/// <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);
|
2026-10-28 21:43:17 +01:00
|
|
|
|
}
|