fix(api): KB 首席架構師審查修復 (I1 tags filter + I2 type annotation)
- I1: Repository list_entries 實作 tags JSONB @> 篩選 (之前聲明未實作) - I2: ORM tags 型別從 list[dict[str, Any]] 修正為 list[str] 首席架構師審查: 87/100 C1 時區(UTC→Taipei) 為既有系統性問題,另開 task 統一遷移 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -494,11 +494,11 @@ class KnowledgeEntryRecord(Base):
|
||||
nullable=False,
|
||||
comment="分類樹節點 (基礎設施/應用層/AI系統/安全合規)",
|
||||
)
|
||||
tags: Mapped[list[dict[str, Any]]] = mapped_column(
|
||||
tags: Mapped[list[str]] = mapped_column(
|
||||
JSON,
|
||||
default=list,
|
||||
nullable=False,
|
||||
comment="標籤列表 (JSONB)",
|
||||
comment="標籤列表 (JSONB string array)",
|
||||
)
|
||||
|
||||
# Source & Status
|
||||
|
||||
@@ -115,6 +115,11 @@ class KnowledgeDBRepository:
|
||||
if status:
|
||||
query = query.where(KnowledgeEntryRecord.status == status)
|
||||
count_query = count_query.where(KnowledgeEntryRecord.status == status)
|
||||
if tags:
|
||||
for tag in tags:
|
||||
tag_filter = KnowledgeEntryRecord.tags.op('@>')(f'["{tag}"]')
|
||||
query = query.where(tag_filter)
|
||||
count_query = count_query.where(tag_filter)
|
||||
if q:
|
||||
like_q = f"%{q}%"
|
||||
filter_cond = or_(
|
||||
|
||||
Reference in New Issue
Block a user