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.

87 lines
2.1 KiB

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
{
/// <summary>
/// Onvif 增删改查
/// </summary>
[ApiController]
[ApiDescriptionSettings("Onvif")]
[Route("onvif/[controller]")]
public class CurdController : ApiController
{
private readonly ICurdBLL _curdBLL;
/// <summary>
///
/// </summary>
/// <param name="curdBLL"></param>
public CurdController(ICurdBLL curdBLL)
{
_curdBLL = curdBLL;
}
/// <summary>
/// 添加 onvif
/// </summary>
/// <param name="ip">IP地址</param>
/// <param name="username">用户名</param>
/// <param name="password">密码</param>
/// <returns></returns>
[HttpPost]
public async Task<bool> 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;
}
/// <summary>
/// 移除 onvif
/// </summary>
/// <param name="ip">IP地址</param>
/// <returns></returns>
[HttpDelete]
public bool Remove(
[Required][DataValidation(ValidationTypes.IPv4)] string ip)
{
bool ret = _curdBLL.Remove(ip);
return ret;
}
/// <summary>
/// 更新 onvif
/// </summary>
/// <param name="ip">IP地址</param>
/// <param name="username">用户名</param>
/// <param name="password">密码</param>
/// <returns></returns>
[HttpPost]
public async Task<bool> 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;
}
/// <summary>
/// 是否存在 onvif
/// </summary>
/// <param name="ip">IP地址</param>
/// <returns></returns>
[HttpGet]
public bool IsExist(
[Required][DataValidation(ValidationTypes.IPv4)] string ip)
{
bool ret = _curdBLL.IsExist(ip);
return ret;
}
}
}