From 9286afb09a14a7f1e461fc138365e2b8a17d6abc Mon Sep 17 00:00:00 2001
From: fajiao <1519100073@qq.com>
Date: Tue, 22 Feb 2022 16:14:25 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20post=20=E6=96=B9=E6=B3=95?=
=?UTF-8?q?=E5=8F=82=E6=95=B0=E6=8E=A5=E6=94=B6=E6=A0=BC=E5=BC=8F=EF=BC=8C?=
=?UTF-8?q?=E5=8F=82=E8=80=83=20https://docs.microsoft.com/zh-cn/aspnet/co?=
=?UTF-8?q?re/web-api/=3Fview=3Daspnetcore-3.1#binding-source-parameter-in?=
=?UTF-8?q?ference?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BaseModule/EC.App/Core/ApiController.cs | 5 ++---
.../Controllers/Onvif/CurdController.cs | 11 ++++++-----
.../Controllers/Onvif/DeviceController.cs | 3 ++-
.../Controllers/Onvif/ImagingController.cs | 17 +++++++++--------
.../Controllers/Onvif/MediaController.cs | 3 ++-
.../Controllers/Onvif/PTZController.cs | 17 +++++++++--------
.../Controllers/Onvif/TestController.cs | 3 ++-
7 files changed, 32 insertions(+), 27 deletions(-)
diff --git a/BaseModule/EC.App/Core/ApiController.cs b/BaseModule/EC.App/Core/ApiController.cs
index d1c3c0b..37e902e 100644
--- a/BaseModule/EC.App/Core/ApiController.cs
+++ b/BaseModule/EC.App/Core/ApiController.cs
@@ -1,11 +1,10 @@
-using Furion.DependencyInjection;
-using Furion.DynamicApiController;
+using Furion.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
namespace EC.App.Core
{
- [ApiDescriptionSettings(false)]
[NonController]
+ [ApiDescriptionSettings(false)]
public class ApiController : IDynamicApiController
{
}
diff --git a/OnvifWebServer/Controllers/Onvif/CurdController.cs b/OnvifWebServer/Controllers/Onvif/CurdController.cs
index 44f652d..1435e8c 100644
--- a/OnvifWebServer/Controllers/Onvif/CurdController.cs
+++ b/OnvifWebServer/Controllers/Onvif/CurdController.cs
@@ -10,8 +10,9 @@ namespace OnvifWebServer.Controllers.Onvif
///
/// Onvif 增删改查
///
- [Route("onvif/[controller]")]
+ [ApiController]
[ApiDescriptionSettings("Onvif")]
+ [Route("onvif/[controller]")]
public class CurdController : ApiController
{
private readonly ICurdBLL _curdBLL;
@@ -34,8 +35,8 @@ namespace OnvifWebServer.Controllers.Onvif
///
[HttpPost]
public async Task Add(
- [Required][DataValidation(ValidationTypes.IPv4)] string ip,
- [Required] string username, [Required] string password)
+ [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;
@@ -63,8 +64,8 @@ namespace OnvifWebServer.Controllers.Onvif
///
[HttpPost]
public async Task Update(
- [Required][DataValidation(ValidationTypes.IPv4)] string ip,
- [Required] string username, [Required] string password)
+ [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;
diff --git a/OnvifWebServer/Controllers/Onvif/DeviceController.cs b/OnvifWebServer/Controllers/Onvif/DeviceController.cs
index 97ad0f4..e042a50 100644
--- a/OnvifWebServer/Controllers/Onvif/DeviceController.cs
+++ b/OnvifWebServer/Controllers/Onvif/DeviceController.cs
@@ -9,8 +9,9 @@ namespace OnvifWebServer.Controllers.Onvif
///
/// Onvif 设备参数控制
///
- [Route("onvif/[controller]")]
+ [ApiController]
[ApiDescriptionSettings("Onvif")]
+ [Route("onvif/[controller]")]
public class DeviceController : ApiController
{
private readonly IDeviceBLL _deviceBLL;
diff --git a/OnvifWebServer/Controllers/Onvif/ImagingController.cs b/OnvifWebServer/Controllers/Onvif/ImagingController.cs
index 1de5f9b..7176df3 100644
--- a/OnvifWebServer/Controllers/Onvif/ImagingController.cs
+++ b/OnvifWebServer/Controllers/Onvif/ImagingController.cs
@@ -10,8 +10,9 @@ namespace OnvifWebServer.Controllers.Onvif
///
/// Onvif 成像参数控制
///
- [Route("onvif/[controller]")]
+ [ApiController]
[ApiDescriptionSettings("Onvif")]
+ [Route("onvif/[controller]")]
public class ImagingController : ApiController
{
private readonly IImagingBLL _imagingBLL;
@@ -46,8 +47,8 @@ namespace OnvifWebServer.Controllers.Onvif
///
[HttpPost]
public async Task FocusAbsoluteMove(
- [Required][DataValidation(ValidationTypes.IPv4)] string ip,
- [Required] float position)
+ [FromForm][Required][DataValidation(ValidationTypes.IPv4)] string ip,
+ [FromForm][Required] float position)
{
bool ret = await _imagingBLL.FocusAbsoluteMove(ip, position);
return ret;
@@ -61,8 +62,8 @@ namespace OnvifWebServer.Controllers.Onvif
///
[HttpPost]
public async Task FocusRelativeMove(
- [Required][DataValidation(ValidationTypes.IPv4)] string ip,
- [Required] float distance)
+ [FromForm][Required][DataValidation(ValidationTypes.IPv4)] string ip,
+ [FromForm][Required] float distance)
{
bool ret = await _imagingBLL.FocusRelativeMove(ip, distance);
return ret;
@@ -76,8 +77,8 @@ namespace OnvifWebServer.Controllers.Onvif
///
[HttpPost]
public async Task FocusContinuousMove(
- [Required][DataValidation(ValidationTypes.IPv4)] string ip,
- [Required] float speed)
+ [FromForm][Required][DataValidation(ValidationTypes.IPv4)] string ip,
+ [FromForm][Required] float speed)
{
bool ret = await _imagingBLL.FocusContinuousMove(ip, speed);
return ret;
@@ -89,7 +90,7 @@ namespace OnvifWebServer.Controllers.Onvif
/// IP地址
[HttpPost]
public async Task FocusStopMove(
- [Required][DataValidation(ValidationTypes.IPv4)] string ip)
+ [FromForm][Required][DataValidation(ValidationTypes.IPv4)] string ip)
{
bool ret = await _imagingBLL.FocusStopMove(ip);
return ret;
diff --git a/OnvifWebServer/Controllers/Onvif/MediaController.cs b/OnvifWebServer/Controllers/Onvif/MediaController.cs
index a27d640..755b2a2 100644
--- a/OnvifWebServer/Controllers/Onvif/MediaController.cs
+++ b/OnvifWebServer/Controllers/Onvif/MediaController.cs
@@ -10,8 +10,9 @@ namespace OnvifWebServer.Controllers.Onvif
///
/// Onvif 媒体参数控制
///
- [Route("onvif/[controller]")]
+ [ApiController]
[ApiDescriptionSettings("Onvif")]
+ [Route("onvif/[controller]")]
public class MediaController : ApiController
{
private readonly IMediaBLL _mediaBLL;
diff --git a/OnvifWebServer/Controllers/Onvif/PTZController.cs b/OnvifWebServer/Controllers/Onvif/PTZController.cs
index 0351181..3b3497d 100644
--- a/OnvifWebServer/Controllers/Onvif/PTZController.cs
+++ b/OnvifWebServer/Controllers/Onvif/PTZController.cs
@@ -10,8 +10,9 @@ namespace OnvifWebServer.Controllers.Onvif
///
/// Onvif 移动参数控制
///
- [Route("onvif/[controller]")]
+ [ApiController]
[ApiDescriptionSettings("Onvif")]
+ [Route("onvif/[controller]")]
public class PTZController : ApiController
{
private readonly IPTZBLL _ptzBLL;
@@ -48,8 +49,8 @@ namespace OnvifWebServer.Controllers.Onvif
///
[HttpPost]
public async Task AbsoluteMove(
- [Required][DataValidation(ValidationTypes.IPv4)] string ip,
- [Required] float pan, [Required] float tilt, [Required] float zoom)
+ [FromForm][Required][DataValidation(ValidationTypes.IPv4)] string ip,
+ [FromForm][Required] float pan, [FromForm][Required] float tilt, [FromForm][Required] float zoom)
{
bool ret = await _ptzBLL.AbsoluteMove(ip, pan, tilt, zoom);
return ret;
@@ -64,8 +65,8 @@ namespace OnvifWebServer.Controllers.Onvif
/// 变倍相对点[-1,1]
[HttpPost]
public async Task RelativeMove(
- [Required][DataValidation(ValidationTypes.IPv4)] string ip,
- [Required] float pan, [Required] float tilt, [Required] float zoom)
+ [FromForm][Required][DataValidation(ValidationTypes.IPv4)] string ip,
+ [FromForm][Required] float pan, [FromForm][Required] float tilt, [FromForm][Required] float zoom)
{
bool ret = await _ptzBLL.RelativeMove(ip, pan, tilt, zoom);
return ret;
@@ -80,8 +81,8 @@ namespace OnvifWebServer.Controllers.Onvif
/// 变倍移动速度[-1,1]
[HttpPost]
public async Task ContinuousMove(
- [Required][DataValidation(ValidationTypes.IPv4)] string ip,
- [Required] float pan, [Required] float tilt, [Required] float zoom)
+ [FromForm][Required][DataValidation(ValidationTypes.IPv4)] string ip,
+ [FromForm][Required] float pan, [FromForm][Required] float tilt, [FromForm][Required] float zoom)
{
bool ret = await _ptzBLL.ContinuousMove(ip, pan, tilt, zoom);
return ret;
@@ -93,7 +94,7 @@ namespace OnvifWebServer.Controllers.Onvif
/// IP地址
[HttpPost]
public async Task StopMove(
- [Required][DataValidation(ValidationTypes.IPv4)] string ip)
+ [FromForm][Required][DataValidation(ValidationTypes.IPv4)] string ip)
{
bool ret = await _ptzBLL.StopMove(ip);
return ret;
diff --git a/OnvifWebServer/Controllers/Onvif/TestController.cs b/OnvifWebServer/Controllers/Onvif/TestController.cs
index 108e812..86ec6e2 100644
--- a/OnvifWebServer/Controllers/Onvif/TestController.cs
+++ b/OnvifWebServer/Controllers/Onvif/TestController.cs
@@ -6,8 +6,9 @@ using System.ComponentModel.DataAnnotations;
namespace OnvifWebServer.Controllers.Onvif
{
- [Route("test/[controller]")]
+ [ApiController]
[ApiDescriptionSettings("Test")]
+ [Route("test/[controller]")]
public class TestController : ApiController
{
public TestController()