Files
flatrender/services/identity/FlatRender.IdentitySvc/Controllers/GamificationController.cs
T
soroush.asadi 90ac0b81d1 feat: V2 microservices stack — backend services, gateway, JWT auth
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>
2026-05-29 23:29:31 +03:30

50 lines
1.7 KiB
C#

using FlatRender.IdentitySvc.Application.Services.Interfaces;
using FlatRender.IdentitySvc.Models.Responses;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace FlatRender.IdentitySvc.Controllers;
[ApiController]
[Authorize]
public class GamificationController(IGamificationService gamificationService) : ControllerBase
{
[HttpGet("v1/quests")]
[ProducesResponseType(typeof(object), 200)]
public async Task<IActionResult> GetQuests()
{
var quests = await gamificationService.GetActiveQuestsAsync(GetUserId(), GetTenantId());
return Ok(new { data = quests });
}
[HttpPost("v1/quests/{questId:guid}/claim")]
[ProducesResponseType(200)]
public async Task<IActionResult> ClaimQuest(Guid questId)
{
await gamificationService.ClaimQuestPrizeAsync(GetUserId(), questId);
return Ok();
}
[HttpGet("v1/gifts/earned")]
[ProducesResponseType(typeof(object), 200)]
public async Task<IActionResult> GetEarnedGifts()
{
var gifts = await gamificationService.GetEarnedGiftsAsync(GetUserId());
return Ok(new { data = gifts });
}
[HttpPost("v1/gifts/earned/{earnedGiftId:guid}/use")]
[ProducesResponseType(200)]
public async Task<IActionResult> UseGift(Guid earnedGiftId)
{
await gamificationService.UseEarnedGiftAsync(GetUserId(), earnedGiftId);
return Ok();
}
private Guid GetUserId() => Guid.Parse(User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier)?.Value
?? User.FindFirst("sub")?.Value ?? throw new UnauthorizedAccessException());
private Guid GetTenantId() => Guid.Parse(User.FindFirst("tenant_id")?.Value
?? throw new UnauthorizedAccessException());
}