You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ds8-solution-pro/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateDetailServic...

76 lines
2.9 KiB
C#

using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface;
using Mapster;
namespace DS.WMS.Core.Fee.Method
{
/// <summary>
/// 往来单位费用模板明细
/// </summary>
public class FeeCustTemplateDetailService : FeeServiceBase, IFeeCustTemplateDetailService
{
/// <summary>
/// 初始化
/// </summary>
/// <param name="serviceProvider"></param>
public FeeCustTemplateDetailService(IServiceProvider serviceProvider) : base(serviceProvider)
{
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DataResult<List<FeeCustTemplateDetailRes>> GetListByPage(PageRequest request)
{
//序列化查询条件
var whereList = request.GetConditionalModels(Db);
var data = TenantDb.Queryable<FeeCustTemplateDetail>().Where(whereList)
.Select<FeeCustTemplateDetailRes>().ToQueryPage(request.PageCondition);
return data;
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public async Task<DataResult> EditAsync(FeeCustTemplateDetailReq req)
{
if (req.Id == 0)
{
if (TenantDb.Queryable<FeeCustTemplateDetail>().Where(x => x.FeeId == req.FeeId && x.TemplateId == req.TemplateId).Any())
return DataResult.Failed("往来单位固定费用已存在!", MultiLanguageConst.FeeCustTemplateDetailExist);
var data = req.Adapt<FeeCustTemplateDetail>();
var entity = await TenantDb.Insertable(data).ExecuteReturnEntityAsync();
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
}
else
{
var info = TenantDb.Queryable<FeeCustTemplateDetail>().Where(x => x.Id == req.Id).First();
info = req.Adapt(info);
await TenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
}
}
/// <summary>
/// 根据ID批量删除
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public async Task<DataResult> DeleteAsync(IdModel model)
{
int rows = await TenantDb.Deleteable<FeeCustTemplateDetail>().Where(x => model.Ids.Contains(x.Id)).ExecuteCommandAsync();
return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
}
}