You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
4.6 KiB
100 lines
4.6 KiB
using Cis.Core.Common;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace Cis.Application.Sys;
|
|
|
|
/// <summary>
|
|
/// 系统字典值服务
|
|
/// </summary>
|
|
[ApiDescriptionSettings(SysInfo.GroupName, Order = SysInfo.GroupOrder)]
|
|
public class SysDictDataService : ServiceBase<SysDictData>, ITransient
|
|
{
|
|
public SysDictDataService(SqlSugarRepository<SysDictData> baseRep) : base(baseRep)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="queryJson">equal:sysDictTypeId,code,id,isDelete; between:[startTime,endTime];</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public override async Task<SysDictData> GetQ(string queryJson)
|
|
{
|
|
JObject queryObj = queryJson.ToJObject();
|
|
|
|
var exp = Expressionable.Create<SysDictData>();
|
|
if (queryObj.TryGetValue("sysDictTypeId", StringComparison.OrdinalIgnoreCase, out JToken sysDictTypeId))
|
|
exp.And(it => it.SysDictTypeId.Equals(sysDictTypeId));
|
|
if (queryObj.TryGetValue("Id", StringComparison.OrdinalIgnoreCase, out JToken Id))
|
|
exp.And(it => it.Id.Equals(Id));
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="queryJson">equal:sysDictTypeId,code,isDelete; between:[startTime,endTime];</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public override async Task<List<SysDictData>> GetList(string queryJson)
|
|
{
|
|
JObject queryObj = queryJson.ToJObject();
|
|
|
|
var exp = Expressionable.Create<SysDictData>();
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="queryJson">equal:sysDictTypeId,code,isDelete; between:[startTime,endTime];</param>
|
|
/// <param name="pagination">index,size</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public override async Task<List<SysDictData>> GetPageList(string pagination, string queryJson = "")
|
|
{
|
|
JObject queryObj = queryJson.ToJObject();
|
|
Pagination pageObj = pagination.ToObject<Pagination>();
|
|
|
|
var exp = Expressionable.Create<SysDictData>();
|
|
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;
|
|
}
|
|
}
|