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.
152 lines
5.0 KiB
C#
152 lines
5.0 KiB
C#
using DS.Module.Core;
|
|
using DS.Module.Core.Extensions;
|
|
using DS.Module.UserModule;
|
|
using DS.WMS.Core.System.Dtos;
|
|
using DS.WMS.Core.System.Entity;
|
|
using DS.WMS.Core.System.Interface;
|
|
using Mapster;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using SqlSugar;
|
|
|
|
namespace DS.WMS.Core.System.Method;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class SysDictionaryService:ISysDictionaryService
|
|
{
|
|
private readonly IServiceProvider _serviceProvider;
|
|
private readonly ISqlSugarClient db;
|
|
private readonly IUser user;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="serviceProvider"></param>
|
|
public SysDictionaryService(IServiceProvider serviceProvider)
|
|
{
|
|
_serviceProvider = serviceProvider;
|
|
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
user = _serviceProvider.GetRequiredService<IUser>();
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
public DataResult<List<SysDictionaryViewModel>> GetListByPage(PageRequest request)
|
|
{
|
|
//序列化查询条件
|
|
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
var data = db.Queryable<Sys_Dictionary>().Where(x=>x.DbSql == null || x.DbSql == "" )
|
|
.Select<SysDictionaryViewModel>()
|
|
.Where(whereList).ToQueryPage(request.PageCondition);
|
|
return data;
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public DataResult<SysDictionaryViewModel> GetSysDictionaryInfo(int id)
|
|
{
|
|
var data = db.Queryable<Sys_Dictionary>()
|
|
.Where(a => a.Dic_ID == id)
|
|
.Select<SysDictionaryViewModel>()
|
|
.First();
|
|
return DataResult<SysDictionaryViewModel>.Success(data);
|
|
}
|
|
|
|
public DataResult EditSysDictionaryInfo(SysDictionaryInput model)
|
|
{
|
|
if (model.Dic_ID.ToString().IsNullOrEmpty())
|
|
{
|
|
var isExist = db.Queryable<Sys_Dictionary>().Where(x => x.DicNo == model.DicNo).First();
|
|
if (isExist!=null)
|
|
{
|
|
return DataResult.Failed("字典唯一编码已存在!");
|
|
}
|
|
|
|
var data = model.Adapt<Sys_Dictionary>();
|
|
|
|
db.Insertable(data).ExecuteCommand();
|
|
|
|
return DataResult.Successed("添加成功!");
|
|
}
|
|
else
|
|
{
|
|
var info =db.Queryable<Sys_Dictionary>().Where(x => x.Dic_ID == model.Dic_ID).First();
|
|
|
|
var data = model.Adapt(info);
|
|
|
|
db.Updateable(data).IgnoreColumns(ignoreAllNullColumns:true).ExecuteCommand();
|
|
return DataResult.Successed("更新成功!");
|
|
}
|
|
}
|
|
|
|
public DataResult<List<SysDictionaryListViewModel>> GetSysDictionaryList(PageRequest request)
|
|
{
|
|
//序列化查询条件
|
|
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
var data = db.Queryable<Sys_DictionaryList>()
|
|
.Select<SysDictionaryListViewModel>()
|
|
.Where(whereList).ToQueryPage(request.PageCondition);
|
|
return data;
|
|
}
|
|
|
|
public DataResult<SysDictionaryListViewModel> GetSysDictionaryListInfo(int id)
|
|
{
|
|
var data = db.Queryable<Sys_DictionaryList>()
|
|
.Where(a => a.DicList_ID == id)
|
|
.Select<SysDictionaryListViewModel>()
|
|
.First();
|
|
return DataResult<SysDictionaryListViewModel>.Success(data);
|
|
}
|
|
|
|
public DataResult EditSysDictionaryListInfo(SysDictionaryListInput model)
|
|
{
|
|
if (model.DicList_ID.ToString().IsNullOrEmpty())
|
|
{
|
|
var isExist = db.Queryable<Sys_DictionaryList>().Where(x => x.DicName == model.DicName && x.Dic_ID == model.Dic_ID).First();
|
|
if (isExist!=null)
|
|
{
|
|
return DataResult.Failed("字典唯一编码已存在!");
|
|
}
|
|
|
|
var data = model.Adapt<Sys_DictionaryList>();
|
|
|
|
db.Insertable(data).ExecuteCommand();
|
|
|
|
return DataResult.Successed("添加成功!");
|
|
}
|
|
else
|
|
{
|
|
var info =db.Queryable<Sys_DictionaryList>().Where(x => x.DicList_ID == model.DicList_ID).First();
|
|
|
|
var data = model.Adapt(info);
|
|
|
|
db.Updateable(data).IgnoreColumns(ignoreAllNullColumns:true).ExecuteCommand();
|
|
return DataResult.Successed("更新成功!");
|
|
}
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public DataResult DelSysDictionaryListInfo(int id)
|
|
{
|
|
|
|
var info =db.Queryable<Sys_DictionaryList>()
|
|
.Where(a => a.DicList_ID == id)
|
|
.First();
|
|
|
|
if (info.IsNull())
|
|
{
|
|
return DataResult.Failed("字典明细不存在!");
|
|
}
|
|
|
|
db.Deleteable(info).ExecuteCommand();
|
|
return DataResult.Successed("删除成功!");
|
|
}
|
|
} |