From 9d7edad80a7da6337038b3621aac583193c4a780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=82=A5=E7=BE=8A?= <1048382248@qq.com> Date: Thu, 12 Feb 2026 10:30:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20API=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=9A=84=E9=83=A8=E5=88=86=E6=B5=81=E7=A8=8B=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20=E6=96=B0=E5=A2=9E=20API=E6=9C=8D=E5=8A=A1=E7=9A=84=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=AF=B7=E6=B1=82=E5=86=99=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Learn.VideoAnalysis.API/Expand/HttpFilter.cs | 279 ++++++++++++++++++ Learn.VideoAnalysis.API/Program.cs | 23 +- VideoAnalysisCore/AICore/GPT/BserGPT.cs | 1 + .../AICore/GPT/DeepSeek/DeepSeekGPTClient.cs | 10 +- .../AICore/GPT/GTP_Analysis_1.cs | 24 +- .../AICore/GPT/Gemini/GeminiGPTClient.cs | 9 +- VideoAnalysisCore/Common/Dto/BaseReturn.cs | 34 +++ VideoAnalysisCore/Common/Dto/ComboModel.cs | 26 ++ VideoAnalysisCore/Common/Dto/PageResult.cs | 16 + VideoAnalysisCore/Common/OhException.cs | 67 +++++ .../Controllers/LJZK_Controller.cs | 13 +- VideoAnalysisCore/Model/HttpLog.cs | 79 +++++ 12 files changed, 550 insertions(+), 31 deletions(-) create mode 100644 Learn.VideoAnalysis.API/Expand/HttpFilter.cs create mode 100644 VideoAnalysisCore/Common/Dto/BaseReturn.cs create mode 100644 VideoAnalysisCore/Common/Dto/ComboModel.cs create mode 100644 VideoAnalysisCore/Common/Dto/PageResult.cs create mode 100644 VideoAnalysisCore/Common/OhException.cs create mode 100644 VideoAnalysisCore/Model/HttpLog.cs diff --git a/Learn.VideoAnalysis.API/Expand/HttpFilter.cs b/Learn.VideoAnalysis.API/Expand/HttpFilter.cs new file mode 100644 index 0000000..ade2cd9 --- /dev/null +++ b/Learn.VideoAnalysis.API/Expand/HttpFilter.cs @@ -0,0 +1,279 @@ +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using System; +using System.Linq; +using Microsoft.AspNetCore.Http; +using SqlSugar; +using Microsoft.AspNetCore.Mvc.Infrastructure; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using System.Threading.Tasks; +using System.Runtime.InteropServices; +using System.Diagnostics; +using System.Text.Json; +using System.Collections.Generic; +using System.Data; +using Microsoft.Extensions.Hosting; +using System.IO; +using Microsoft.AspNetCore.Hosting; +using SqlSugar.IOC; +using Microsoft.AspNetCore.Authorization; +using VideoAnalysisCore.Common.Dto; +using VideoAnalysisCore.Common; +using VideoAnalysisCore.Model; + +namespace Learn.VideoAnalysis.API.Expand +{ + + /// + /// 使用该属性,接口对结果原样输出,不做包装 + /// + [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = false)] + public class ResultIgnore : Attribute { } + + /// + /// http接口日志启用 + /// + public class HttpLogEnable : Attribute { } + + /// + /// Http请求过滤器 + /// + public class HttpLogAttribute : ActionFilterAttribute, IAsyncExceptionFilter + { + readonly Stopwatch _stopwatch;//统计程序耗时 + + public HttpLogAttribute() + { + _stopwatch = Stopwatch.StartNew(); + } + + /// + /// 执行接口前文件做缓存处理 + /// + /// + /// + public void ExecutingFileCached(ActionExecutingContext context) + { + //特殊处理:ResultIgnore,不进行返回结果包装,原样输出 + var endpoint = context.HttpContext.GetEndpoint(); + // 直接返回原始结果,不封装 + if (endpoint?.Metadata.GetMetadata() == null) return; + if (context.HttpContext.Request.HasFormContentType && + context.HttpContext.Request.Form.Files != null && + context.HttpContext.Request.Form.Files.Count() > 0) + { + context.HttpContext.Items["FileCached"]= + context.HttpContext.Request.Form.Files.Select(s => + { + var stream = new MemoryStream(); + s.CopyTo(stream); + stream.Position = 0; + return (s, stream); + }).ToArray(); + } + + } + /// + /// 执行接口前400 处理 + /// + /// + /// + public void Executing400(ActionExecutingContext context) + { + if (!context.ModelState.IsValid) + { + var errMsg = string.Join(',', context.ModelState.Values.SelectMany(s => s.Errors.Select(e => e.ErrorMessage))); + Oh.ModelError(errMsg); + } + } + private bool HasAttribute(ActionExecutedContext context) where T : Attribute + { + if (context.ActionDescriptor is ControllerActionDescriptor descriptor) + { + // 检查方法上是否有 SkipApiResultAttribute + if (descriptor.MethodInfo.GetCustomAttributes(typeof(T), false).Any()) + return true; + // 检查控制器上是否有 SkipApiResultAttribute + if (descriptor.ControllerTypeInfo.GetCustomAttributes(typeof(T), false).Any()) + return true; + } + return false; + } + /// + /// 接口结果格式化 + /// + /// + public BaseReturn? ApiResultFormatting(ActionExecutedContext context) + { + //特殊处理:ResultIgnore,不进行返回结果包装,原样输出 + if (HasAttribute(context)) + { + base.OnActionExecuted(context); + return null; + } + // 返回结果为JsonResult的请求进行Result包装 + if (context.Exception != null) + throw context.Exception; + if (context.Result != null) + { + object? resData = null; + if (context.Result is ObjectResult objectResult) + resData = objectResult.Value; + else if (context.Result is ContentResult contentRes) + resData = contentRes.Content; + else if (context.Result is JsonResult resJ) + resData = resJ.Value; + else if (context.Result is FileResult) + return null; + var code = (context?.Result as IStatusCodeActionResult)?.StatusCode ?? 200; + var res = new BaseReturn() + { + Code = code, + Data = resData, + Message = "SUCCESS" + }; + //不对返回结果结果做修改 + //context.Result = new JsonResult(res); + return res; + } + return null; + } + /// + /// 添加http日志信息 + /// + /// + /// + /// + /// + public async Task AddHttpLogAsync(HttpContext context, BaseReturn? result = null, Exception? e = null) + { + //特殊处理:ResultIgnore,不进行返回结果包装,原样输出 + var endpoint = context.GetEndpoint(); + // 所有请求都记录 + //if (endpoint?.Metadata.GetMetadata() == null&& e is null) return; + + string request = null; + var logId = Yitter.IdGenerator.YitIdHelper.NextId(); + if (!context.Request.Method.Equals("GET", StringComparison.InvariantCultureIgnoreCase)) + { + //记录请求参数 + if (context.Request.Body.CanSeek) + { + try + { + var fileArr = context.Items.ContainsKey("FileCached") ? context.Items["FileCached"] as (IFormFile file, MemoryStream stream)[] : null; + if (context.Request.HasFormContentType && fileArr != null) + { + // 设置保存目录(例如:项目根目录下的Uploads文件夹) + string uploadsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UploadLogs", logId.ToString()); + // 创建目录(如果不存在) + if (!Directory.Exists(uploadsFolder)) + Directory.CreateDirectory(uploadsFolder); + foreach (var fileInfo in fileArr) + { + // 生成安全文件名(防止路径遍历攻击) + string uniqueFileName = Guid.NewGuid().ToString().Substring(0, 5) + "_" + Path.GetFileName(fileInfo.file.FileName); + // 保存文件 + using var stream = new FileStream(Path.Combine(uploadsFolder, uniqueFileName), FileMode.Create, FileAccess.Write); + fileInfo.stream.Position = 0; + await fileInfo.stream.CopyToAsync(stream); + fileInfo.stream.Dispose(); + } + request = $"请求体包含{context.Request.Form.Files.Count()}个文件 目录 {uploadsFolder}"; + } + else + { + context.Request.Body.Position = 0; + using var sr = new System.IO.StreamReader(context.Request.Body); + request = await sr.ReadToEndAsync(); + } + } + catch (Exception ex) + { + request = "处理请求入参时发生了错误 \r\n" + ex.ToString() + "\r\n 原有请求数据 " + request; + } + } + } + //写入队列 + await DbScoped.Sugar.CopyNew() + .Insertable(new HttpLog + { + Id = logId, + Url = context.Request.Path + context.Request.QueryString, + Method = context.Request.Method, + Request = request, + IP = $"{context.Connection?.RemoteIpAddress?.ToString()}", + ResponseCode = result?.Code ?? -1, + Response = (result != null ? JsonSerializer.Serialize(result) : null) , + Authorization = context.Request.Headers.ContainsKey("Authorization") + ? context.Request.Headers["Authorization"].ToString() + : string.Empty, + Exception = e?.ToString(), + ExceptionMessage = e?.Message, + AdminId = 0, + TotalMilliseconds = (double)_stopwatch.Elapsed.TotalMilliseconds + }).ExecuteCommandAsync(); + } + + + public override async void OnActionExecuting(ActionExecutingContext context) + { + // 过期的 + //if (context.HttpContext.GetEndpoint()? + // .Metadata.GetMetadata() is null) + //{ + // context.Result = new UnauthorizedResult(); + // return; + //} + + + Executing400(context); + ExecutingFileCached(context); + base.OnActionExecuting(context); + } + + /// + /// 在Controller的Action执行后执行 + /// + /// + public override async void OnActionExecuted(ActionExecutedContext context) + { + try + { + BaseReturn? res = ApiResultFormatting(context); + await AddHttpLogAsync(context.HttpContext, res); + } + catch (Exception ex) + { + } + + base.OnActionExecuted(context); + } + /// + /// 执行错误时 + /// + /// + /// + public async Task OnExceptionAsync(ExceptionContext context) + { + var code = -1; + var msg = context.Exception.Message; + if (context.Exception is OhException exception) + code = exception.Code; + var result = new BaseReturn() + { + Code = code, + Message = context.Exception.Message + }; + context.Result = new JsonResult(result); + await AddHttpLogAsync(context.HttpContext, null, context.Exception); + if (code == 401 || code == 403) + context.HttpContext.Response.StatusCode = code; + context.ExceptionHandled = true; + + } + } + +} diff --git a/Learn.VideoAnalysis.API/Program.cs b/Learn.VideoAnalysis.API/Program.cs index 7914399..9218e7e 100644 --- a/Learn.VideoAnalysis.API/Program.cs +++ b/Learn.VideoAnalysis.API/Program.cs @@ -2,6 +2,9 @@ using Learn.VideoAnalysis.API.Expand; using Mapster; using Microsoft.OpenApi.Models; +using System.Text.Encodings.Web; +using System.Text.Json; +using System.Text.Unicode; using VideoAnalysisCore.AICore.FFMPGE; using VideoAnalysisCore.AICore.GPT.DeepSeek; using VideoAnalysisCore.AICore.SherpaOnnx; @@ -18,8 +21,17 @@ namespace Learn.VideoAnalysis.API // Add services to the container. - builder.Services.AddControllers(); - // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle + builder.Services.AddControllers(options => + { + // ȫģ͸ֵĬֵ ͳһظʽ + options.Filters.Add(); + }).AddJsonOptions(options => + { + + options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);//תʱʹUnicode + //options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;// ĬСշ null շ + }); + builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(c => { @@ -42,10 +54,8 @@ namespace Learn.VideoAnalysis.API builder.Services.AddCoravel(); builder.Services.AddCorsExpand(); - builder.Services.AddDownloadFileExpand(); - builder.Services.AddFFMPGEExpand(); - builder.Services.AddSenseVoiceExpand(); - builder.Services.AddHttpContextAccessor(); + + builder.Services.AddControllersWithViews(options => { options.Filters.Add(typeof(ExceptionFilter)); @@ -62,7 +72,6 @@ namespace Learn.VideoAnalysis.API app.UseHttpsRedirection(); - app.UseAuthorization(); app.MapControllers(); diff --git a/VideoAnalysisCore/AICore/GPT/BserGPT.cs b/VideoAnalysisCore/AICore/GPT/BserGPT.cs index d6901f0..3da3c16 100644 --- a/VideoAnalysisCore/AICore/GPT/BserGPT.cs +++ b/VideoAnalysisCore/AICore/GPT/BserGPT.cs @@ -11,6 +11,7 @@ using Microsoft.Extensions.DependencyInjection; using VideoAnalysisCore.AICore.GPT.ChatGPT; using VideoAnalysisCore.AICore.GPT.DeepSeek; using System.Text.Json.Serialization; +using VideoAnalysisCore.AICore.GPT.Gemini; namespace VideoAnalysisCore.AICore.GPT { diff --git a/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeekGPTClient.cs b/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeekGPTClient.cs index 20308bc..cee20a1 100644 --- a/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeekGPTClient.cs +++ b/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeekGPTClient.cs @@ -7,12 +7,10 @@ using System.Net.Http; using Newtonsoft.Json; using System.Net.Http.Json; using System.Net; -using VideoAnalysisCore.AICore.GPT.DeepSeek; -using VideoAnalysisCore.AICore.GPT; using System.Text.Json; -namespace VideoAnalysisCore.AICore.GPT.ChatGPT +namespace VideoAnalysisCore.AICore.GPT.DeepSeek { public class DeepSeekGPTClient : GPTClient @@ -24,7 +22,7 @@ namespace VideoAnalysisCore.AICore.GPT.ChatGPT private readonly RedisManager redisManager; public DeepSeekGPTClient(IHttpClientFactory httpClientFactory, RedisManager redisManager) - :base(httpClientFactory, redisManager) + : base(httpClientFactory, redisManager) { _httpClientFactory = httpClientFactory; this.redisManager = redisManager; @@ -48,7 +46,7 @@ namespace VideoAnalysisCore.AICore.GPT.ChatGPT new Message(postMessages,"user"), ]; messageArr = messageArr.Where(s => s != null).ToArray(); - if (max_tokens > 8000 &&(model is null || model == ChatGPTType.Deepseek_Chat)) + if (max_tokens > 8000 && (model is null || model == ChatGPTType.Deepseek_Chat)) max_tokens = 8000; var chatReq = new ChatRequest { @@ -59,7 +57,7 @@ namespace VideoAnalysisCore.AICore.GPT.ChatGPT stream = true, messages = messageArr }; - return await base.ChatAsync(chatReq); + return await ChatAsync(chatReq); } } diff --git a/VideoAnalysisCore/AICore/GPT/GTP_Analysis_1.cs b/VideoAnalysisCore/AICore/GPT/GTP_Analysis_1.cs index 5f8057a..5d19b2e 100644 --- a/VideoAnalysisCore/AICore/GPT/GTP_Analysis_1.cs +++ b/VideoAnalysisCore/AICore/GPT/GTP_Analysis_1.cs @@ -25,13 +25,15 @@ using System.Text.RegularExpressions; using System.Diagnostics; using Dm.util; using static System.Net.Mime.MediaTypeNames; +using VideoAnalysisCore.AICore.GPT.DeepSeek; +using VideoAnalysisCore.AICore.GPT.Gemini; -namespace VideoAnalysisCore.AICore.GPT.DeepSeek +namespace VideoAnalysisCore.AICore.GPT { /// /// 视频分析工作流1 /// - public class GTP_Analysis_1 : IBserGPTWorkflow + public class GTP_Analysis_1 : IBserGPTWorkflow { private readonly GeminiGPTClient geminiClient; private readonly DeepSeekGPTClient deepSeekClient; @@ -134,7 +136,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek .SelectMany( s => { - var StageId = Yitter.IdGenerator.YitIdHelper.NextId(); + var StageId = YitIdHelper.NextId(); return s.KnowPoints.Where(x => knowDic.ContainsKey(x.KnowPoint)) .Select(x => new VideoKonwPoint() { @@ -173,7 +175,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek || s.Depth == 2)) .Select(s => s.Name).ToArrayAsync(); var captionsArr = JsonSerializer.Deserialize(taskInfo.Captions); - + var fileNameResFormat = "{授课章节: string|null}"; var rCaptionArr = string.Join(',', captionsArr .Where((s, i) => i % 3 == 0) @@ -300,11 +302,11 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek Func>>[] chatClentArr = [ - async (string m)=>await deepSeekClient + async (m)=>await deepSeekClient .ChatAsync>(taskInfo.Id.ToString(), m, "优化字幕",ChatGPTType.Deepseek_Chat,8_000), - async (string m)=>await chatGPTClient + async (m)=>await chatGPTClient .ChatAsync>(taskInfo.Id.ToString(), m, "优化字幕",ChatGPTType.GPT5,16_000), - async (string m)=>await geminiClient + async (m)=>await geminiClient .ChatAsync>(taskInfo.Id.ToString(), m, "优化字幕",ChatGPTType.Gemini_3_Chat,16_000), ]; await Parallel.ForAsync(0, totalCount, new ParallelOptions() @@ -499,8 +501,8 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek .ToList(); if (ordered.Any(s => - (!string.IsNullOrWhiteSpace(s.Stage) && s.Stage.Contains("作业")) || - (!string.IsNullOrWhiteSpace(s.Theme) && s.Theme.Contains("作业")))) + !string.IsNullOrWhiteSpace(s.Stage) && s.Stage.Contains("作业") || + !string.IsNullOrWhiteSpace(s.Theme) && s.Theme.Contains("作业"))) return ordered.ToArray(); var end = homeworkStage.EndTime ?? maxVideoTime; @@ -804,11 +806,11 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek VideoTaskId = taskInfo.Id, CourseLevel = taskInfo.CourseLevel, TextBookVersionId = taskInfo.TextBookVersionId, - GradeSemester= taskInfo.GradeSemester, + GradeSemester = taskInfo.GradeSemester, GradeId = taskInfo.GradeId, }).ToList(); //尝试追加 作业布置分段 - if (homework != null && (!questionRes.Any(s => s.Stage == StageEnum.作业布置.ToString()))) + if (homework != null && !questionRes.Any(s => s.Stage == StageEnum.作业布置.ToString())) tStage.Add(homework.Adapt()); await videoTaskStageDB.InsertRangeAsync(tStage); await videoKonwPointDB.InsertRangeAsync(insertData); diff --git a/VideoAnalysisCore/AICore/GPT/Gemini/GeminiGPTClient.cs b/VideoAnalysisCore/AICore/GPT/Gemini/GeminiGPTClient.cs index 772e335..dcc51b0 100644 --- a/VideoAnalysisCore/AICore/GPT/Gemini/GeminiGPTClient.cs +++ b/VideoAnalysisCore/AICore/GPT/Gemini/GeminiGPTClient.cs @@ -8,11 +8,10 @@ using Newtonsoft.Json; using System.Net.Http.Json; using System.Net; using VideoAnalysisCore.AICore.GPT.DeepSeek; -using VideoAnalysisCore.AICore.GPT; using System.Text.Json; -namespace VideoAnalysisCore.AICore.GPT.ChatGPT +namespace VideoAnalysisCore.AICore.GPT.Gemini { public class GeminiGPTClient : GPTClient @@ -52,19 +51,19 @@ namespace VideoAnalysisCore.AICore.GPT.ChatGPT var chatReq = new ChatRequest { taskId = task, - title=title, + title = title, model = model, max_tokens = max_tokens, stream = true, messages = messageArr, - max_completion_tokens= 12288, + max_completion_tokens = 12288, }; chatReq.modalities = null; chatReq.max_tokens = null; chatReq.top_p = null; - return await base.ChatAsync(chatReq); + return await ChatAsync(chatReq); } } diff --git a/VideoAnalysisCore/Common/Dto/BaseReturn.cs b/VideoAnalysisCore/Common/Dto/BaseReturn.cs new file mode 100644 index 0000000..b3a1315 --- /dev/null +++ b/VideoAnalysisCore/Common/Dto/BaseReturn.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VideoAnalysisCore.Common.Dto +{ + public class BaseReturn + { + + /// + /// 消息码 + /// + public int Code { get; set; } + /// + /// 消息 + /// + public string? Message { get; set; } + } + public class BaseReturn + { + public T? Data { get; set; } + + /// + /// 消息码 + /// + public int Code { get; set; } + /// + /// 消息 + /// + public string? Message { get; set; } + } +} diff --git a/VideoAnalysisCore/Common/Dto/ComboModel.cs b/VideoAnalysisCore/Common/Dto/ComboModel.cs new file mode 100644 index 0000000..91cca29 --- /dev/null +++ b/VideoAnalysisCore/Common/Dto/ComboModel.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VideoAnalysisCore.Common.Dto +{ + /// + /// 公共返回实体 + /// + public class ComboModel + { + public ComboModel(string t, object v) + { + Text = t; + Value = v; + } + public ComboModel() + { + + } + public object Value { get; set; } + public string Text { get; set; } + } +} diff --git a/VideoAnalysisCore/Common/Dto/PageResult.cs b/VideoAnalysisCore/Common/Dto/PageResult.cs new file mode 100644 index 0000000..b90ae5f --- /dev/null +++ b/VideoAnalysisCore/Common/Dto/PageResult.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; + +namespace VideoAnalysisCore.Common.Dto +{ + public class PageResult + { + /// + /// 数据 + /// + public List Data { get; set; } + /// + /// 总条数 + /// + public int Total { get; set; } + } +} diff --git a/VideoAnalysisCore/Common/OhException.cs b/VideoAnalysisCore/Common/OhException.cs new file mode 100644 index 0000000..0b8e324 --- /dev/null +++ b/VideoAnalysisCore/Common/OhException.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VideoAnalysisCore.Common +{ + /// + /// 异常抛出的拓展类 + /// + public class Oh + { + /// + /// 抛出 异常 + /// + /// + /// + /// + public static void Error(string message, int code = 500) + { + throw new OhException(message, code); + } + /// + /// 抛出 异常 + /// + /// + /// + /// + public static T Error(string message, int code = 500) + { + throw new OhException(message, code); + } + /// + /// 抛出 模型校验异常 + /// + /// + /// + /// + public static void ModelError(string message, int code = 400) + { + throw new OhException(message, code); + } + /// + /// 抛出 模型校验异常 + /// + /// + /// + /// + public static void ToeknError(string message, int code = 401) + { + throw new OhException(message, code); + } + } + public class OhException : Exception + { + /// + /// 错误码 + /// + public virtual int Code { get; } + public OhException(string message, int code = -1) : base(message) + { + Code = code; + } + + } +} diff --git a/VideoAnalysisCore/Controllers/LJZK_Controller.cs b/VideoAnalysisCore/Controllers/LJZK_Controller.cs index 812458b..d283e13 100644 --- a/VideoAnalysisCore/Controllers/LJZK_Controller.cs +++ b/VideoAnalysisCore/Controllers/LJZK_Controller.cs @@ -67,7 +67,7 @@ namespace VideoAnalysisCore.Controllers [HttpPost(Name = "NodePackage")] public async Task NodePackage(NodePackageReq[] reqArr) { - Console.WriteLine($"{DateTime.Now} ļ req=" + reqArr.ToJson()); + Console.WriteLine($"{DateTime.Now} ļ req=" + reqArr.Count()); if (reqArr is null || reqArr.Count() == 0) return BadRequest("ЧƵб"); var videos = new List(reqArr.Count()); @@ -77,7 +77,16 @@ namespace VideoAnalysisCore.Controllers //ϵͳɽѧ var subjectArr = new List { - SubjectEnum.ѧ + SubjectEnum., + SubjectEnum.ѧ, + SubjectEnum.Ӣ, + SubjectEnum., + SubjectEnum.ѧ, + SubjectEnum., + SubjectEnum., + SubjectEnum.ʷ, + SubjectEnum., + }; var courseTypeArr = new List { diff --git a/VideoAnalysisCore/Model/HttpLog.cs b/VideoAnalysisCore/Model/HttpLog.cs new file mode 100644 index 0000000..97a5b04 --- /dev/null +++ b/VideoAnalysisCore/Model/HttpLog.cs @@ -0,0 +1,79 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection.Metadata.Ecma335; +using System.Text; +using System.Threading.Tasks; +using UserCenter.Model; +using VideoAnalysisCore.Model.Interface; + +namespace VideoAnalysisCore.Model +{ + /// + /// 请求日志表 + /// + [SugarTable("httplog")] + public partial class HttpLog : EntityBaseId, IDB + { + /// + /// 创建时间 + /// + public DateTime CreateTime { get; set; } = DateTime.Now; + + /// + /// 路由 + /// + [SugarColumn(Length = 500)] + public string Url { get; set; } + /// + /// 请求方法类型 + /// + [SugarColumn(Length = 10)] + public string Method { get; set; } + + /// + /// 请求来自哪个ip + /// + [SugarColumn(IsNullable = true, Length = 30)] + public string IP { get; set; } + + /// + /// 请求参数 + /// + [SugarColumn(IsNullable = true, ColumnDataType = "longtext")] + public string? Request { get; set; } + /// + /// 请求返回参数 + /// + [SugarColumn(IsNullable = true, ColumnDataType = "longtext")] + public string? Response { get; set; } + /// + /// 响应状态码 + /// + public int ResponseCode { get; set; } + /// + /// 授权信息 + /// + [SugarColumn(IsNullable = true, Length = 500)] + public string? Authorization { get; set; } + /// + /// 异常完整信息 + /// + [SugarColumn(IsNullable = true, ColumnDataType = "text")] + public string Exception { get; set; } + /// + /// 异常信息 + /// + [SugarColumn(IsNullable = true, ColumnDataType = "text")] + public string? ExceptionMessage { get; set; } + /// + /// 管理员ID + /// + public long AdminId { get; set; } + /// + /// 总耗时(秒) + /// + public double TotalMilliseconds { get; set; } + } +}