Add player settings feature and settings API
This commit is contained in:
@@ -21,9 +21,9 @@ public class ProfilesController(IProfileService profileService) : ControllerBase
|
||||
return profile;
|
||||
}
|
||||
|
||||
[HttpGet("bulk")]
|
||||
[HttpPost("bulk")]
|
||||
public async Task<IReadOnlyList<ProfileDTO>> GetBulkProfiles(
|
||||
[FromQuery(Name = "id")] List<Guid> ids,
|
||||
[FromBody] List<Guid> ids,
|
||||
CancellationToken ct)
|
||||
=> await profileService.GetProfilesAsync(ids, ct);
|
||||
|
||||
|
||||
40
src/API/Controllers/Settings/V1/SettingsController.cs
Normal file
40
src/API/Controllers/Settings/V1/SettingsController.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using RecNet.Application.Common.Security;
|
||||
using RecNet.Application.Profiles;
|
||||
|
||||
namespace API.Controllers.Settings.V1;
|
||||
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
[Route("api/[controller]/v1")]
|
||||
public class SettingsController(IProfileService profileService) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<IReadOnlyList<PlayerSettingDTO>> GetAllAsync(CancellationToken ct)
|
||||
{
|
||||
var profileId = User.GetProfileId();
|
||||
|
||||
return await profileService.GetPlayerSettingsAsync(profileId, ct);
|
||||
}
|
||||
|
||||
[HttpPost("set")]
|
||||
public async Task<IActionResult> SetAsync(
|
||||
[FromBody] PlayerSettingDTO request,
|
||||
CancellationToken ct)
|
||||
{
|
||||
var profileId = User.GetProfileId();
|
||||
|
||||
var updated = await profileService.UpdatePlayerSettingAsync
|
||||
(
|
||||
profileId: profileId,
|
||||
command: new UpdatePlayerSettingCommand(request.Key, request.Value),
|
||||
ct: ct
|
||||
);
|
||||
|
||||
if (!updated)
|
||||
return NotFound();
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user