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.

124 lines
4.7 KiB
C#

using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.UserModule;
using DS.WMS.Core.Sys.Dtos;
using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.Sys.Interface;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using Org.BouncyCastle.Ocsp;
using SqlSugar;
namespace DS.WMS.Core.Sys.Method
{
public class TenantParamService : ITenantParamService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ICommonService _commonService;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public TenantParamService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
_commonService = _serviceProvider.GetRequiredService<ICommonService>();
}
public DataResult EditTenantParam(TenantParamReq req)
{
if (req.Id == 0)
{
var isExist = db.Queryable<SysTenantParam>().Where(x => x.ParamCode == req.ParamCode).First();
if (isExist != null)
{
return DataResult.Failed("租户参数唯一编码已存在!");
}
var data = req.Adapt<SysTenantParam>();
var entity = db.Insertable(data).ExecuteReturnEntity();
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
}
else
{
var info = db.Queryable<SysTenantParam>().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 EditTenantParamData(TenantParamDataReq req)
{
if (req.Id == 0)
{
var isExist = db.Queryable<SysTenantParamData>().Where(x => x.ParamId == req.ParamId && x.ItemCode == req.ItemCode).First();
if (isExist != null)
{
return DataResult.Failed("租户参数值唯一编码已存在!");
}
var data = req.Adapt<SysTenantParamData>();
var entity = db.Insertable(data).ExecuteReturnEntity();
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
}
else
{
var info = db.Queryable<SysTenantParamData>().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<List<TenantParamRes>> GetListByPage(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<SysTenantParam>()
.Select<TenantParamRes>()
.Where(whereList).ToQueryPage(request.PageCondition);
return data;
}
public DataResult<TenantParamDataRes> GetTenantParamDataInfo(string id)
{
var data = db.Queryable<SysTenantParamData>()
.Where(a => a.Id == long.Parse(id))
.Select<TenantParamDataRes>()
.First();
return DataResult<TenantParamDataRes>.Success(data, MultiLanguageConst.DataQuerySuccess);
}
public DataResult<List<TenantParamDataRes>> GetTenantParamDataList(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<SysTenantParamData>()
.Select<TenantParamDataRes>()
.Where(whereList).ToQueryPage(request.PageCondition);
return data;
}
public DataResult<TenantParamRes> GetTenantParamInfo(string id)
{
var data = db.Queryable<SysTenantParam>()
.Where(a => a.Id == long.Parse(id))
.Select<TenantParamRes>()
.First();
return DataResult<TenantParamRes>.Success(data, MultiLanguageConst.DataQuerySuccess);
}
}
}