using Dapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XYY.Common.Standard;
using XYY.Core.Standard.Data.Infrastructure;
using XYY.Data.Model.Standard.Tracking;
namespace XYY.Service.Standard.TrackingService
{
public interface ITraceSupplementConfigService
{
///
/// 添加配置
///
///
///
Task AddConfig(Logistics_Trace_SupplementConfig supplementConfig);
///
/// 查找配置
///
///
///
Task> QueryConfig(QueryModel queryModel);
///
/// 获取所有配置
///
///
///
Task> GetAllConfig();
///
/// 编辑配置
///
///
///
Task EditConfig(Logistics_Trace_SupplementConfig supplementConfig);
///
/// 启用
///
///
///
Task Enable(int[] Ids);
///
/// 禁用
///
///
///
Task Disable(int[] Ids);
///
/// 移除
///
///
///
Task Delete(int[] Ids);
}
public class TraceSupplementConfigService : ITraceSupplementConfigService
{
private readonly IUnitOfWork _unitOfWork;
public TraceSupplementConfigService(IUnitOfWork unitOfWork)
{
_unitOfWork = unitOfWork;
}
public async Task AddConfig(Logistics_Trace_SupplementConfig supplementConfig)
{
await _unitOfWork.InsertAsync(supplementConfig);
}
public async Task Delete(int[] Ids)
{
await _unitOfWork.UpdateByConditionAsync(x => x.Id.In(Ids), new
{
IsDelete = true
});
}
public async Task Disable(int[] Ids)
{
await _unitOfWork.UpdateByConditionAsync(x => x.Id.In(Ids), new
{
IsEnable = false
});
}
public async Task EditConfig(Logistics_Trace_SupplementConfig supplementConfig)
{
await _unitOfWork.UpdateAsync(supplementConfig);
}
public async Task Enable(int[] Ids)
{
await _unitOfWork.UpdateByConditionAsync(x => x.Id.In(Ids), new
{
IsEnable = true
});
}
public async Task> GetAllConfig()
{
return (await _unitOfWork.QueryAsync()).ToList();
}
public async Task> QueryConfig(QueryModel queryModel)
{
return await _unitOfWork.GetPagingList2Async(queryModel);
}
}
}