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.

93 lines
2.5 KiB
C#

1 year ago
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
using DS.WMS.Core.System.Interface;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace DS.WMS.Core.System.Method;
/// <summary>
///
/// </summary>
public class TenantService : ITenantService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public TenantService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DataResult<List<SysTenant>> GetListByPage(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<SysTenant>()
.Where(whereList).ToQueryPage(request.PageCondition);
return data;
}
1 year ago
/// <summary>
///
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
11 months ago
public DataResult EditTenant(TenantReq model)
1 year ago
{
if (model.Id.IsNullOrEmpty())
{
var isExist = db.Queryable<SysTenant>().Where(x => x.TaxNo == model.TaxNo).First();
1 year ago
if (isExist != null)
{
return DataResult.Failed("租户唯一编码已存在!");
}
11 months ago
var data = model.MapTo<TenantReq, SysTenant>();
1 year ago
db.Insertable(data).ExecuteCommand();
return DataResult.Successed("添加成功!");
}
else
{
var info = db.Queryable<SysTenant>().Where(x => x.Id == model.Id).First();
11 months ago
info = model.MapTo<TenantReq, SysTenant>();
1 year ago
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
return DataResult.Successed("更新成功!");
}
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public DataResult<SysTenant> GetTenantInfo(string id)
{
var data = db.Queryable<SysTenant>()
.Where(a => a.Id ==long.Parse(id))
1 year ago
.First();
return DataResult<SysTenant>.Success(data);
}
1 year ago
}