修改一下参数

pull/14/head
刘鑫 4 months ago
parent 8738a98d00
commit 02a957c992
  1. 23
      WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/DaHua/RequestDto/DahuaVideoQueryDto.cs
  2. 6
      WeiCloud.Fusion/Common.SharedService/Common.Shared.DomainService/DaHTokenService/TokenProviderService.cs
  3. 16
      WeiCloud.Fusion/VideoService/Video.API/Controllers/DaHua/VideoManageController.cs
  4. 45
      WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/DahuaGeneralCtlService.cs
  5. 8
      WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/IDahuaGeneralCtlService.cs
  6. 8
      WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/IRootVideoPlaybackService.cs
  7. 16
      WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/RootVideoPlaybackService.cs

@ -59,11 +59,6 @@ namespace Common.Shared.Application.DaHua
public class PlaybackReqDto public class PlaybackReqDto
{ {
public PlaybackItem Data { get; set; } public PlaybackItem Data { get; set; }
/// <summary>
/// 如果多个icc平台的话,决定是哪个平台的回放
/// </summary>
public string? IpAddress { get; set; }
} }
/// <summary> /// <summary>
@ -114,11 +109,6 @@ namespace Common.Shared.Application.DaHua
public class RtspPlayBackReqDto public class RtspPlayBackReqDto
{ {
public RtspPlaybackItem Data { get; set; } public RtspPlaybackItem Data { get; set; }
/// <summary>
/// 如果多个icc平台的话,决定是哪个平台的回放
/// </summary>
public string? IpAddress { get; set; }
} }
/// <summary> /// <summary>
@ -268,11 +258,6 @@ namespace Common.Shared.Application.DaHua
/// </summary> /// </summary>
[JsonPropertyName("data")] [JsonPropertyName("data")]
public StreamRequestData Data { get; set; } public StreamRequestData Data { get; set; }
/// <summary>
/// 如果多个icc平台的话,决定是哪个平台的回放
/// </summary>
public string? IpAddress { get; set; }
} }
/// <summary> /// <summary>
@ -286,10 +271,10 @@ namespace Common.Shared.Application.DaHua
[JsonPropertyName("data")] [JsonPropertyName("data")]
public StreamRtspRequestData Data { get; set; } public StreamRtspRequestData Data { get; set; }
/// <summary> ///// <summary>
/// 如果多个icc平台的话,决定是哪个平台的回放 ///// 如果多个icc平台的话,决定是哪个平台的回放
/// </summary> ///// </summary>
public string? IpAddress { get; set; } //public string? IpAddress { get; set; }
} }
/// <summary> /// <summary>

@ -309,11 +309,11 @@ namespace Common.Shared.DomainService
public bool IsTokenValid(string token) public bool IsTokenValid(string token)
{ {
// 避免 NullReferenceException // 避免 NullReferenceException
if (string.IsNullOrWhiteSpace(token)) if (string.IsNullOrWhiteSpace(token) && token.Length < 10)
return true; return false;
// 统一写法,后续改条件只改这里 // 统一写法,后续改条件只改这里
return token.Length < 10; return true;
} }
#region RES加密 #region RES加密

@ -37,9 +37,9 @@ namespace Video.API.Controllers.DaHua
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("playback/dh")] [HttpPost("playback/dh")]
public async Task<ApiResult<UrlDataDto>> StartAndPlaybackDH(PlaybackReqDto dto) public async Task<ApiResult<UrlDataDto>> StartAndPlaybackDH([FromBody] PlaybackReqDto dto, [FromQuery] string? ipaddress)
{ {
return await _rootVideoPlaybackService.GetDaHRecordVideoUrl(dto); return await _rootVideoPlaybackService.GetDaHRecordVideoUrl(dto, ipaddress);
} }
/// <summary> /// <summary>
@ -48,9 +48,9 @@ namespace Video.API.Controllers.DaHua
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("rtspplayback/dh")] [HttpPost("rtspplayback/dh")]
public async Task<ApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlayBackReqDto dto) public async Task<ApiResult<UrlDataDto>> RtspPlaybackByTime([FromBody] RtspPlayBackReqDto dto, [FromQuery] string? ipaddress)
{ {
return await _rootVideoPlaybackService.RtspPlaybackByTime(dto); return await _rootVideoPlaybackService.RtspPlaybackByTime(dto, ipaddress);
} }
/// <summary> /// <summary>
@ -59,9 +59,9 @@ namespace Video.API.Controllers.DaHua
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("realtime/dh")] [HttpPost("realtime/dh")]
public async Task<ApiResult<UrlDataDto>> GetRealtimeUrl(StreamReqDto dto) public async Task<ApiResult<UrlDataDto>> GetRealtimeUrl([FromBody] StreamReqDto dto, [FromQuery] string? ipaddress)
{ {
return await _rootVideoPlaybackService.GetRealtimeUrl(dto); return await _rootVideoPlaybackService.GetRealtimeUrl(dto, ipaddress);
} }
/// <summary> /// <summary>
@ -70,9 +70,9 @@ namespace Video.API.Controllers.DaHua
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("rtspstart/dh")] [HttpPost("rtspstart/dh")]
public async Task<ApiResult<UrlDataDto>> RtspStartVideoUrl(StreamRtspReqDto dto) public async Task<ApiResult<UrlDataDto>> RtspStartVideoUrl([FromBody] StreamRtspReqDto dto, [FromQuery] string? ipaddress)
{ {
return await _rootVideoPlaybackService.RtspStartVideoUrl(dto); return await _rootVideoPlaybackService.RtspStartVideoUrl(dto, ipaddress);
} }
/// <summary> /// <summary>

@ -38,7 +38,7 @@ namespace Video.DomainService
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="NotImplementedException"></exception> /// <exception cref="NotImplementedException"></exception>
public async Task<DaHApiResult<UrlDataDto>> RecordVideoUrl(PlaybackReqDto dto) public async Task<DaHApiResult<UrlDataDto>> RecordVideoUrl(PlaybackReqDto dto, string? ipaddress)
{ {
// 1) 参数校验 + 早退 // 1) 参数校验 + 早退
if (dto == null || string.IsNullOrWhiteSpace(dto.Data.ChannelId)) if (dto == null || string.IsNullOrWhiteSpace(dto.Data.ChannelId))
@ -57,15 +57,15 @@ namespace Video.DomainService
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1009", Msg = "token无效" }; return new DaHApiResult<UrlDataDto> { Success = false, Code = "1009", Msg = "token无效" };
} }
var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/video/stream/record"; var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/video/stream/record";
if (dto.IpAddress != null) if (ipaddress != null)
{ {
url = $"https://{dto.IpAddress}/evo-apigw/admin/API/video/stream/record"; url = $"https://{ipaddress}/evo-apigw/admin/API/video/stream/record";
} }
// 3) 构造请求(把 dto 放进 Body),并用 SendAsync 发送,才能带上头 // 3) 构造请求(把 dto 放进 Body),并用 SendAsync 发送,才能带上头
using var req = new HttpRequestMessage(HttpMethod.Post, url) using var req = new HttpRequestMessage(HttpMethod.Post, url)
{ {
Content = JsonContent.Create(dto) // 关键:别再丢 body 了 Content = JsonContent.Create(dto.Data) // 关键:别再丢 body 了
}; };
req.Headers.TryAddWithoutValidation("Authorization", token); req.Headers.TryAddWithoutValidation("Authorization", token);
@ -86,7 +86,7 @@ namespace Video.DomainService
} }
result.Data!.Url = UrlHostReplacer.ReplaceHost( result.Data!.Url = UrlHostReplacer.ReplaceHost(
result.Data.Url, result.Data.Url,
dto.IpAddress, ipaddress,
_configuration, _configuration,
"Time" "Time"
) + "?token=" + result.Data.Token; ) + "?token=" + result.Data.Token;
@ -122,13 +122,10 @@ namespace Video.DomainService
return new DaHApiResult<RecordsResDto> { Success = false, Code = "1009", Msg = "token无效" }; return new DaHApiResult<RecordsResDto> { Success = false, Code = "1009", Msg = "token无效" };
} }
var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/SS/Record/QueryRecords"; var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/SS/Record/QueryRecords";
if (dto.IpAddress != null)
{
url = $"https://{dto.IpAddress}/evo-apigw/admin/API/SS/Record/QueryRecords";
}
using var req = new HttpRequestMessage(HttpMethod.Post, url) using var req = new HttpRequestMessage(HttpMethod.Post, url)
{ {
Content = JsonContent.Create(dto) // 关键:把 dto 放进请求体 Content = JsonContent.Create(dto.Data) // 关键:把 dto 放进请求体
}; };
req.Headers.TryAddWithoutValidation("Authorization", token); req.Headers.TryAddWithoutValidation("Authorization", token);
@ -223,7 +220,7 @@ namespace Video.DomainService
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="NotImplementedException"></exception> /// <exception cref="NotImplementedException"></exception>
public async Task<DaHApiResult<UrlDataDto>> RealtimeStreamUrl(StreamReqDto dto) public async Task<DaHApiResult<UrlDataDto>> RealtimeStreamUrl(StreamReqDto dto, string? ipaddress)
{ {
// 1) 参数校验 + 早退 // 1) 参数校验 + 早退
if (dto == null || dto.Data == null) if (dto == null || dto.Data == null)
@ -245,15 +242,15 @@ namespace Video.DomainService
var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/video/stream/realtime"; var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/video/stream/realtime";
if (dto.IpAddress != null) if (ipaddress != null)
{ {
url = $"https://{dto.IpAddress}/evo-apigw/admin/API/video/stream/realtime"; url = $"https://{ipaddress}/evo-apigw/admin/API/video/stream/realtime";
} }
// 3) 用 HttpRequestMessage 发送,才能带上自定义头 // 3) 用 HttpRequestMessage 发送,才能带上自定义头
using var req = new HttpRequestMessage(HttpMethod.Post, url) using var req = new HttpRequestMessage(HttpMethod.Post, url)
{ {
Content = JsonContent.Create(dto) // 等价 PostAsJsonAsync,但不会丢头 Content = JsonContent.Create(dto.Data) // 等价 PostAsJsonAsync,但不会丢头
}; };
req.Headers.TryAddWithoutValidation("Authorization", token); req.Headers.TryAddWithoutValidation("Authorization", token);
@ -274,7 +271,7 @@ namespace Video.DomainService
} }
result.Data!.Url = UrlHostReplacer.ReplaceHost( result.Data!.Url = UrlHostReplacer.ReplaceHost(
result.Data.Url, result.Data.Url,
dto.IpAddress, ipaddress,
_configuration, _configuration,
"Real" "Real"
) + "?token=" + result.Data.Token; ) + "?token=" + result.Data.Token;
@ -345,7 +342,7 @@ namespace Video.DomainService
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="NotImplementedException"></exception> /// <exception cref="NotImplementedException"></exception>
public async Task<DaHApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlayBackReqDto dto) public async Task<DaHApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlayBackReqDto dto, string? ipaddress)
{ {
// 参数校验 + 早退 // 参数校验 + 早退
if (dto == null || string.IsNullOrWhiteSpace(dto.Data.ChannelId)) if (dto == null || string.IsNullOrWhiteSpace(dto.Data.ChannelId))
@ -364,14 +361,14 @@ namespace Video.DomainService
} }
var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/SS/Playback/StartPlaybackByTime"; var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/SS/Playback/StartPlaybackByTime";
if (dto.IpAddress != null) if (ipaddress != null)
{ {
url = $"https://{dto.IpAddress}/evo-apigw/admin/API/SS/Playback/StartPlaybackByTime"; url = $"https://{ipaddress}/evo-apigw/admin/API/SS/Playback/StartPlaybackByTime";
} }
using var req = new HttpRequestMessage(HttpMethod.Post, url) using var req = new HttpRequestMessage(HttpMethod.Post, url)
{ {
Content = JsonContent.Create(dto) // 关键:把 dto 放进请求体 Content = JsonContent.Create(dto.Data) // 关键:把 dto 放进请求体
}; };
req.Headers.TryAddWithoutValidation("Authorization", token); req.Headers.TryAddWithoutValidation("Authorization", token);
@ -394,7 +391,7 @@ namespace Video.DomainService
} }
result.Data!.Url = UrlHostReplacer.ReplaceHost( result.Data!.Url = UrlHostReplacer.ReplaceHost(
result.Data.Url, result.Data.Url,
dto.IpAddress, ipaddress,
_configuration, _configuration,
"Time" "Time"
) + "?token=" + result.Data.Token; ) + "?token=" + result.Data.Token;
@ -414,7 +411,7 @@ namespace Video.DomainService
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="NotImplementedException"></exception> /// <exception cref="NotImplementedException"></exception>
public async Task<DaHApiResult<UrlDataDto>> RtspStartVideoUrl(StreamRtspReqDto dto) public async Task<DaHApiResult<UrlDataDto>> RtspStartVideoUrl(StreamRtspReqDto dto, string? ipaddress)
{ {
if (dto == null || dto.Data == null) if (dto == null || dto.Data == null)
{ {
@ -431,9 +428,9 @@ namespace Video.DomainService
} }
var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/MTS/Video/StartVideo"; var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/MTS/Video/StartVideo";
if (dto.IpAddress != null) if (ipaddress != null)
{ {
url = $"https://{dto.IpAddress}/evo-apigw/admin/API/MTS/Video/StartVideo"; url = $"https://{ipaddress}/evo-apigw/admin/API/MTS/Video/StartVideo";
} }
using var req = new HttpRequestMessage(HttpMethod.Post, url) using var req = new HttpRequestMessage(HttpMethod.Post, url)
@ -461,7 +458,7 @@ namespace Video.DomainService
} }
result.Data!.Url = UrlHostReplacer.ReplaceHost( result.Data!.Url = UrlHostReplacer.ReplaceHost(
result.Data.Url, result.Data.Url,
dto.IpAddress, ipaddress,
_configuration, _configuration,
"Real" "Real"
) + "?token=" + result.Data.Token; ) + "?token=" + result.Data.Token;

@ -19,14 +19,14 @@ namespace Video.DomainService
/// </summary> /// </summary>
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
Task<DaHApiResult<UrlDataDto>> RecordVideoUrl(PlaybackReqDto dto); Task<DaHApiResult<UrlDataDto>> RecordVideoUrl(PlaybackReqDto dto, string? ipaddress);
/// <summary> /// <summary>
/// Rtsp录像回放 /// Rtsp录像回放
/// </summary> /// </summary>
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
Task<DaHApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlayBackReqDto dto); Task<DaHApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlayBackReqDto dto, string? ipaddress);
/// <summary> /// <summary>
/// 设备通道分页查询,需要用于HlsRecordVideo /// 设备通道分页查询,需要用于HlsRecordVideo
@ -41,14 +41,14 @@ namespace Video.DomainService
/// </summary> /// </summary>
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
Task<DaHApiResult<UrlDataDto>> RealtimeStreamUrl(StreamReqDto dto); Task<DaHApiResult<UrlDataDto>> RealtimeStreamUrl(StreamReqDto dto, string? ipaddress);
/// <summary> /// <summary>
/// rtsp实时预览接口方式 /// rtsp实时预览接口方式
/// </summary> /// </summary>
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
Task<DaHApiResult<UrlDataDto>> RtspStartVideoUrl(StreamRtspReqDto dto); Task<DaHApiResult<UrlDataDto>> RtspStartVideoUrl(StreamRtspReqDto dto, string? ipaddress);
/// <summary> /// <summary>
/// 注销认证信息 /// 注销认证信息

@ -10,28 +10,28 @@ namespace Video.DomainService
/// </summary> /// </summary>
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
Task<ApiResult<UrlDataDto>> GetDaHRecordVideoUrl(PlaybackReqDto dto); Task<ApiResult<UrlDataDto>> GetDaHRecordVideoUrl(PlaybackReqDto dto, string? ipaddress);
/// <summary> /// <summary>
/// 大华的实时视频 /// 大华的实时视频
/// </summary> /// </summary>
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
Task<ApiResult<UrlDataDto>> GetRealtimeUrl(StreamReqDto dto); Task<ApiResult<UrlDataDto>> GetRealtimeUrl(StreamReqDto dto, string? ipaddress);
/// <summary> /// <summary>
/// rtsp实时预览接口方式 /// rtsp实时预览接口方式
/// </summary> /// </summary>
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
Task<ApiResult<UrlDataDto>> RtspStartVideoUrl(StreamRtspReqDto dto); Task<ApiResult<UrlDataDto>> RtspStartVideoUrl(StreamRtspReqDto dto, string? ipaddress);
/// <summary> /// <summary>
/// rtsp录像回放 /// rtsp录像回放
/// </summary> /// </summary>
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
Task<ApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlayBackReqDto dto); Task<ApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlayBackReqDto dto, string? ipaddress);
/// <summary> /// <summary>
/// 大华设备通道分页查询 /// 大华设备通道分页查询

@ -35,11 +35,11 @@ namespace Video.DomainService
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="NotImplementedException"></exception> /// <exception cref="NotImplementedException"></exception>
public async Task<ApiResult<UrlDataDto>> GetDaHRecordVideoUrl(PlaybackReqDto dto) public async Task<ApiResult<UrlDataDto>> GetDaHRecordVideoUrl(PlaybackReqDto dto, string? ipaddress)
{ {
ApiResult<UrlDataDto> result = new ApiResult<UrlDataDto>() { Code = 200, Msg = "接口调用成功" }; ApiResult<UrlDataDto> result = new ApiResult<UrlDataDto>() { Code = 200, Msg = "接口调用成功" };
var urlReult = await _dahuaGeneralCtlService.RecordVideoUrl(dto); var urlReult = await _dahuaGeneralCtlService.RecordVideoUrl(dto, ipaddress);
if (!urlReult.Success) if (!urlReult.Success)
{ {
result.Code = 500; result.Code = 500;
@ -58,10 +58,10 @@ namespace Video.DomainService
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="NotImplementedException"></exception> /// <exception cref="NotImplementedException"></exception>
public async Task<ApiResult<UrlDataDto>> GetRealtimeUrl(StreamReqDto dto) public async Task<ApiResult<UrlDataDto>> GetRealtimeUrl(StreamReqDto dto, string? ipaddress)
{ {
ApiResult<UrlDataDto> result = new ApiResult<UrlDataDto>() { Code = 200, Msg = "接口调用成功" }; ApiResult<UrlDataDto> result = new ApiResult<UrlDataDto>() { Code = 200, Msg = "接口调用成功" };
var urlReult = await _dahuaGeneralCtlService.RealtimeStreamUrl(dto); var urlReult = await _dahuaGeneralCtlService.RealtimeStreamUrl(dto, ipaddress);
if (!urlReult.Success) if (!urlReult.Success)
{ {
result.Code = 500; result.Code = 500;
@ -123,10 +123,10 @@ namespace Video.DomainService
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="NotImplementedException"></exception> /// <exception cref="NotImplementedException"></exception>
public async Task<ApiResult<UrlDataDto>> RtspStartVideoUrl(StreamRtspReqDto dto) public async Task<ApiResult<UrlDataDto>> RtspStartVideoUrl(StreamRtspReqDto dto, string? ipaddress)
{ {
ApiResult<UrlDataDto> result = new ApiResult<UrlDataDto>() { Code = 200, Msg = "接口调用成功" }; ApiResult<UrlDataDto> result = new ApiResult<UrlDataDto>() { Code = 200, Msg = "接口调用成功" };
var urlReult = await _dahuaGeneralCtlService.RtspStartVideoUrl(dto); var urlReult = await _dahuaGeneralCtlService.RtspStartVideoUrl(dto, ipaddress);
if (!urlReult.Success) if (!urlReult.Success)
{ {
result.Code = 500; result.Code = 500;
@ -142,11 +142,11 @@ namespace Video.DomainService
/// </summary> /// </summary>
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
public async Task<ApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlayBackReqDto dto) public async Task<ApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlayBackReqDto dto, string? ipaddress)
{ {
ApiResult<UrlDataDto> result = new ApiResult<UrlDataDto>() { Code = 200, Msg = "接口调用成功" }; ApiResult<UrlDataDto> result = new ApiResult<UrlDataDto>() { Code = 200, Msg = "接口调用成功" };
var urlReult = await _dahuaGeneralCtlService.RtspPlaybackByTime(dto); var urlReult = await _dahuaGeneralCtlService.RtspPlaybackByTime(dto, ipaddress);
if (!urlReult.Success) if (!urlReult.Success)
{ {
result.Code = 500; result.Code = 500;

Loading…
Cancel
Save