using Microsoft.AspNetCore.Mvc; using IStation.Model.Api; using System.Net; using System.Net.Http.Headers; using Microsoft.Extensions.Hosting.Internal; using Microsoft.AspNetCore.Http.Extensions; using IStation.Untity; namespace IStation.WebApi.Controllers.V1 { /// /// ObjectMapInfo 标准Api /// [ApiController] [Route("V1/Standard/ObjectMapInfo")] [ApiExplorerSettings(GroupName = "V1")] public class ObjectMapInfo_StandardController : ControllerBase { private readonly Service.ObjectMapInfo _service = new Service.ObjectMapInfo(); #region Query /// /// 通过 CorpID 获取 /// [Route("GetByCorpID")] [HttpGet] public Result GetByCorpID(long CorpID) { if (CorpID < 1) { return new Result(Code.Error, "CorpID 参数错误"); } var list = _service.GetByCorpID(CorpID); return new Result>(list); } /// /// 通过 ID 获取 /// [Route("GetByID")] [HttpGet] public Result GetByID(long CorpID, long ID) { if (CorpID < 1) { return new Result(Code.Error, "CorpID 参数错误"); } if (ID < 1) { return new Result(Code.Error, "ID 参数错误"); } var model = _service.GetByID(CorpID, ID); return new Result(model); } /// /// 通过 Ids 获取 /// [Route("GetByIds")] [HttpGet] public Result GetByIds(long CorpID, string Ids) { if (CorpID < 1) { return new Result(Code.Error, "CorpID 参数错误"); } var ids = LongListHelper.ToList(Ids); if (ids == null || ids.Count() < 1) { return new Result(Code.Error, "Ids 参数错误"); } var list = _service.GetByIds(CorpID, ids); return new Result>(list); } /// /// 获取 /// [Route("Get")] [HttpGet] public Result Get(long CorpID, string ObjectType, long ObjectID, string MapKind, string MapType) { if (CorpID < 1) { return new Result(Code.Error, "CorpID 参数错误"); } if (ObjectID < 1) { return new Result(Code.Error, "ObjectID 参数错误"); } var model = _service.Get(CorpID, ObjectType, ObjectID, MapKind, MapType); return new Result(model); } /// /// 获取管辖 /// [Route("GetAdmin")] [HttpGet] public Result GetAdmin(long CorpID, string ObjectType, long ObjectID, string MapKind) { if (CorpID < 1) { return new Result(Code.Error, "CorpID 参数错误"); } if (ObjectID < 1) { return new Result(Code.Error, "ObjectID 参数错误"); } var model = _service.GetAdmin(CorpID, ObjectType, ObjectID, MapKind); return new Result(model); } /// /// 获取定位 /// [Route("GetLocation")] [HttpGet] public Result GetLocation(long CorpID, string ObjectType, long ObjectID, string MapKind) { if (CorpID < 1) { return new Result(Code.Error, "CorpID 参数错误"); } if (ObjectID < 1) { return new Result(Code.Error, "ObjectID 参数错误"); } var model = _service.GetLocation(CorpID, ObjectType, ObjectID, MapKind); return new Result(model); } #endregion #region Insert /// /// 插入一条数据 /// [Route("Insert")] [HttpPost] public Result Insert(Model.ObjectMapInfo model) { if (model == null) { return new Result(Code.Error, "参数错误"); } var id = _service.Insert(model); return new Result(id); } /// /// 插入多条 /// [Route("Inserts")] [HttpPost] public Result Inserts(List list) { if (list == null || list.Count() < 1) { return new Result(Code.Error, "参数错误"); } var bol = _service.Inserts(list); return new Result(bol); } #endregion #region Update /// /// 更新一条 /// [Route("Update")] [HttpPut] public Result Update(Model.ObjectMapInfo model) { if (model == null) { return new Result(Code.Error, "参数错误"); } var bol = _service.Update(model); return new Result(bol); } /// /// 更新多条 /// [Route("Updates")] [HttpPut] public Result Updates(List list) { if (list == null || list.Count() < 1) { return new Result(Code.Error, "参数错误"); } var bol = _service.Updates(list); return new Result(bol); } /// /// 更新地图位置 /// [Route("UpdateMapPosition")] [HttpPut] public Result UpdateMapPosition(Model.UpdateMapPositionInput model) { if (model == null) { return new Result(Code.Error, "参数错误"); } if (model.CorpID < 1) { return new Result(Code.Error, "CorpID 参数错误"); } var bol = _service.UpdateMapPosition(model.CorpID, model.ID, model.MapPosition); return new Result(bol); } /// /// 更新对象位置信息 /// [Route("UpdateObjectMapPosition")] [HttpPut] public Result UpdateObjectMapPosition(Model.UpdateObjectMapPositionInput model) { if (model == null) { return new Result(Code.Error, "参数错误"); } if (model.CorpID < 1) { return new Result(Code.Error, "CorpID 参数错误"); } var bol = _service.UpdateObjectMapPosition(model.CorpID, model.ObjectType, model.ObjectID, model.MapKind, model.MapType, model.MapPosition); return new Result(bol); } #endregion #region Exist /// /// 是否存在 /// [Route("Exist")] [HttpGet] public Result IsExist(long CorpID, string ObjectType, long ObjectID, string MapKind, string MapType) { if (CorpID < 1) { return new Result(Code.Error, "CorpID 参数错误"); } if (ObjectID < 1) { return new Result(Code.Error, "ObjectID 参数错误"); } var bol = _service.IsExist(CorpID,ObjectType,ObjectID, MapKind, MapType); return new Result(bol); } /// /// 是否存在 /// [Route("Exists")] [HttpGet] public Result Exists(long CorpID, string ObjectType, string ObjectIds, string MapKind, string MapType) { if (CorpID < 1) { return new Result(Code.Error, "CorpID 参数错误"); } var ids = LongListHelper.ToList(ObjectIds); if (ids == null || ids.Count < 1) { return new Result(Code.Error, "ObjectIds 参数错误"); } var list = _service.Exists(CorpID, ObjectType, ids, MapKind, MapType); return new Result>(list); } #endregion #region Delete /// /// 通过 ID 删除 /// [Route("DeleteByID")] [HttpDelete] public Result DeleteByID(long CorpID, long ID) { if (CorpID < 1) { return new Result(Code.Error, "CorpID 参数错误"); } if (ID < 1) { return new Result(Code.Error, "ID 参数错误"); } var bol = _service.DeleteByID(CorpID, ID, out string Msg); return new ResultReason(bol, Msg); } /// /// 通过 ID 删除 /// [Route("Delete")] [HttpDelete] public Result Delete(long CorpID, string ObjectType, long ObjectID, string MapKind, string MapType) { if (CorpID < 1) { return new Result(Code.Error, "CorpID 参数错误"); } if (ObjectID < 1) { return new Result(Code.Error, "ObjectID 参数错误"); } var bol = _service.Delete(CorpID, ObjectType, ObjectID, MapKind, MapType, out string Msg); return new ResultReason(bol, Msg); } #endregion } }