Add avatar support
This commit is contained in:
47
src/API/Controllers/Avatar/V1/AvatarController.cs
Normal file
47
src/API/Controllers/Avatar/V1/AvatarController.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -50,4 +50,4 @@ public class ProfilesController(IProfileService profileService) : ControllerBase
|
||||
ExpiresIn = result.ExpiresIn
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user