|
|
|
using DS.Module.Core;
|
|
|
|
using DS.Module.Core.Data;
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
using DS.Module.SqlSugar;
|
|
|
|
using DS.Module.UserModule;
|
|
|
|
using DS.WMS.Core.Code.Dtos;
|
|
|
|
using DS.WMS.Core.Code.Entity;
|
|
|
|
using DS.WMS.Core.Code.Interface;
|
|
|
|
using Mapster;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Code.Method;
|
|
|
|
|
|
|
|
public class CodeSourceDetailService:ICodeSourceDetailService
|
|
|
|
{
|
|
|
|
private readonly IServiceProvider _serviceProvider;
|
|
|
|
private readonly ISqlSugarClient db;
|
|
|
|
private readonly IUser user;
|
|
|
|
private readonly ISaasDbService saasService;
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="serviceProvider"></param>
|
|
|
|
public CodeSourceDetailService(IServiceProvider serviceProvider)
|
|
|
|
{
|
|
|
|
_serviceProvider = serviceProvider;
|
|
|
|
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
|
|
user = _serviceProvider.GetRequiredService<IUser>();
|
|
|
|
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
|
|
|
|
}
|
|
|
|
|
|
|
|
public DataResult<List<CodeSourceDetailRes>> GetListByPage(PageRequest request)
|
|
|
|
{
|
|
|
|
//序列化查询条件
|
|
|
|
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
var data = db.Queryable<CodeSourceDetail>()
|
|
|
|
.Where(whereList)
|
|
|
|
.Select<CodeSourceDetailRes>().ToQueryPage(request.PageCondition);
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
public DataResult EditCodeSourceDetail(CodeSourceDetailReq req)
|
|
|
|
{
|
|
|
|
if (req.Id == 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (db.Queryable<CodeSourceDetail>().Where(x=>x.DetailName == req.DetailName.Trim()).Any())
|
|
|
|
{
|
|
|
|
return DataResult.Failed("业务来源明细信息已存在!",MultiLanguageConst.CodeSourceDetailExist);
|
|
|
|
}
|
|
|
|
|
|
|
|
var data = req.Adapt<CodeSourceDetail>();
|
|
|
|
|
|
|
|
var entity = db.Insertable(data).ExecuteReturnEntity();
|
|
|
|
|
|
|
|
return DataResult.Successed("添加成功!", entity.Id,MultiLanguageConst.DataCreateSuccess);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var info = db.Queryable<CodeSourceDetail>().Where(x => x.Id == req.Id).First();
|
|
|
|
|
|
|
|
info = req.Adapt(info);
|
|
|
|
|
|
|
|
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
|
|
|
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public DataResult<CodeSourceDetailRes> GetCodeSourceDetailInfo(string id)
|
|
|
|
{
|
|
|
|
var data = db.Queryable<CodeSourceDetail>()
|
|
|
|
.Where(a => a.Id == long.Parse(id))
|
|
|
|
.Select<CodeSourceDetailRes>()
|
|
|
|
.First();
|
|
|
|
return DataResult<CodeSourceDetailRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
|
|
|
|
}
|
|
|
|
|
|
|
|
public DataResult<List<CodeSourceDetailRes>> GetClientListByPage(PageRequest request)
|
|
|
|
{
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
//序列化查询条件
|
|
|
|
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
var data = tenantDb.Queryable<CodeSourceDetail>()
|
|
|
|
.Where(whereList)
|
|
|
|
.Select<CodeSourceDetailRes>().ToQueryPage(request.PageCondition);
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
public DataResult EditClientCodeSourceDetail(CodeSourceDetailReq req)
|
|
|
|
{
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
if (req.Id == 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (tenantDb.Queryable<CodeSourceDetail>().Where(x=>x.DetailName == req.DetailName.Trim()).Any())
|
|
|
|
{
|
|
|
|
return DataResult.Failed("业务来源明细信息已存在!",MultiLanguageConst.CodeSourceDetailExist);
|
|
|
|
}
|
|
|
|
|
|
|
|
var data = req.Adapt<CodeSourceDetail>();
|
|
|
|
|
|
|
|
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
|
|
|
|
|
|
|
|
return DataResult.Successed("添加成功!", entity.Id,MultiLanguageConst.DataCreateSuccess);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var info = tenantDb.Queryable<CodeSourceDetail>().Where(x => x.Id == req.Id).First();
|
|
|
|
|
|
|
|
info = req.Adapt(info);
|
|
|
|
|
|
|
|
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
|
|
|
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public DataResult<CodeSourceDetailRes> GetClientCodeSourceDetailInfo(string id)
|
|
|
|
{
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var data = tenantDb.Queryable<CodeSourceDetail>()
|
|
|
|
.Where(a => a.Id == long.Parse(id))
|
|
|
|
.Select<CodeSourceDetailRes>()
|
|
|
|
.First();
|
|
|
|
return DataResult<CodeSourceDetailRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|