feat(degree): /degree/degree_list returns owned ids

This commit is contained in:
gamer147
2026-06-13 08:11:13 -04:00
parent 025c2a8c56
commit 68741b2980
5 changed files with 126 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using SVSim.Database;
using SVSim.EmulatedEntrypoint.Models.Dtos.Common;
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests;
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests.Degree;
using SVSim.EmulatedEntrypoint.Models.Dtos.Responses.Degree;
namespace SVSim.EmulatedEntrypoint.Controllers;
/// <summary>
/// /degree/* — viewer-scoped degree (title) management. Read, mark-favorite, set-currently-displayed.
/// Mirrors /sleeve/* and /emblem/*; favorite handler is no-op like the others until a viewer-favorites
/// schema lands (would also serve /sleeve/favorite + /emblem/favorite via the shared Wizard/FavoriteTask.cs Kind enum).
/// </summary>
[Route("degree")]
public class DegreeController : SVSimController
{
private readonly SVSimDbContext _db;
public DegreeController(SVSimDbContext db) => _db = db;
[HttpPost("degree_list")]
public async Task<ActionResult<DegreeListResponse>> DegreeList(DegreeListRequest _, CancellationToken ct)
{
if (!TryGetViewerId(out long viewerId)) return Unauthorized();
var viewer = await _db.Viewers
.Include(v => v.Degrees)
.FirstOrDefaultAsync(v => v.Id == viewerId, ct);
if (viewer is null) return Unauthorized();
return new DegreeListResponse
{
UserDegreeList = viewer.Degrees
.Select(d => new DegreeListEntry { DegreeId = d.Id })
.OrderBy(e => e.DegreeId)
.ToList(),
};
}
}