diff --git a/VideoAnalysis/Controllers/ApiController.cs b/VideoAnalysis/Controllers/ApiController.cs index 551526e..1be35f5 100644 --- a/VideoAnalysis/Controllers/ApiController.cs +++ b/VideoAnalysis/Controllers/ApiController.cs @@ -11,6 +11,8 @@ using VideoAnalysisCore.AICore.ChatGPT.Dto; using AntDesign; using System.Threading.Tasks; using FFmpeg.NET.Services; +using MapsterMapper; +using Mapster; namespace Learn.VideoAnalysis.Controllers { @@ -19,11 +21,13 @@ namespace Learn.VideoAnalysis.Controllers public class ApiController : ControllerBase { private readonly ILogger _logger; + private readonly IMapper mp; private readonly Repository videoTaskDB; - public ApiController(ILogger logger, Repository videoTaskDB) + public ApiController(ILogger logger, Repository videoTaskDB, IMapper mp) { _logger = logger; this.videoTaskDB = videoTaskDB; + this.mp = mp; } private string GetClientIpAddress() @@ -53,25 +57,23 @@ namespace Learn.VideoAnalysis.Controllers .FirstAsync(); if (task is null) return BadRequest(); - var taskData = task.ChatAnalysis; + var taskData = task.ChatAnalysis.Adapt(); + if (taskData is null) + return BadRequest(); + taskData.Status = task.LastEnum; if (task.LastEnum != RedisChannelEnum.EndTask) - return BadRequest(new - { - Enum = task.LastEnum , - Task = taskData - }); + return BadRequest(taskData); if (!needSubtitle && taskData != null && taskData.TimeBase != null) { - foreach (var item in taskData.TimeBase) - { - item.Content = null; - } + taskData.TimeBase = taskData.TimeBase + .Select(s => + { + s.Content = null; + return s; + }) + .ToArray(); } - return Ok(new - { - Enum = task.LastEnum, - Task = taskData - }); + return Ok(taskData); } /// diff --git a/VideoAnalysis/Controllers/Dto/ApiDto.cs b/VideoAnalysis/Controllers/Dto/ApiDto.cs index fa0b0bc..35c9a35 100644 --- a/VideoAnalysis/Controllers/Dto/ApiDto.cs +++ b/VideoAnalysis/Controllers/Dto/ApiDto.cs @@ -1,4 +1,7 @@ -using System.ComponentModel.DataAnnotations; +using AntDesign; +using System.ComponentModel.DataAnnotations; +using VideoAnalysisCore.AICore.ChatGPT.Dto; +using VideoAnalysisCore.Enum; namespace Learn.VideoAnalysis.Controllers.Dto { @@ -35,4 +38,47 @@ namespace Learn.VideoAnalysis.Controllers.Dto } + public class TextValue + { + public TextValue(float v) + { + var s = TimeSpan.FromSeconds((double)v); + Text = s.ToString(@"mm\:ss"); + Value = v; + } + public TextValue(string t,object v) + { + + } + public TextValue() + { + + } + public string Text { get; set; } + public object Value { get; set; } + } + public class TaskInfoRes: TaskRes + { + public TaskInfoRes() + { + + } + /// + /// 任务当前执行状态 + /// + public RedisChannelEnum Status { get; set; } + /// + /// 时间轴状态枚举 + /// + public Dictionary TimeTypeEnum => + Enum.GetValues(typeof(TimeBaseTypeEnum)) + .Cast() + .ToDictionary(x => (int)x, x => x.ToString()); + /// + /// 时间轴合计 + /// + public Dictionary? TimeBaseTotal => + TimeBase?.GroupBy(s => s.TimeBaseType??TimeBaseTypeEnum.教师讲授)? + .ToDictionary(s => s.Key, s => new TextValue(s.Sum(x => x.End - x.Start))); + } } diff --git a/VideoAnalysisCore/AICore/ChatGPT/Dto/QuestionRes.cs b/VideoAnalysisCore/AICore/ChatGPT/Dto/QuestionRes.cs index 52dee63..11136b1 100644 --- a/VideoAnalysisCore/AICore/ChatGPT/Dto/QuestionRes.cs +++ b/VideoAnalysisCore/AICore/ChatGPT/Dto/QuestionRes.cs @@ -66,6 +66,11 @@ namespace VideoAnalysisCore.AICore.ChatGPT.Dto /// 差的评价 /// public CourseCriteria[]? Bad { get; set; } + /// + /// 改进意见 + /// + public string[]? BadImprovedMethods => + Bad?.Select(s => s.ImprovedMethods??string.Empty)?.ToArray(); } }