using EC.App.Core; using EC.App.ThatBLL.Onvif.Intf; using Furion.DataValidation; using Microsoft.AspNetCore.Mvc; using System.ComponentModel.DataAnnotations; using System.Threading.Tasks; namespace OnvifWebServer.Controllers.Onvif { /// /// Onvif 增删改查 /// [ApiController] [ApiDescriptionSettings("Onvif")] [Route("onvif/[controller]")] public class CurdController : ApiController { private readonly ICurdBLL _curdBLL; /// /// /// /// public CurdController(ICurdBLL curdBLL) { _curdBLL = curdBLL; } /// /// 添加 onvif /// /// IP地址 /// 用户名 /// 密码 /// [HttpPost] public async Task Add( [FromForm][Required][DataValidation(ValidationTypes.IPv4)] string ip, [FromForm][Required] string username, [FromForm][Required] string password) { bool ret = await _curdBLL.Add(ip, username, password); return ret; } /// /// 移除 onvif /// /// IP地址 /// [HttpDelete] public bool Remove( [Required][DataValidation(ValidationTypes.IPv4)] string ip) { bool ret = _curdBLL.Remove(ip); return ret; } /// /// 更新 onvif /// /// IP地址 /// 用户名 /// 密码 /// [HttpPost] public async Task Update( [FromForm][Required][DataValidation(ValidationTypes.IPv4)] string ip, [FromForm][Required] string username, [FromForm][Required] string password) { bool ret = await _curdBLL.Update(ip, username, password); return ret; } /// /// 是否存在 onvif /// /// IP地址 /// [HttpGet] public bool IsExist( [Required][DataValidation(ValidationTypes.IPv4)] string ip) { bool ret = _curdBLL.IsExist(ip); return ret; } } }