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 { /// /// SignalType 标准Api /// [ApiController] [Route("V1/Standard/SignalType")] [ApiExplorerSettings(GroupName = "V1")] public class SignalType_StandardController : ControllerBase { private readonly Service.SignalType _service = new Service.SignalType(); #region Query /// /// 获取所有 /// [Route("GetAll")] [HttpGet] public Result GetAll() { var list = _service.GetAll(); return new Result>(list); } /// /// 通过 GroupID 获取 /// [Route("GetByGroupID")] [HttpGet] public Result GetByGroupID(long GroupID) { if (GroupID < 1) { return new Result(Code.Error, "GroupID 参数错误"); } var list = _service.GetByGroupID(GroupID); return new Result>(list); } /// /// 通过 ID 获取 /// [Route("GetByID")] [HttpGet] public Result GetByID(long ID) { if (ID < 1) { return new Result(Code.Error, "ID 参数错误"); } var model = _service.GetByID(ID); return new Result(model); } /// /// 通过 ID 获取 /// [Route("GetByIds")] [HttpGet] public Result GetByIds(string Ids) { var ids = LongListHelper.ToList(Ids); if (ids == null || ids.Count() < 1) { return new Result("Ids 参数错误"); } var list = _service.GetByIds(ids); return new Result>(list); } #endregion #region Insert /// /// 添加一条 /// [Route("Insert")] [HttpPost] public Result Insert(Model.SignalType 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.SignalType 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() <= 0) { return new Result(Code.Error, "参数错误"); } var bol = _service.Updates(list); return new Result(bol); } /// /// 更新排序码 /// [Route("UpdateSortCode")] [HttpPut] public Result UpdateSortCode(Model.UpdateSortCodeInput model) { if (model == null) { return new Result(Code.Error, "参数错误"); } if (model.ID < 1) { return new Result(Code.Error, "ID 参数错误"); } var bol = _service.UpdateSortCode(model.ID, model.SortCode); return new Result(bol); } /// /// 更新排序 /// [Route("UpdateSorter")] [HttpPut] public Result UpdateSorter(List Sorters) { if (Sorters == null || Sorters.Count() < 1) { return new Result(Code.Error, "参数错误"); } var bol = _service.UpdateSorter(Sorters); return new Result(bol); } /// /// 更新GroupID /// [Route("UpdateGroupID")] [HttpPut] public Result UpdateGroupID(Model.UpdateGroupIDInput model) { if (model == null) { return new Result(Code.Error, "参数错误"); } if (model.ID < 1) { return new Result(Code.Error, "ID 参数错误"); } var bol = _service.UpdateGroupID(model.ID, model.GroupID); return new Result(bol); } /// /// 更新TagName /// [Route("UpdateTagName")] [HttpPut] public Result UpdateTagName(Model.UpdateTagNameInput model) { if (model == null) { return new Result(Code.Error, "参数错误"); } if (model.ID < 1) { return new Result(Code.Error, "ID 参数错误"); } var bol = _service.UpdateTagName(model.ID, model.TagName); return new Result(bol); } #endregion #region Exist /// /// 判断是否存在 /// [Route("IsExist")] [HttpGet] public Result IsExist(string Identifier) { if (string.IsNullOrEmpty(Identifier)) { return new Result(Code.Error, "Identifier 参数错误"); } var bol = _service.IsExist(Identifier); return new Result(bol); } /// /// 判断是否存在 Except /// [Route("IsExistExceptID")] [HttpGet] public Result IsExistExceptID(string Identifier, long ExceptID) { if (string.IsNullOrEmpty(Identifier)) { return new Result(Code.Error, "Identifier 参数错误"); } if (ExceptID < 1) { return new Result(Code.Error, "ExceptID 参数错误"); } var bol = _service.IsExistExceptID(Identifier, ExceptID); return new Result(bol); } #endregion #region Delete /// /// 通过 ID 删除 /// [Route("DeleteByID")] [HttpDelete] public Result DeleteByID(long ID) { if (ID < 1) { return new Result(Code.Error, "ID 参数错误"); } var bol = _service.DeleteByID(ID, out string Msg); return new ResultReason(bol, Msg); } #endregion } }