|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using Entity.Base;
|
|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
|
using Entity.DbModel.System;
|
|
|
|
|
using Entity.Dto.Req;
|
|
|
|
|
using HybirdFrameworkCore.Autofac.Attribute;
|
|
|
|
|
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<SqlSugarPagedList<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.Page, input.PageSize, total
|
|
|
|
|
);
|
|
|
|
|
return SqlSugarPagedExtensions.CreateSqlSugarPagedList(items, total, input.Page, input.PageSize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <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);
|
|
|
|
|
}
|
|
|
|
|
}
|