Files
jinko.yikatong/Src/Dlhis.Canteen/Setting/Controllers/WalletsController.cs

50 lines
1.4 KiB
C#

using Dlhis.Canteen.Order.Repository;
using Dlhis.Canteen.Setting.Response;
using Dlhis.Canteen.Setting.Services;
using Kurisu.AspNetCore.Authentication.Abstractions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Dlhis.Canteen.Setting.Controllers;
/// <summary>
/// 钱包
/// </summary>
[Authorize]
[Route("api/[controller]")]
[ApiController]
public class WalletsController : ControllerBase
{
private readonly IWalletService _walletService;
private readonly IBalanceRepository _balanceRepository;
private readonly ICurrentUser _currentUser;
public WalletsController(IWalletService walletService, IBalanceRepository balanceRepository, ICurrentUser currentUser)
{
_walletService = walletService;
_balanceRepository = balanceRepository;
_currentUser = currentUser;
}
/// <summary>
/// 钱包列表
/// </summary>
/// <returns></returns>
[HttpGet("list")]
public async Task<List<WalletResponse>> GetListAsync()
{
return await _walletService.GetListAsync();
}
/// <summary>
/// 余额
/// </summary>
/// <param name="factory"></param>
/// <returns></returns>
[HttpGet("balance")]
public async Task<decimal> GetBalanceAsync(string factory)
{
var code = _currentUser.GetUserClaim("jinko-code");
return await _balanceRepository.GetBalanceAsync(code, factory);
}
}