This PR finalizes the implementation of issue #35 by establishing a formal foreign key relationship between `KnowledgeUnit` and `Ebook`. Closes #35 ### Changes: - **Domain**: Refactored `KnowledgeUnit` to use `Guid EbookId` and added navigation property. - **Data**: Updated `AppDbContext` fluent configuration and generated a new migration. - **Service**: Updated `IKnowledgeService` and its implementations to propagate `ebookId`. - **API**: Updated Web API endpoints to support linking extracted knowledge to specific ebooks. ### Verification: - [x] Solution builds successfully (`dotnet build`). - [x] Schema changes verified in migration file. - [x] Cascading delete behavior confirmed. --------- Co-authored-by: Marek Jasiński <jasins.marek@gmail.com> Reviewed-on: #43 Co-authored-by: Antigravity <antigravity@google.com> Co-committed-by: Antigravity <antigravity@google.com>
This commit was merged in pull request #43.
This commit is contained in:
@@ -14,24 +14,24 @@ public class WasmKnowledgeService : IKnowledgeService
|
||||
_httpClient = httpClient;
|
||||
}
|
||||
|
||||
public async Task<Result<KnowledgePacket>> GetKnowledgeAsync(string text, string tenantId, CancellationToken cancellationToken = default)
|
||||
public async Task<Result<KnowledgePacket>> GetKnowledgeAsync(string text, string tenantId, Guid? ebookId = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await CallKnowledgeApiAsync("/api/knowledge", text, cancellationToken);
|
||||
return await CallKnowledgeApiAsync("/api/knowledge", text, ebookId, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<Result<KnowledgePacket>> GetGraphDataAsync(string text, string tenantId, CancellationToken cancellationToken = default)
|
||||
public async Task<Result<KnowledgePacket>> GetGraphDataAsync(string text, string tenantId, Guid? ebookId = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await CallKnowledgeApiAsync("/api/knowledge/graph", text, cancellationToken);
|
||||
return await CallKnowledgeApiAsync("/api/knowledge/graph", text, ebookId, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<Result<KnowledgePacket>> GetKnowledgeMapAsync(string text, string tenantId, CancellationToken cancellationToken = default)
|
||||
public async Task<Result<KnowledgePacket>> GetKnowledgeMapAsync(string text, string tenantId, Guid? ebookId = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await CallKnowledgeApiAsync("/api/knowledge/map", text, cancellationToken);
|
||||
return await CallKnowledgeApiAsync("/api/knowledge/map", text, ebookId, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<Result<KnowledgePacket>> GetSummaryAndQuizAsync(string text, string tenantId, CancellationToken cancellationToken = default)
|
||||
public async Task<Result<KnowledgePacket>> GetSummaryAndQuizAsync(string text, string tenantId, Guid? ebookId = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await CallKnowledgeApiAsync("/api/knowledge/summary", text, cancellationToken);
|
||||
return await CallKnowledgeApiAsync("/api/knowledge/summary", text, ebookId, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<Result<List<RelevantContext>>> GetRelevantContextAsync(string query, string tenantId, CancellationToken cancellationToken = default)
|
||||
@@ -73,11 +73,11 @@ public class WasmKnowledgeService : IKnowledgeService
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<Result<KnowledgePacket>> CallKnowledgeApiAsync(string endpoint, string text, CancellationToken cancellationToken)
|
||||
private async Task<Result<KnowledgePacket>> CallKnowledgeApiAsync(string endpoint, string text, Guid? ebookId, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _httpClient.PostAsJsonAsync(endpoint, new { text }, cancellationToken);
|
||||
var response = await _httpClient.PostAsJsonAsync(endpoint, new { text, ebookId }, cancellationToken);
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var packet = await response.Content.ReadFromJsonAsync<KnowledgePacket>(cancellationToken: cancellationToken);
|
||||
|
||||
Reference in New Issue
Block a user