using Cis.Core.Common;
using Newtonsoft.Json.Linq;
namespace Cis.Application.Sys;
///
/// 系统字典值服务
///
[ApiDescriptionSettings(SysInfo.GroupName, Order = SysInfo.GroupOrder)]
public class SysDictDataService : ServiceBase, ITransient
{
public SysDictDataService(SqlSugarRepository baseRep) : base(baseRep)
{
}
///
///
///
/// equal:sysDictTypeId,code,isDelete; between:[startTime,endTime];
///
[HttpGet]
public override async Task GetQ(string queryJson)
{
JObject queryObj = queryJson.ToJObject();
var exp = Expressionable.Create();
if (queryObj.TryGetValue("sysDictTypeId", StringComparison.OrdinalIgnoreCase, out JToken sysDictTypeId))
exp.And(it => it.SysDictTypeId.Equals(sysDictTypeId));
if (queryObj.TryGetValue("code", StringComparison.OrdinalIgnoreCase, out JToken code))
exp.And(it => it.Code.Equals(code));
if (queryObj.TryGetValue("IsDelete", StringComparison.OrdinalIgnoreCase, out JToken isDelete))
exp.And(it => it.IsDelete.Equals(isDelete));
if (queryObj.TryGetValue("StartTime", StringComparison.OrdinalIgnoreCase, out JToken startTime)
&& queryObj.TryGetValue("EndTime", StringComparison.OrdinalIgnoreCase, out JToken endTime))
exp.And(it => it.CreateTime >= startTime.ToDateTime() && it.CreateTime <= endTime.ToDateTime());
var entity = await _baseRep.AsQueryable()
.Where(exp.ToExpression())
.FirstAsync();
return entity;
}
///
///
///
/// equal:sysDictTypeId,code,isDelete; between:[startTime,endTime];
///
[HttpGet]
public override async Task> GetList(string queryJson)
{
JObject queryObj = queryJson.ToJObject();
var exp = Expressionable.Create();
if (queryObj.TryGetValue("sysDictTypeId", StringComparison.OrdinalIgnoreCase, out JToken sysDictTypeId))
exp.And(it => it.SysDictTypeId.Equals(sysDictTypeId));
if (queryObj.TryGetValue("code", StringComparison.OrdinalIgnoreCase, out JToken code))
exp.And(it => it.Code.Equals(code));
if (queryObj.TryGetValue("IsDelete", StringComparison.OrdinalIgnoreCase, out JToken isDelete))
exp.And(it => it.IsDelete.Equals(isDelete));
if (queryObj.TryGetValue("StartTime", StringComparison.OrdinalIgnoreCase, out JToken startTime)
&& queryObj.TryGetValue("EndTime", StringComparison.OrdinalIgnoreCase, out JToken endTime))
exp.And(it => it.CreateTime >= startTime.ToDateTime() && it.CreateTime <= endTime.ToDateTime());
var list = await _baseRep.AsQueryable()
.Where(exp.ToExpression()).OrderBy(it => it.Order)
.ToListAsync();
return list;
}
///
///
///
/// equal:sysDictTypeId,code,isDelete; between:[startTime,endTime];
/// index,size
///
[HttpGet]
public override async Task> GetPageList(string queryJson, string pagination)
{
JObject queryObj = queryJson.ToJObject();
Pagination pageObj = pagination.ToObject();
var exp = Expressionable.Create();
if (queryObj.TryGetValue("sysDictTypeId", StringComparison.OrdinalIgnoreCase, out JToken sysDictTypeId))
exp.And(it => it.SysDictTypeId.Equals(sysDictTypeId));
if (queryObj.TryGetValue("code", StringComparison.OrdinalIgnoreCase, out JToken code))
exp.And(it => it.Code.Equals(code));
if (queryObj.TryGetValue("IsDelete", StringComparison.OrdinalIgnoreCase, out JToken isDelete))
exp.And(it => it.IsDelete.Equals(isDelete));
if (queryObj.TryGetValue("StartTime", StringComparison.OrdinalIgnoreCase, out JToken startTime)
&& queryObj.TryGetValue("EndTime", StringComparison.OrdinalIgnoreCase, out JToken endTime))
exp.And(it => it.CreateTime >= startTime.ToDateTime() && it.CreateTime <= endTime.ToDateTime());
var list = await _baseRep.AsQueryable()
.Where(exp.ToExpression()).OrderBy(it => it.Order)
.ToPageListAsync(pageObj.Index, pageObj.Size);
return list;
}
}