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.

87 lines
2.9 KiB

using System.ComponentModel;
using Entity.Base;
using Entity.DbModel.Station;
using Entity.DbModel.System;
using Entity.Dto.Req;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Entity;
using Repository.Station;
using SqlSugar;
namespace Service.Station;
[Scope("SingleInstance")]
public class BatteryOpModelService : BaseServices<BatteryOpModel>
{
private BatteryOpModelRepository _batteryOpModelRepository;
public BatteryOpModelService(BatteryOpModelRepository dal)
{
_batteryOpModelRepository = dal;
BaseDal = dal;
}
/// <summary>
/// 电池运营模型分页列表 🔖
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[DisplayName("获取电池运营模型分页列表")]
public async Task<PageResult<BatteryOpModel>> Page(PageBatteryOpReq input)
{
RefAsync<int> total = 0;
var items = await _batteryOpModelRepository.QueryPageAsync(
entity => true,
false, entity => true,
false, entity => true,
input.ModelId != null, (u => input.ModelId != null && u.ModelId.Equals(input.ModelId.Value)),
u => u.CreatedTime, input.PageNum, input.PageSize, total
);
return new PageResult<BatteryOpModel>()
{
PageNum = input.PageNum,
PageSize = input.PageSize,
ToTal = total,
Rows = items,
};
}
/// <summary>
/// 增加电池运营模型 🔖
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<string> AddBatteryOpModel(AddBatteryOpReq input)
{
string result = "";
var isExist = await _batteryOpModelRepository.QueryByClauseAsync(u => u.ModelId == input.ModelId);
if (isExist != null)
return result = "模型id已存在";
await _batteryOpModelRepository.InsertAsync(input);
BatteryOpModel batteryOpModel =
await _batteryOpModelRepository.QueryByClauseAsync(u => u.ModelId == input.ModelId);
return result = "新增id" + batteryOpModel.Id;
}
/// <summary>
/// 更新电池运营模型 🔖
/// </summary>
/// <returns></returns>
public virtual async Task<bool> UpdateBatteryOpModel(UpdateBatteryOpReq batteryOpReq)
{
return await _batteryOpModelRepository.UpdateAsync(batteryOpReq);
}
/// <summary>
/// 删除电池运营模型 🔖
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public virtual async Task<bool> DeleteBatteryOpModel(DeleteBatteryOpReq input)
{
var user = await _batteryOpModelRepository.QueryByClauseAsync(u => u.Id == input.Id);
if (user == null)
throw new ArgumentException($"电池运营模型不存在");
return await _batteryOpModelRepository.DeleteAsync(user);
}
}