|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
|
using Entity.Dto.Req;
|
|
|
|
|
using HybirdFrameworkCore.Autofac.Attribute;
|
|
|
|
|
using HybirdFrameworkCore.Entity;
|
|
|
|
|
using log4net;
|
|
|
|
|
using Repository.Station;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
namespace Service.Station;
|
|
|
|
|
|
|
|
|
|
[Scope("SingleInstance")]
|
|
|
|
|
public class SwapFailReasonConfigService : BaseServices<SwapFailReasonConfig>
|
|
|
|
|
{
|
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(SwapFailReasonConfigService));
|
|
|
|
|
|
|
|
|
|
private SwapFailReasonConfigRepository _swapFailReasonConfigRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public SwapFailReasonConfigService(SwapFailReasonConfigRepository swapFailReasonConfigRepository)
|
|
|
|
|
{
|
|
|
|
|
_swapFailReasonConfigRepository = swapFailReasonConfigRepository;
|
|
|
|
|
BaseDal = swapFailReasonConfigRepository;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<PageResult<SwapFailReasonConfig>> Page(PageSwapFailReasonConfigReq input)
|
|
|
|
|
{
|
|
|
|
|
RefAsync<int> total = 0;
|
|
|
|
|
var items = await _swapFailReasonConfigRepository.QueryPageAsync(
|
|
|
|
|
entity => true,
|
|
|
|
|
false, entity => true,
|
|
|
|
|
false, entity => true,
|
|
|
|
|
input.FailReason != null, (u => input.FailReason != null && u.FailReason.Equals(input.FailReason)),
|
|
|
|
|
u => u.CreatedTime, input.PageNum, input.PageSize, total
|
|
|
|
|
);
|
|
|
|
|
return new PageResult<SwapFailReasonConfig>()
|
|
|
|
|
{
|
|
|
|
|
PageNum = input.PageNum,
|
|
|
|
|
PageSize = input.PageSize,
|
|
|
|
|
ToTal = total,
|
|
|
|
|
Rows = items,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<string> Add(AddSwapFailReasonConfigReq input)
|
|
|
|
|
{
|
|
|
|
|
SwapFailReasonConfig swapFailReasonConfig = await _swapFailReasonConfigRepository.InsertAsync(input);
|
|
|
|
|
return "新增id:" + swapFailReasonConfig.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual async Task<bool> Update(UpdateSwapFailReasonConfigReq req)
|
|
|
|
|
{
|
|
|
|
|
return await _swapFailReasonConfigRepository.UpdateAsync(req);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public virtual async Task<bool> Delete(DeleteSwapFailReasonConfigpReq input)
|
|
|
|
|
{
|
|
|
|
|
var user = await _swapFailReasonConfigRepository.QueryByClauseAsync(u => u.Id == input.Id);
|
|
|
|
|
if (user == null)
|
|
|
|
|
throw new ArgumentException($"电池异常原因不存在");
|
|
|
|
|
return await _swapFailReasonConfigRepository.DeleteAsync(user);
|
|
|
|
|
}
|
|
|
|
|
}
|