using EC.App.Core;
using EC.App.ThatBLL.Onvif;
using Furion.DataValidation;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
namespace OnvifWebServer.Controllers.Onvif
{
///
/// Onvif 增删改查
///
[Route("onvif/[controller]")]
[ApiDescriptionSettings("Onvif")]
public class CurdController : ApiController
{
private readonly ICurdBLL _curdBLL;
///
///
///
///
public CurdController(ICurdBLL curdBLL)
{
_curdBLL = curdBLL;
}
///
/// 添加 onvif
///
/// IP地址
/// 用户名
/// 密码
///
[HttpPost]
public async Task Add(
[Required][DataValidation(ValidationTypes.IPv4)] string ip,
[Required] string username, [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(
[Required][DataValidation(ValidationTypes.IPv4)] string ip,
[Required] string username, [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;
}
}
}