Add avatar support

This commit is contained in:
Holden
2026-06-20 15:33:46 -05:00
parent 942bb4c80b
commit e24a4c6872
15 changed files with 365 additions and 9 deletions

View File

@@ -0,0 +1,47 @@
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using RecNet.Application.Common.Security;
using RecNet.Application.Profiles;
using AvatarEntity = RecNet.Domain.Profiles.Avatar;
namespace API.Controllers.Avatar.V1;
[Authorize]
[ApiController]
[Route("api/[controller]/v1")]
public class AvatarController(IProfileService profileService) : ControllerBase
{
[HttpGet]
public async Task<ActionResult<AvatarDTO>> GetAvatar(
CancellationToken ct)
{
var profileId = User.GetProfileId();
var avatar = await profileService.GetAvatarAsync(profileId, ct);
if (avatar == null)
return NotFound();
return avatar;
}
[HttpPost("set")]
public async Task<ActionResult<AvatarDTO>> UpdateAvatar(
[FromBody] AvatarDTO request,
CancellationToken ct)
{
var profileId = User.GetProfileId();
var avatar = await profileService.UpdateAvatarAsync(
profileId,
new UpdateAvatarCommand(
request.OutfitSelections,
request.SkinColor,
request.HairColor),
ct);
if (avatar == null)
return NotFound();
return avatar;
}
}

View File

@@ -50,4 +50,4 @@ public class ProfilesController(IProfileService profileService) : ControllerBase
ExpiresIn = result.ExpiresIn
};
}
}
}