Camera Information System
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.

106 lines
5.1 KiB

using Cis.Core.Common;
using Newtonsoft.Json.Linq;
namespace Cis.Application.Cb;
/// <summary>
/// 相机服务
/// </summary>
[ApiDescriptionSettings(CbInfo.GroupName, Order = CbInfo.GroupOrder)]
public class CbCameraService : ServiceBase<CbCamera>, ITransient
{
public CbCameraService(SqlSugarRepository<CbCamera> baseRep) : base(baseRep)
{
}
/// <summary>
///
/// </summary>
2 years ago
/// <param name="queryJson">equal:cbCameraParamsId,id,isDelete; like:ip,name; between:[startTime,endTime];</param>
/// <returns></returns>
[HttpGet]
public override async Task<CbCamera> GetQ(string queryJson)
{
JObject queryObj = queryJson.ToJObject();
var exp = Expressionable.Create<CbCamera>();
if (queryObj.TryGetValue("cbCameraParamsId", StringComparison.OrdinalIgnoreCase, out JToken cbCameraParamsId))
exp.And(it => it.CbCameraParamsId.Equals(cbCameraParamsId));
if (queryObj.TryGetValue("name", StringComparison.OrdinalIgnoreCase, out JToken name))
exp.And(it => it.Name.Contains(name.ToString()));
if (queryObj.TryGetValue("ip", StringComparison.OrdinalIgnoreCase, out JToken ip))
exp.And(it => it.Ip.Contains(ip.ToString()));
2 years ago
if (queryObj.TryGetValue("Id", StringComparison.OrdinalIgnoreCase, out JToken Id))
exp.And(it => it.Id.Equals(Id));
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:cbCameraParamsId,isDelete; like:ip,name; between:[startTime,endTime];</param>
/// <returns></returns>
[HttpGet]
public override async Task<List<CbCamera>> GetList(string queryJson = "")
{
JObject queryObj = queryJson.ToJObject();
var exp = Expressionable.Create<CbCamera>();
if (queryObj.TryGetValue("cbCameraParamsId", StringComparison.OrdinalIgnoreCase, out JToken cbCameraParamsId))
exp.And(it => it.CbCameraParamsId.Equals(cbCameraParamsId));
if (queryObj.TryGetValue("name", StringComparison.OrdinalIgnoreCase, out JToken name))
exp.And(it => it.Name.Contains(name.ToString()));
if (queryObj.TryGetValue("ip", StringComparison.OrdinalIgnoreCase, out JToken ip))
exp.And(it => it.Ip.Contains(ip.ToString()));
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())
.ToListAsync();
return list;
}
/// <summary>
///
/// </summary>
/// <param name="queryJson">equal:cbCameraParamsId,isDelete; like:ip,name; between:[startTime,endTime];</param>
/// <param name="pagination">index,size</param>
/// <returns></returns>
[HttpGet]
2 years ago
public override async Task<List<CbCamera>> GetPageList(string pagination, string queryJson = "")
{
JObject queryObj = queryJson.ToJObject();
Pagination pageObj = pagination.ToObject<Pagination>();
var exp = Expressionable.Create<CbCamera>();
if (queryObj.TryGetValue("cbCameraParamsId", StringComparison.OrdinalIgnoreCase, out JToken cbCameraParamsId))
exp.And(it => it.CbCameraParamsId.Equals(cbCameraParamsId));
if (queryObj.TryGetValue("name", StringComparison.OrdinalIgnoreCase, out JToken name))
exp.And(it => it.Name.Contains(name.ToString()));
if (queryObj.TryGetValue("ip", StringComparison.OrdinalIgnoreCase, out JToken ip))
exp.And(it => it.Ip.Contains(ip.ToString()));
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())
.ToPageListAsync(pageObj.Index, pageObj.Size);
return list;
}
}