mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-03-20 00:16:37 +08:00
feat: Token 支持请求日志开关并记录 OpenAPI 请求日志
新增 Token 的 IsEnableLog 字段,贯穿领域、应用与 DTO;在 OpenApiService 中根据 Token 配置异步记录请求日志,包含请求体、模型与接口类型,用于后续审计与分析。
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using Volo.Abp.Domain.Services;
|
||||
using Yi.Framework.AiHub.Domain.Entities.OpenApi;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Enums;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.AiHub.Domain.Managers;
|
||||
|
||||
public class MessageLogManager : DomainService
|
||||
{
|
||||
private readonly ISqlSugarRepository<MessageLogAggregateRoot> _repository;
|
||||
|
||||
public MessageLogManager(ISqlSugarRepository<MessageLogAggregateRoot> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建消息日志
|
||||
/// </summary>
|
||||
public async Task CreateAsync(string requestBody, string apiKey, string apiKeyName, string modelId, ModelApiTypeEnum apiType)
|
||||
{
|
||||
var entity = new MessageLogAggregateRoot
|
||||
{
|
||||
RequestBody = requestBody,
|
||||
ApiKey = apiKey,
|
||||
ApiKeyName = apiKeyName,
|
||||
ModelId = modelId,
|
||||
ApiType = apiType,
|
||||
ApiTypeName = apiType.ToString(),
|
||||
CreationTime = DateTime.Now
|
||||
};
|
||||
await _repository.InsertAsync(entity);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user