- ASP.NET Core 9 Web API backend with JWT auth, EF Core MySQL - Vue 3 + Vite + Pinia + Ant Design Vue frontend - Multi-platform connection management (UOOC & Zhihuishu) - Video brushing with AES-CBC encryption for Zhihuishu - Multi-task queue with cross-platform parallel execution - Task persistence via MySQL database - Progress tracking with inline catalog enrichment - Mobile-responsive UI Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using System.Security.Claims;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using UoocProgress.Api.Models;
|
|
using UoocProgress.Api.Services;
|
|
|
|
namespace UoocProgress.Api.Controllers;
|
|
|
|
[ApiController]
|
|
[Authorize(Policy = "UserOrAdmin")]
|
|
[Route("api/platform-challenges")]
|
|
public sealed class PlatformChallengesController(ChallengeSessionService challengeSessionService) : ControllerBase
|
|
{
|
|
[HttpGet("{challengeSessionId}")]
|
|
[ProducesResponseType<ChallengeSessionDto>(StatusCodes.Status200OK)]
|
|
[ProducesResponseType<ProblemDetails>(StatusCodes.Status404NotFound)]
|
|
public ActionResult<ChallengeSessionDto> GetChallenge(string challengeSessionId)
|
|
{
|
|
var claimValue = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
|
var userId = long.TryParse(claimValue, out var parsed)
|
|
? parsed
|
|
: throw new InvalidOperationException("当前登录态无效。");
|
|
|
|
var challenge = challengeSessionService.Get(challengeSessionId, userId);
|
|
if (challenge is null)
|
|
{
|
|
return NotFound(new ProblemDetails
|
|
{
|
|
Title = "挑战会话不存在",
|
|
Detail = "未找到对应的挑战会话。",
|
|
Status = StatusCodes.Status404NotFound
|
|
});
|
|
}
|
|
|
|
return Ok(challenge);
|
|
}
|
|
}
|