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.
85 lines
2.3 KiB
85 lines
2.3 KiB
using Cis.Application.Core;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace Cis.Application.Cm;
|
|
|
|
/// <summary>
|
|
/// 标记标签服务
|
|
/// </summary>
|
|
[ApiDescriptionSettings(CmInfo.GroupName, Order = CmInfo.GroupOrder)]
|
|
public class CmMarkLabelService : IDynamicApiController, ITransient
|
|
{
|
|
private readonly SqlSugarRepository<CmMarkLabel> _cmMarkLabelRep;
|
|
|
|
private CameraDataCenter _cameraDataCenter { get; set; }
|
|
|
|
public CmMarkLabelService(CameraDataCenter cameraDataCenter,
|
|
SqlSugarRepository<CmMarkLabel> cmMarkLabelRep)
|
|
{
|
|
_cameraDataCenter = cameraDataCenter;
|
|
_cmMarkLabelRep = cmMarkLabelRep;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<bool> Add([FromForm] CmMarkLabel entity)
|
|
{
|
|
PtzInfo ptzInfo = _cameraDataCenter.GetCameraPtzInfo(entity.CbCameraId);
|
|
if (ptzInfo == null)
|
|
return false;
|
|
entity.PanPosition = ptzInfo.Pan;
|
|
entity.TiltPosition = ptzInfo.Tilt;
|
|
entity.ZoomPosition = ptzInfo.Zoom;
|
|
return await _cmMarkLabelRep.InsertAsync(entity);
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<long> AddReturnId([FromForm] CmMarkLabel entity)
|
|
{
|
|
PtzInfo ptzInfo = _cameraDataCenter.GetCameraPtzInfo(entity.CbCameraId);
|
|
if (ptzInfo == null)
|
|
return 0;
|
|
entity.PanPosition = ptzInfo.Pan;
|
|
entity.TiltPosition = ptzInfo.Tilt;
|
|
entity.ZoomPosition = ptzInfo.Zoom;
|
|
await _cmMarkLabelRep.InsertAsync(entity);
|
|
return entity.Id;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<bool> Update([FromForm] CmMarkLabel entity)
|
|
{
|
|
return await _cmMarkLabelRep.UpdateAsync(entity);
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<bool> Delete([FromForm] CmMarkLabel entity)
|
|
{
|
|
return await _cmMarkLabelRep.DeleteAsync(entity);
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<CmMarkLabel> Get(long id)
|
|
{
|
|
CmMarkLabel entity = await _cmMarkLabelRep.GetByIdAsync(id);
|
|
return entity;
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<List<CmMarkLabel>> GetList(string queryJson = "")
|
|
{
|
|
JObject queryObj = queryJson.ToJObject();
|
|
List<CmMarkLabel> list = await _cmMarkLabelRep.AsQueryable()
|
|
.ToListAsync();
|
|
return list;
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<List<CmMarkLabel>> GetPageList(string queryJson, string pagination)
|
|
{
|
|
Pagination pageObj = pagination.ToObject<Pagination>();
|
|
JObject queryObj = queryJson.ToJObject();
|
|
List<CmMarkLabel> list = await _cmMarkLabelRep.AsQueryable()
|
|
.ToPageListAsync(pageObj.Index, pageObj.Size);
|
|
return list;
|
|
}
|
|
}
|