|
|
|
|
namespace Ds.WMS.Finance.MediatR.handlers
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 具体的业务逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class GetCostBasicHandler : IRequestHandler<CostExchangeRateCommand, CurrencyDto>
|
|
|
|
|
{
|
|
|
|
|
private readonly ISqlSugarClient _db;
|
|
|
|
|
public GetCostBasicHandler(ISqlSugarClient db)
|
|
|
|
|
{
|
|
|
|
|
_db = db;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 具体的业务逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <param name="cancellationToken"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
async Task<CurrencyDto> IRequestHandler<CostExchangeRateCommand, CurrencyDto>.Handle(CostExchangeRateCommand request, CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
var list = await _db.Queryable<Code_Currency>()
|
|
|
|
|
.Where(x => x.Id == request.Id)
|
|
|
|
|
.Select<CurrencyDto>()
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
return await Task.FromResult(list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class AddCostBasicHandler : IRequestHandler<CostExchangeForAddCommand, bool>
|
|
|
|
|
{
|
|
|
|
|
private readonly ISqlSugarClient _db;
|
|
|
|
|
public AddCostBasicHandler(ISqlSugarClient db)
|
|
|
|
|
{
|
|
|
|
|
_db = db;
|
|
|
|
|
}
|
|
|
|
|
public async Task<bool> Handle(CostExchangeForAddCommand request, CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
var list = await _db.Insertable<Code_Currency>(new Code_Currency()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
CodeName = request.CodeName,
|
|
|
|
|
DefaultRate = request.DefaultRate,
|
|
|
|
|
Description = request.Description,
|
|
|
|
|
FinanceSoftCodes = request.FinanceSoftCodes,
|
|
|
|
|
Name = request.Name
|
|
|
|
|
|
|
|
|
|
}).ExecuteCommandAsync() > 0;
|
|
|
|
|
return await Task.FromResult(list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class DelCostBasicHandler : IRequestHandler<CostExchangeForDelCommand, bool>
|
|
|
|
|
{
|
|
|
|
|
private readonly ISqlSugarClient _db;
|
|
|
|
|
public DelCostBasicHandler(ISqlSugarClient db)
|
|
|
|
|
{
|
|
|
|
|
_db = db;
|
|
|
|
|
}
|
|
|
|
|
public async Task<bool> Handle(CostExchangeForDelCommand request, CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
var list = await _db.Updateable<Code_Currency>()
|
|
|
|
|
.Where(p => p.Id.Equals(request.Id))
|
|
|
|
|
.IgnoreColumns(true)
|
|
|
|
|
.SetColumns(p => p.DsIsDel == true)
|
|
|
|
|
.ExecuteCommandAsync() > 0;
|
|
|
|
|
return await Task.FromResult(list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|