修改一下参数

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

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

@ -37,9 +37,9 @@ namespace Video.API.Controllers.DaHua
/// <param name="dto"></param>
/// <returns></returns>
[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>
@ -48,9 +48,9 @@ namespace Video.API.Controllers.DaHua
/// <param name="dto"></param>
/// <returns></returns>
[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>
@ -59,9 +59,9 @@ namespace Video.API.Controllers.DaHua
/// <param name="dto"></param>
/// <returns></returns>
[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>
@ -70,9 +70,9 @@ namespace Video.API.Controllers.DaHua
/// <param name="dto"></param>
/// <returns></returns>
[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>

@ -38,7 +38,7 @@ namespace Video.DomainService
/// <param name="dto"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<DaHApiResult<UrlDataDto>> RecordVideoUrl(PlaybackReqDto dto)
public async Task<DaHApiResult<UrlDataDto>> RecordVideoUrl(PlaybackReqDto dto, string? ipaddress)
{
// 1) 参数校验 + 早退
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无效" };
}
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 发送,才能带上头
using var req = new HttpRequestMessage(HttpMethod.Post, url)
{
Content = JsonContent.Create(dto) // 关键:别再丢 body 了
Content = JsonContent.Create(dto.Data) // 关键:别再丢 body 了
};
req.Headers.TryAddWithoutValidation("Authorization", token);
@ -86,7 +86,7 @@ namespace Video.DomainService
}
result.Data!.Url = UrlHostReplacer.ReplaceHost(
result.Data.Url,
dto.IpAddress,
ipaddress,
_configuration,
"Time"
) + "?token=" + result.Data.Token;
@ -122,13 +122,10 @@ namespace Video.DomainService
return new DaHApiResult<RecordsResDto> { Success = false, Code = "1009", Msg = "token无效" };
}
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)
{
Content = JsonContent.Create(dto) // 关键:把 dto 放进请求体
Content = JsonContent.Create(dto.Data) // 关键:把 dto 放进请求体
};
req.Headers.TryAddWithoutValidation("Authorization", token);
@ -223,7 +220,7 @@ namespace Video.DomainService
/// <param name="dto"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<DaHApiResult<UrlDataDto>> RealtimeStreamUrl(StreamReqDto dto)
public async Task<DaHApiResult<UrlDataDto>> RealtimeStreamUrl(StreamReqDto dto, string? ipaddress)
{
// 1) 参数校验 + 早退
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";
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 发送,才能带上自定义头
using var req = new HttpRequestMessage(HttpMethod.Post, url)
{
Content = JsonContent.Create(dto) // 等价 PostAsJsonAsync,但不会丢头
Content = JsonContent.Create(dto.Data) // 等价 PostAsJsonAsync,但不会丢头
};
req.Headers.TryAddWithoutValidation("Authorization", token);
@ -274,7 +271,7 @@ namespace Video.DomainService
}
result.Data!.Url = UrlHostReplacer.ReplaceHost(
result.Data.Url,
dto.IpAddress,
ipaddress,
_configuration,
"Real"
) + "?token=" + result.Data.Token;
@ -345,7 +342,7 @@ namespace Video.DomainService
/// <param name="dto"></param>
/// <returns></returns>
/// <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))
@ -364,14 +361,14 @@ namespace Video.DomainService
}
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)
{
Content = JsonContent.Create(dto) // 关键:把 dto 放进请求体
Content = JsonContent.Create(dto.Data) // 关键:把 dto 放进请求体
};
req.Headers.TryAddWithoutValidation("Authorization", token);
@ -394,7 +391,7 @@ namespace Video.DomainService
}
result.Data!.Url = UrlHostReplacer.ReplaceHost(
result.Data.Url,
dto.IpAddress,
ipaddress,
_configuration,
"Time"
) + "?token=" + result.Data.Token;
@ -414,7 +411,7 @@ namespace Video.DomainService
/// <param name="dto"></param>
/// <returns></returns>
/// <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)
{
@ -431,9 +428,9 @@ namespace Video.DomainService
}
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)
@ -461,7 +458,7 @@ namespace Video.DomainService
}
result.Data!.Url = UrlHostReplacer.ReplaceHost(
result.Data.Url,
dto.IpAddress,
ipaddress,
_configuration,
"Real"
) + "?token=" + result.Data.Token;

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

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

@ -35,11 +35,11 @@ namespace Video.DomainService
/// <param name="dto"></param>
/// <returns></returns>
/// <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 = "接口调用成功" };
var urlReult = await _dahuaGeneralCtlService.RecordVideoUrl(dto);
var urlReult = await _dahuaGeneralCtlService.RecordVideoUrl(dto, ipaddress);
if (!urlReult.Success)
{
result.Code = 500;
@ -58,10 +58,10 @@ namespace Video.DomainService
/// <param name="dto"></param>
/// <returns></returns>
/// <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 = "接口调用成功" };
var urlReult = await _dahuaGeneralCtlService.RealtimeStreamUrl(dto);
var urlReult = await _dahuaGeneralCtlService.RealtimeStreamUrl(dto, ipaddress);
if (!urlReult.Success)
{
result.Code = 500;
@ -123,10 +123,10 @@ namespace Video.DomainService
/// <param name="dto"></param>
/// <returns></returns>
/// <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 = "接口调用成功" };
var urlReult = await _dahuaGeneralCtlService.RtspStartVideoUrl(dto);
var urlReult = await _dahuaGeneralCtlService.RtspStartVideoUrl(dto, ipaddress);
if (!urlReult.Success)
{
result.Code = 500;
@ -142,11 +142,11 @@ namespace Video.DomainService
/// </summary>
/// <param name="dto"></param>
/// <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 = "接口调用成功" };
var urlReult = await _dahuaGeneralCtlService.RtspPlaybackByTime(dto);
var urlReult = await _dahuaGeneralCtlService.RtspPlaybackByTime(dto, ipaddress);
if (!urlReult.Success)
{
result.Code = 500;

Loading…
Cancel
Save