|
|
|
using DS.Module.Core;
|
|
|
|
using DS.Module.Core.Data;
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
using DS.WMS.Core.Info.Dtos;
|
|
|
|
using DS.WMS.Core.Info.Entity;
|
|
|
|
using DS.WMS.Core.Info.Interface;
|
|
|
|
using Mapster;
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Info.Method;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 往来单位收发货人
|
|
|
|
/// </summary>
|
|
|
|
public class ClientShipperService : ServiceBase, IClientShipperService
|
|
|
|
{
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 初始化
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="serviceProvider"></param>
|
|
|
|
public ClientShipperService(IServiceProvider serviceProvider) : base(serviceProvider)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 列表
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public DataResult<List<ClientShipperRes>> GetListByPage(PageRequest request)
|
|
|
|
{
|
|
|
|
//序列化查询条件
|
|
|
|
var whereList = request.GetConditionalModels(Db);
|
|
|
|
var data = TenantDb.Queryable<InfoClientShipper>()
|
|
|
|
.Where(whereList)
|
|
|
|
.Select<ClientShipperRes>().ToQueryPage(request.PageCondition);
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 编辑
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="req"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public DataResult EditClientShipper(ClientShipperReq req)
|
|
|
|
{
|
|
|
|
if (req.Id == 0)
|
|
|
|
{
|
|
|
|
if (TenantDb.Queryable<InfoClientShipper>().Where(x=>x.ClientId == req.ClientId && x.CodeName == req.CodeName).Any())
|
|
|
|
{
|
|
|
|
return DataResult.Failed("客户收发货人信息已存在!",MultiLanguageConst.ClientShipperExist);
|
|
|
|
}
|
|
|
|
|
|
|
|
var data = req.Adapt<InfoClientShipper>();
|
|
|
|
|
|
|
|
var entity = TenantDb.Insertable(data).ExecuteReturnEntity();
|
|
|
|
|
|
|
|
return DataResult.Successed("添加成功!", entity.Id,MultiLanguageConst.DataCreateSuccess);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var info = TenantDb.Queryable<InfoClientShipper>().Where(x => x.Id == req.Id).First();
|
|
|
|
|
|
|
|
info = req.Adapt(info);
|
|
|
|
|
|
|
|
TenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
|
|
|
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 详情
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public DataResult<ClientShipperRes> GetClientShipperInfo(string id)
|
|
|
|
{
|
|
|
|
var data = TenantDb.Queryable<InfoClientShipper>()
|
|
|
|
.Where(a => a.Id == long.Parse(id))
|
|
|
|
.Select<ClientShipperRes>()
|
|
|
|
.First();
|
|
|
|
return DataResult<ClientShipperRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 根据ID批量删除
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="model"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public async Task<DataResult> DeleteAsync(IdModel model)
|
|
|
|
{
|
|
|
|
int rows = await TenantDb.Deleteable<InfoClientShipper>().Where(x => model.Ids.Contains(x.Id)).ExecuteCommandAsync();
|
|
|
|
return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
|
|
|
|
}
|
|
|
|
}
|