You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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);
}
}