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.
75 lines
2.6 KiB
C#
75 lines
2.6 KiB
C#
9 months ago
|
using DS.Module.Core;
|
||
|
using DS.Module.Core.Extensions;
|
||
|
using DS.Module.UserModule;
|
||
6 months ago
|
using DS.WMS.Core.Sys.Dtos;
|
||
|
using DS.WMS.Core.Sys.Entity;
|
||
|
using DS.WMS.Core.Sys.Interface;
|
||
9 months ago
|
using Mapster;
|
||
|
using Microsoft.Extensions.DependencyInjection;
|
||
|
using SqlSugar;
|
||
|
|
||
6 months ago
|
namespace DS.WMS.Core.Sys.Method;
|
||
9 months ago
|
|
||
|
public class SysDictDataService:ISysDictDataService
|
||
|
{
|
||
|
private readonly IServiceProvider _serviceProvider;
|
||
|
private readonly ISqlSugarClient db;
|
||
|
private readonly IUser user;
|
||
|
private readonly ICommonService _commonService;
|
||
|
/// <summary>
|
||
|
///
|
||
|
/// </summary>
|
||
|
/// <param name="serviceProvider"></param>
|
||
|
public SysDictDataService(IServiceProvider serviceProvider)
|
||
|
{
|
||
|
_serviceProvider = serviceProvider;
|
||
|
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
|
||
|
user = _serviceProvider.GetRequiredService<IUser>();
|
||
|
_commonService = _serviceProvider.GetRequiredService<ICommonService>();
|
||
|
}
|
||
|
public DataResult<List<DictDataRes>> GetListByPage(PageRequest request)
|
||
|
{
|
||
|
//序列化查询条件
|
||
|
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
||
|
var data = db.Queryable<SysDictData>()
|
||
|
.Select<DictDataRes>()
|
||
|
.Where(whereList).ToQueryPage(request.PageCondition);
|
||
|
return data;
|
||
|
}
|
||
|
|
||
|
public DataResult EditDictData(DictDataReq req)
|
||
|
{
|
||
|
if (req.Id == 0)
|
||
|
{
|
||
9 months ago
|
var isExist = db.Queryable<SysDictData>().Where(x =>x.TypeId == req.TypeId && x.Value == req.Value).First();
|
||
9 months ago
|
if (isExist != null)
|
||
|
{
|
||
|
return DataResult.Failed("字典值唯一编码已存在!",MultiLanguageConst.DictCodeExist);
|
||
|
}
|
||
|
|
||
|
var data = req.Adapt<SysDictData>();
|
||
|
|
||
|
var entity = db.Insertable(data).ExecuteReturnEntity();
|
||
|
|
||
|
return DataResult.Successed("添加成功!", entity.Id,MultiLanguageConst.DataCreateSuccess);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
var info = db.Queryable<SysDictData>().Where(x => x.Id == req.Id).First();
|
||
|
|
||
|
info = req.Adapt(info);
|
||
|
|
||
7 months ago
|
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
||
9 months ago
|
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public DataResult<DictDataRes> GetDictDataInfo(string id)
|
||
|
{
|
||
|
var data = db.Queryable<SysDictData>()
|
||
|
.Where(a => a.Id == long.Parse(id))
|
||
|
.Select<DictDataRes>()
|
||
|
.First();
|
||
|
return DataResult<DictDataRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
|
||
|
}
|
||
|
}
|