feat: implement multi-tenancy support across knowledge services and normalize TenantId to string type.
This commit is contained in:
@@ -3,5 +3,6 @@ using NexusReader.Application.Abstractions.Messaging;
|
||||
namespace NexusReader.Application.Queries.Graph;
|
||||
|
||||
/// <param name="Text">Chapter or page content to extract the graph from.</param>
|
||||
public record GetKnowledgeGraphQuery(string Text) : IQuery<GraphDataDto>;
|
||||
/// <param name="TenantId">Tenant scope for knowledge extraction and caching.</param>
|
||||
public record GetKnowledgeGraphQuery(string Text, string TenantId) : IQuery<GraphDataDto>;
|
||||
|
||||
|
||||
@@ -18,20 +18,13 @@ internal sealed class GetKnowledgeGraphQueryHandler : IQueryHandler<GetKnowledge
|
||||
if (string.IsNullOrWhiteSpace(request.Text))
|
||||
return Result.Ok(new GraphDataDto());
|
||||
|
||||
var result = await _knowledgeService.GetGraphDataAsync(request.Text, cancellationToken);
|
||||
var result = await _knowledgeService.GetGraphDataAsync(request.Text, request.TenantId, cancellationToken);
|
||||
|
||||
if (result.IsFailed)
|
||||
return Result.Fail<GraphDataDto>(result.Errors);
|
||||
|
||||
var graph = result.Value.Graph;
|
||||
|
||||
if (graph is null)
|
||||
return Result.Ok(new GraphDataDto());
|
||||
|
||||
if (graph is null)
|
||||
return Result.Ok(new GraphDataDto());
|
||||
|
||||
return Result.Ok(graph);
|
||||
return graph is null ? Result.Ok(new GraphDataDto()) : Result.Ok(graph);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user