SoftTraderBackend/Controller/UserInterestController.cs
2026-03-21 09:16:59 -04:00

51 lines
1.2 KiB
C#

using Backend.ServiceHandler;
using Backend.Interface;
using Microsoft.AspNetCore.Mvc;
namespace Backend.Controllers
{
[ApiController]
[Route("api/user-interest")]
public sealed class UserInterestController : ControllerBase
{
private readonly IUserInterestStore _store;
public UserInterestController(IUserInterestStore store)
{
_store = store;
}
[HttpGet("fetch")]
public async Task<ActionResult<UserInterestFetchResponse>> FetchAll(
[FromQuery] string user,
[FromQuery] string type)
{
List<string> items = await _store.FetchAllAsync(user, type);
return Ok(new UserInterestFetchResponse
{
Items = items
});
}
[HttpPost("add")]
public async Task<ActionResult<BoolResponse>> Add(
[FromQuery] string user,
[FromQuery] string type,
[FromQuery] string value)
{
bool success = await _store.AddAsync(user, type, value);
return Ok(new BoolResponse { Success = success });
}
[HttpDelete("remove")]
public async Task<ActionResult<BoolResponse>> Remove(
[FromQuery] string user,
[FromQuery] string type,
[FromQuery] string value)
{
bool success = await _store.RemoveAsync(user, type, value);
return Ok(new BoolResponse { Success = success });
}
}
}