feat(profile): /profile/update_official_mark_display
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
Reference in New Issue
Block a user