fix 查询条件调整
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using Dlhis.Canteen.Order.Repository;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.Canteen.Setting.Response;
|
||||
using Dlhis.Canteen.Setting.Services;
|
||||
using Kurisu.AspNetCore.Authentication.Abstractions;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -16,14 +15,10 @@ namespace Dlhis.Canteen.Setting.Controllers;
|
||||
public class WalletsController : ControllerBase
|
||||
{
|
||||
private readonly IWalletService _walletService;
|
||||
private readonly IBalanceRepository _balanceRepository;
|
||||
private readonly ICurrentUser _currentUser;
|
||||
|
||||
public WalletsController(IWalletService walletService, IBalanceRepository balanceRepository, ICurrentUser currentUser)
|
||||
public WalletsController(IWalletService walletService)
|
||||
{
|
||||
_walletService = walletService;
|
||||
_balanceRepository = balanceRepository;
|
||||
_currentUser = currentUser;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -39,12 +34,11 @@ public class WalletsController : ControllerBase
|
||||
/// <summary>
|
||||
/// 余额
|
||||
/// </summary>
|
||||
/// <param name="factory"></param>
|
||||
/// <param name="walletCode">钱包code</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("balance")]
|
||||
public async Task<decimal> GetBalanceAsync(string factory)
|
||||
public async Task<decimal> GetBalanceAsync([Required] string walletCode)
|
||||
{
|
||||
var code = _currentUser.GetUserClaim("jinko-code");
|
||||
return await _balanceRepository.GetBalanceAsync(code, factory);
|
||||
return await _walletService.GetBalanceAsync(walletCode);
|
||||
}
|
||||
}
|
||||
@@ -5,4 +5,6 @@ namespace Dlhis.Canteen.Setting.Services;
|
||||
public interface IWalletService : IScopeDependency
|
||||
{
|
||||
Task<List<WalletResponse>> GetListAsync();
|
||||
|
||||
Task<decimal> GetBalanceAsync(string walletCode);
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
using Dlhis.Canteen.Order.Repository;
|
||||
using Dlhis.Canteen.Setting.Response;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Kurisu.AspNetCore.Authentication.Abstractions;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using SqlSugar;
|
||||
|
||||
@@ -8,10 +10,14 @@ namespace Dlhis.Canteen.Setting.Services.Implements;
|
||||
public class WalletService : IWalletService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ICurrentUser _currentUser;
|
||||
private readonly IBalanceRepository _balanceRepository;
|
||||
|
||||
public WalletService(IDbContext dbContext)
|
||||
public WalletService(IDbContext dbContext, ICurrentUser currentUser, IBalanceRepository balanceRepository)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_currentUser = currentUser;
|
||||
_balanceRepository = balanceRepository;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -27,4 +33,13 @@ public class WalletService : IWalletService
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<decimal> GetBalanceAsync(string walletCode)
|
||||
{
|
||||
var userCode = _currentUser.GetUserClaim("jinko-code");
|
||||
var factory = await _dbContext.Queryable<WalletEntity>().Where(x => x.Code == walletCode).Select(x => x.Factory).FirstAsync();
|
||||
|
||||
return await _balanceRepository.GetBalanceAsync(userCode, factory);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user