139 lines
4.8 KiB
C#
139 lines
4.8 KiB
C#
|
|
using VideoAnalysisCore.Common;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Reflection;
|
|
using MapsterMapper;
|
|
using Mapster;
|
|
using VideoAnalysisCore.AICore.SherpaOnnx;
|
|
using UserCenter.Model.Enum;
|
|
using VideoAnalysisCore.AICore.GPT.ChatGPT;
|
|
using VideoAnalysisCore.AICore.GPT;
|
|
using System.Text.Json;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using VideoAnalysisCore.Model.Enum;
|
|
|
|
namespace Learn.VideoAnalysis.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 蓝鲸字库接口
|
|
/// </summary>
|
|
[ApiController]
|
|
[Route("LJZK/[action]")]
|
|
public class LJZK_Controller : ControllerBase
|
|
{
|
|
private readonly ILogger<LJZK_Controller> _logger;
|
|
private readonly IMapper mp;
|
|
private readonly Repository<NodeSubscription> nodesubscriptionDB;
|
|
private readonly Repository<VideoTask> videoTaskDB;
|
|
private readonly Repository<VideoKonwPoint> videoKonwPointDB;
|
|
private readonly IBserGPT chatGPT;
|
|
public LJZK_Controller(ILogger<LJZK_Controller> logger,
|
|
IMapper mp, IBserGPT chatGPT, Repository<NodeSubscription> nodesubscriptionDB, Repository<VideoTask> videoTaskDB = null, Repository<VideoKonwPoint> videoKonwPointDB = null)
|
|
{
|
|
_logger = logger;
|
|
this.mp = mp;
|
|
this.chatGPT = chatGPT;
|
|
this.nodesubscriptionDB = nodesubscriptionDB;
|
|
this.videoTaskDB = videoTaskDB;
|
|
this.videoKonwPointDB = videoKonwPointDB;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 蓝鲸智库_添加文件节点监控
|
|
/// </summary>
|
|
/// <param name="req">请求体</param>
|
|
/// <returns></returns>
|
|
[HttpPost(Name = "NodeSubscription")]
|
|
public async Task<IActionResult> NodeSubscription(NodeMonitoringReq req)
|
|
{
|
|
if(req is null || req.NodeId ==0)
|
|
return BadRequest("无效的提交数据");
|
|
if (nodesubscriptionDB.IsAny(s => s.NodeId == req.NodeId))
|
|
return BadRequest("重复添加了节点监控任务" + req.NodeId);
|
|
var res = await nodesubscriptionDB.InsertReturnEntityAsync(new NodeSubscription()
|
|
{
|
|
NodeId = req.NodeId,
|
|
TaskType = req.Type ?? default,
|
|
Subject = req.Subject?? default,
|
|
|
|
});
|
|
return Ok(res);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取任务类型
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet(Name = "TaskTypList")]
|
|
public IActionResult TaskType()
|
|
{
|
|
Type type = typeof(TaskTypeEnum);
|
|
return Ok(Enum.GetValues(type).Cast<object>()
|
|
.Select(s => new { Text = s.ToString(), Value = (int)s }));
|
|
}
|
|
/// <summary>
|
|
/// 获取学科类型
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet(Name = "SubjectList")]
|
|
public IActionResult Subject()
|
|
{
|
|
Type type = typeof(SubjectEnum);
|
|
return Ok(Enum.GetValues(type).Cast<object>()
|
|
.Select(s => new { Text = s.ToString(), Value = (int)s }));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取视频知识点片段<para>taskId/tagId二选一</para>
|
|
/// </summary>
|
|
/// <param name="taskId"></param>
|
|
/// <param name="tagId">自定义id</param>
|
|
/// <returns></returns>
|
|
[HttpGet(Name = "TaskKnowInfo")]
|
|
public async Task<IActionResult> TaskKnowInfo(long taskId, string? tagId)
|
|
{
|
|
if (taskId == 0 && string.IsNullOrEmpty(tagId))
|
|
return BadRequest();
|
|
var task = await videoTaskDB.AsQueryable()
|
|
.WhereIF(taskId != 0, s => s.Id == taskId)
|
|
.WhereIF(!string.IsNullOrEmpty(tagId), s => s.TagId == tagId)
|
|
.FirstAsync();
|
|
if (task is null)
|
|
return BadRequest("无效任务");
|
|
|
|
var konwArr = await videoKonwPointDB.AsQueryable()
|
|
.Where(s => s.VideoTaskId == task.Id)
|
|
.ToArrayAsync();
|
|
if (konwArr is null || konwArr.Length == 0)
|
|
return BadRequest("无效任务");
|
|
return Ok(new TaskKnowRes()
|
|
{
|
|
TagId = task.TagId,
|
|
Status = task.LastEnum,
|
|
VideoTaskId = task.Id,
|
|
KnowBlockArr = konwArr
|
|
.GroupBy(s => s.StartTime)
|
|
.Select(s => new TaskKnowBlock()
|
|
{
|
|
Id = s.First().Id,
|
|
Content = s.First().Content,
|
|
StartTime = s.First().StartTime,
|
|
EndTime = s.First().EndTime,
|
|
Theme = s.First().Theme,
|
|
Know = s.Select(x => new TaskKnowInfo()
|
|
{
|
|
Id = x.Id,
|
|
KnowPoint = x.KnowPoint,
|
|
KnowPointId = x.KnowPointId
|
|
}).ToArray()
|
|
}).ToArray()
|
|
});
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|