90ac0b81d1
Add full V2 architecture: identity, content, studio (.NET 10) and file, render, notification, gateway (Go) services with vendored deps, plus DB migrations, event/API contracts, and an init-db script. Wire the Next.js frontend to the gateway: server-side JWT auth routes (login/register/refresh/logout/me), gateway fetch helper, and session/ cookie/jwt helpers under src/lib. Containerize the stack via docker-compose.v2.yml and per-service Dockerfiles. Base images resolve through a Nexus mirror (Docker Hub) and MCR directly; npm/NuGet pull from Nexus groups. Self-host fonts via next/font/local to avoid Google Fonts (geo-blocked). Add CI workflow and ignore .env.v2, *.stackdump, and .NET bin/obj. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
62 lines
2.3 KiB
C#
62 lines
2.3 KiB
C#
using FlatRender.IdentitySvc.Application.Services.Interfaces;
|
|
using FlatRender.IdentitySvc.Models.Requests;
|
|
using FlatRender.IdentitySvc.Models.Responses;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace FlatRender.IdentitySvc.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("v1/users")]
|
|
[Authorize]
|
|
public class UsersController(IUserService userService) : ControllerBase
|
|
{
|
|
[HttpGet("me")]
|
|
[ProducesResponseType(typeof(UserResponse), 200)]
|
|
public async Task<IActionResult> GetMe()
|
|
=> Ok(await userService.GetMeAsync(GetUserId()));
|
|
|
|
[HttpPatch("me")]
|
|
[ProducesResponseType(typeof(UserResponse), 200)]
|
|
public async Task<IActionResult> UpdateMe([FromBody] UpdateUserRequest request)
|
|
=> Ok(await userService.UpdateMeAsync(GetUserId(), request));
|
|
|
|
[HttpGet("me/balance")]
|
|
[ProducesResponseType(typeof(BalanceResponse), 200)]
|
|
public async Task<IActionResult> GetBalance()
|
|
=> Ok(await userService.GetBalanceAsync(GetUserId()));
|
|
|
|
[HttpPost("me/avatar")]
|
|
public async Task<IActionResult> SetAvatar([FromBody] SetAvatarRequest request)
|
|
{
|
|
await userService.UpdateAvatarAsync(GetUserId(), request.AvatarId, request.AvatarUrl);
|
|
return Ok();
|
|
}
|
|
|
|
[HttpGet("{userId:guid}")]
|
|
[ProducesResponseType(typeof(UserResponse), 200)]
|
|
[ProducesResponseType(404)]
|
|
public async Task<IActionResult> GetById(Guid userId)
|
|
=> Ok(await userService.GetByIdAsync(userId));
|
|
|
|
[HttpGet]
|
|
[ProducesResponseType(typeof(PagedResponse<UserResponse>), 200)]
|
|
public async Task<IActionResult> Search(
|
|
[FromQuery] string? q,
|
|
[FromQuery] Guid? tenantId,
|
|
[FromQuery] int page = 1,
|
|
[FromQuery] int pageSize = 20)
|
|
=> Ok(await userService.SearchAsync(q, tenantId, page, pageSize));
|
|
|
|
[HttpPost("{userId:guid}/ban")]
|
|
[ProducesResponseType(204)]
|
|
public async Task<IActionResult> Ban(Guid userId, [FromBody] BanUserRequest request)
|
|
{
|
|
await userService.BanAsync(userId, request.Reason, request.UnblockDate);
|
|
return NoContent();
|
|
}
|
|
|
|
private Guid GetUserId() => Guid.Parse(User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier)?.Value
|
|
?? User.FindFirst("sub")?.Value ?? throw new UnauthorizedAccessException());
|
|
}
|