feat(profile): /profile/update_official_mark_display

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-12 22:54:52 -04:00
parent 37cb8b5eeb
commit 398764a4cc
3 changed files with 69 additions and 1 deletions

View File

@@ -1,8 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using SVSim.Database;
using SVSim.Database.Repositories.Viewer;
using SVSim.EmulatedEntrypoint.Constants;
using SVSim.EmulatedEntrypoint.Models.Dtos;
using SVSim.EmulatedEntrypoint.Models.Dtos.Common;
using SVSim.EmulatedEntrypoint.Models.Dtos.Profile;
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests.Profile;
namespace SVSim.EmulatedEntrypoint.Controllers;
@@ -14,9 +18,13 @@ namespace SVSim.EmulatedEntrypoint.Controllers;
public sealed class ProfileController : SVSimController
{
private readonly IViewerRepository _viewerRepository;
private readonly SVSimDbContext _db;
public ProfileController(IViewerRepository viewerRepository) =>
public ProfileController(IViewerRepository viewerRepository, SVSimDbContext db)
{
_viewerRepository = viewerRepository;
_db = db;
}
[HttpPost("index")]
public async Task<ActionResult<ProfileIndexResponse>> Index(
@@ -48,4 +56,18 @@ public sealed class ProfileController : SVSimController
UserClassList = classes,
};
}
[HttpPost("update_official_mark_display")]
public async Task<ActionResult<EmptyResponse>> UpdateOfficialMarkDisplay(
ProfileUpdateOfficialMarkDisplayRequest request,
CancellationToken ct)
{
if (!TryGetViewerId(out long viewerId)) return Unauthorized();
var viewer = await _db.Viewers.FirstAsync(v => v.Id == viewerId, ct);
viewer.Info.IsOfficialMarkDisplayed = request.IsOfficialMarkDisplayed != 0;
await _db.SaveChangesAsync(ct);
return new EmptyResponse();
}
}

View File

@@ -0,0 +1,13 @@
// SVSim.EmulatedEntrypoint/Models/Dtos/Requests/Profile/ProfileUpdateOfficialMarkDisplayRequest.cs
using MessagePack;
using System.Text.Json.Serialization;
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Requests.Profile;
[MessagePackObject]
public class ProfileUpdateOfficialMarkDisplayRequest : BaseRequest
{
[JsonPropertyName("is_official_mark_displayed")]
[Key("is_official_mark_displayed")]
public int IsOfficialMarkDisplayed { get; set; }
}