forked from fajiao/OnvifServer-CSharp
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.
90 lines
2.1 KiB
90 lines
2.1 KiB
using EC.App.Core;
|
|
using EC.App.ThatBLL.Onvif.Impl;
|
|
using Furion.DataValidation;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace OnvifWebServer.Controllers.Onvif
|
|
{
|
|
/// <summary>
|
|
/// Onvif 增删改查
|
|
/// </summary>
|
|
[Route("onvif/[controller]")]
|
|
[ApiDescriptionSettings("Onvif")]
|
|
public class CurdController : ApiController
|
|
{
|
|
private readonly ICurdBLL _curdBLL;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="curdBLL"></param>
|
|
public CurdController(ICurdBLL curdBLL)
|
|
{
|
|
_curdBLL = curdBLL;
|
|
}
|
|
|
|
#region Operate
|
|
|
|
/// <summary>
|
|
/// 添加 onvif
|
|
/// </summary>
|
|
/// <param name="ip">IP地址</param>
|
|
/// <param name="username">用户名</param>
|
|
/// <param name="password">密码</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<bool> Add(
|
|
[Required][DataValidation(ValidationTypes.IPv4)] string ip,
|
|
[Required] string username, [Required] string password)
|
|
{
|
|
bool ret = await _curdBLL.Add(ip, username, password);
|
|
return ret;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 移除 onvif
|
|
/// </summary>
|
|
/// <param name="ip">IP地址</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
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(
|
|
[Required][DataValidation(ValidationTypes.IPv4)] string ip,
|
|
[Required] string username, [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;
|
|
}
|
|
|
|
#endregion Operate
|
|
}
|
|
}
|