first commit
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using Fitness_core_BE.DTOs.TimeBankCard;
|
||||
using Fitness_core_BE.Helpers;
|
||||
using Fitness_core_BE.Interfaces.Services;
|
||||
using Fitness_core_BE.Models.IOs;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using static Fitness_core_BE.Helpers.JwtMiddleware;
|
||||
using static Fitness_core_BE.Helpers.ApiResponseHelper;
|
||||
|
||||
namespace Fitness_core_BE.Controllers
|
||||
{
|
||||
// Same absolute-per-route reasoning as BookingController: staff issue/swipe under
|
||||
// "api/client/...", a member's own card list under "api/app/...". This is the
|
||||
// staff-facing manual swipe terminal; AgentController's own "time-bank-cards/redeem"
|
||||
// exposes the same tap-in/tap-out swipe to an RFID-reader-equipped agent station instead.
|
||||
[ApiController]
|
||||
public class TimeBankCardController : ControllerBase
|
||||
{
|
||||
private readonly ITimeBankCardService _timeBankCardService;
|
||||
|
||||
public TimeBankCardController(ITimeBankCardService timeBankCardService)
|
||||
{
|
||||
_timeBankCardService = timeBankCardService;
|
||||
}
|
||||
|
||||
[CustomMiddleware]
|
||||
[TenantResolution]
|
||||
[RequiresPermission("bookings")]
|
||||
[HttpPost("api/client/time-bank-cards")]
|
||||
public async Task<ActionResult<ApiResponse<object>>> IssueCard([FromBody] IssueTimeBankCardRequest request)
|
||||
=> Response(await _timeBankCardService.IssueCard(new
|
||||
{
|
||||
rfidTagId = request.RfidTagId,
|
||||
totalMinutesPurchased = request.TotalMinutesPurchased,
|
||||
amountPaid = request.AmountPaid,
|
||||
customerId = request.CustomerId,
|
||||
expiresAt = request.ExpiresAt?.ToString("o")
|
||||
}, HttpContext));
|
||||
|
||||
[CustomMiddleware]
|
||||
[TenantResolution]
|
||||
[RequiresPermission("bookings")]
|
||||
[HttpPost("api/client/time-bank-cards/redeem")]
|
||||
public async Task<ActionResult<ApiResponse<object>>> Swipe([FromBody] SwipeTimeBankCardRequest request)
|
||||
=> Response(await _timeBankCardService.Swipe(new
|
||||
{
|
||||
rfidTagId = request.RfidTagId,
|
||||
facilityId = request.FacilityId
|
||||
}));
|
||||
|
||||
[CustomMiddleware]
|
||||
[TenantResolution]
|
||||
[RequiresPermission("bookings")]
|
||||
[HttpGet("api/client/time-bank-cards/{rfidTagId}")]
|
||||
public async Task<ActionResult<ApiResponse<object>>> GetBalance(string rfidTagId)
|
||||
=> Response(await _timeBankCardService.GetBalance(new { rfidTagId }));
|
||||
|
||||
[CustomMiddleware]
|
||||
[TenantResolution]
|
||||
[HttpGet("api/app/time-bank-cards/mine")]
|
||||
public async Task<ActionResult<ApiResponse<object>>> GetMyCards()
|
||||
=> Response(await _timeBankCardService.GetMyCards(new { }, HttpContext));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user