优化文件结构
This commit is contained in:
parent
27b4b1f57a
commit
ae6e5ce836
|
|
@ -1,4 +1,4 @@
|
|||
namespace VideoAnalysisRazor.Resources;
|
||||
namespace Learn.VideoAnalysis.Components.Resources;
|
||||
|
||||
|
||||
internal class I18n
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@ namespace Learn.VideoAnalysis.Controllers.Dto
|
|||
/// 任务类型
|
||||
/// </summary>
|
||||
public TaskTypeEnum? Type { get; set; }
|
||||
/// <summary>
|
||||
/// 学科类型
|
||||
/// </summary>
|
||||
public SubjectEnum? Subject { get; set; }
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -64,6 +64,17 @@ namespace Learn.VideoAnalysis.Controllers
|
|||
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 }));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using VideoAnalysisCore.Job;
|
||||
|
||||
namespace VideoAnalysisCore.Common
|
||||
namespace Learn.VideoAnalysis.Expand
|
||||
{
|
||||
public static class CoravelExpand
|
||||
{
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Learn.VideoAnalysis.Expand
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class CorsExpand
|
||||
{
|
||||
/// <summary>
|
||||
/// 添加跨域拓展
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
public static void AddCorsExpand(this IServiceCollection services)
|
||||
{
|
||||
services.AddCors(c =>
|
||||
{
|
||||
c.AddPolicy("All", policy =>
|
||||
{
|
||||
policy.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
|
||||
});
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// 使用跨域
|
||||
/// </summary>
|
||||
/// <param name="app"></param>
|
||||
public static void UseCorsExpand(this WebApplication app)
|
||||
{
|
||||
app.UseCors("All");
|
||||
// 获取配置文件中的允许跨域的地址
|
||||
app.UseCors(options =>
|
||||
{
|
||||
options.WithOrigins("*") // 允许跨域请求的地址
|
||||
.AllowAnyHeader() // 允许的请求标头
|
||||
.AllowAnyMethod(); // 允许跨域请求的类型 (GET,POST等)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MySqlConnector;
|
||||
using SqlSugar;
|
||||
|
|
@ -11,8 +10,9 @@ using System.Linq;
|
|||
using System.Reflection;
|
||||
using System.Xml.Linq;
|
||||
using VideoAnalysisCore.Common;
|
||||
using Yitter.IdGenerator;
|
||||
|
||||
namespace VideoAnalysisCore.Common
|
||||
namespace Learn.VideoAnalysis.Expand
|
||||
{
|
||||
public static class SqlSugarExpand
|
||||
{
|
||||
|
|
@ -79,10 +79,10 @@ namespace VideoAnalysisCore.Common
|
|||
if (entityInfo.EntityColumnInfo.IsPrimarykey && !entityInfo.EntityColumnInfo.IsIdentity && entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(long))
|
||||
{
|
||||
var id = entityInfo.EntityColumnInfo.PropertyInfo.GetValue(entityInfo.EntityValue);
|
||||
//if (id == null || (long)id == 0)
|
||||
// entityInfo.SetValue(YitIdHelper.NextId());
|
||||
if (id == null || (long)id == 0)
|
||||
entityInfo.SetValue(YitIdHelper.NextId());
|
||||
}
|
||||
if (entityInfo.PropertyName == "CreateTime")
|
||||
if (entityInfo.PropertyName == "CreateTime" && entityInfo.EntityValue is null)
|
||||
entityInfo.SetValue(DateTime.Now);
|
||||
}
|
||||
if (entityInfo.OperationType == DataFilterType.UpdateByObject)
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
global using VideoAnalysisRazor.Resources;
|
||||
global using AntDesign;
|
||||
global using AntDesign;
|
||||
|
||||
global using VideoAnalysisCore.Model;
|
||||
global using VideoAnalysisCore.Model.Dto;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ using VideoAnalysisCore.AICore.GPT.ChatGPT;
|
|||
using Microsoft.Extensions.FileProviders;
|
||||
using VideoAnalysisCore.AICore.GPT.DeepSeek;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Learn.VideoAnalysis.Expand;
|
||||
|
||||
|
||||
|
||||
|
|
@ -85,6 +86,7 @@ namespace Learn.VideoAnalysis
|
|||
|
||||
builder.Services.AddAntDesign();
|
||||
builder.Services.AddMapster();
|
||||
builder.Services.AddCorsExpand();
|
||||
|
||||
|
||||
builder.Services.Configure<ProSettings>(builder.Configuration.GetSection("ProSettings"));
|
||||
|
|
@ -125,6 +127,8 @@ namespace Learn.VideoAnalysis
|
|||
|
||||
app.MapControllers();
|
||||
|
||||
app.UseCorsExpand();
|
||||
|
||||
//×Ô¶¨Òå Ó¦ÓÃ
|
||||
SqlSugarExpand.InitDB();
|
||||
CoravelExpand.Run(app.Services);
|
||||
|
|
|
|||
|
|
@ -93,8 +93,8 @@ namespace VideoAnalysisCore.Common
|
|||
public static void Init()
|
||||
{
|
||||
Console.WriteLine("初始化 redis");
|
||||
Redis.Serialize = obj => System.Text.Json.JsonSerializer.Serialize(obj);
|
||||
Redis.Deserialize = (json, type) => System.Text.Json.JsonSerializer.Deserialize(json, type);
|
||||
Redis.Serialize = obj => JsonSerializer.Serialize(obj);
|
||||
Redis.Deserialize = (json, type) => JsonSerializer.Deserialize(json, type);
|
||||
Task.Run(() =>
|
||||
{
|
||||
Thread.Sleep(1000 * 10);
|
||||
|
|
@ -115,6 +115,14 @@ namespace VideoAnalysisCore.Common
|
|||
Redis.Set(RedisExpandKey.TaskGPT(taskId) + ":Req_" + DateTime.Now.ToString("yyyy/MM/dd_HH/mm/ss"), data, 3600 * 24);
|
||||
}
|
||||
/// <summary>
|
||||
/// 加入到消费队列
|
||||
/// </summary>
|
||||
/// <param name="taskId"></param>
|
||||
public static void JoinQueue(params long[] taskId)
|
||||
{
|
||||
Redis.LPush(RedisExpandKey.ChannelKey, taskId);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取任务进度
|
||||
/// </summary>
|
||||
/// <param name="taskId"></param>
|
||||
|
|
@ -161,7 +169,7 @@ namespace VideoAnalysisCore.Common
|
|||
public static async Task TaskEnd(string task)
|
||||
{
|
||||
var tId = long.Parse(task);
|
||||
var gptRes = (await RedisExpand.Redis
|
||||
var gptRes = (await Redis
|
||||
.HMGetAsync<TaskRes>(RedisExpandKey.Task(task), "ChatAnalysis")).FirstOrDefault();
|
||||
if (gptRes is null)
|
||||
throw new Exception("未能读取到GPT处理结果");
|
||||
|
|
|
|||
|
|
@ -2,10 +2,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VideoAnalysisCore.Common;
|
||||
using VideoAnalysisCore.Model;
|
||||
using VideoAnalysisCore.Model.Dto;
|
||||
using VideoAnalysisCore.Model.蓝鲸智库;
|
||||
|
||||
namespace VideoAnalysisCore.Job
|
||||
|
|
@ -17,10 +19,12 @@ namespace VideoAnalysisCore.Job
|
|||
{
|
||||
private readonly Repository<NodeSubscription> nodesubscriptionDB;
|
||||
private readonly Repository<Attachments> attachmentsDB;
|
||||
public NodeSubscriptionJob(Repository<Attachments> videoTaskDB, Repository<NodeSubscription> nodesubscriptionDB)
|
||||
private readonly Repository<VideoTask> videotaskDB;
|
||||
public NodeSubscriptionJob(Repository<Attachments> videoTaskDB, Repository<NodeSubscription> nodesubscriptionDB, Repository<VideoTask> videotaskDB)
|
||||
{
|
||||
this.attachmentsDB = videoTaskDB;
|
||||
this.nodesubscriptionDB = nodesubscriptionDB;
|
||||
this.videotaskDB = videotaskDB;
|
||||
}
|
||||
public async Task Invoke()
|
||||
{
|
||||
|
|
@ -61,6 +65,22 @@ namespace VideoAnalysisCore.Job
|
|||
)
|
||||
""");
|
||||
|
||||
var videos = data.Select(s => new VideoTask()
|
||||
{
|
||||
ComeFrom = "127.0.0.1",
|
||||
ApiToken = "",
|
||||
Type = item.TaskType,
|
||||
Subject = item.Subject,
|
||||
Tag = string.Empty,
|
||||
TagId = s.VideoCode,
|
||||
MediaUrl = s.Url,
|
||||
MediaName = s.Name
|
||||
}).ToArray();
|
||||
|
||||
//入库
|
||||
await videotaskDB.InsertRangeAsync(videos);
|
||||
var ids = videos.Select(s => s.Id).ToArray();
|
||||
RedisExpand.JoinQueue(ids);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@ namespace VideoAnalysisCore.Model
|
|||
[DisplayName("绑定学科")]
|
||||
public TaskTypeEnum TaskType { get; set; }
|
||||
/// <summary>
|
||||
/// 学科
|
||||
/// </summary>
|
||||
public SubjectEnum Subject { get; set; }
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
[DisplayName("是否启用")]
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ namespace VideoAnalysisCore.Model
|
|||
/// 任务id
|
||||
/// <para>视频音频文件地址都使用taskID能获取</para>
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 媒体路径
|
||||
|
|
|
|||
Loading…
Reference in New Issue