mirror of
https://gitee.com/qqtt-ah/ai-crm.git
synced 2026-11-25 08:29:20 +08:00
init
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
"""用户记忆 API。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
|
||||
from api.deps import current_actor, memory_service
|
||||
from api.response import ok
|
||||
from application.memory_service import MemoryService
|
||||
from domain.models import Actor
|
||||
|
||||
router = APIRouter(prefix="/memories", tags=["memories"])
|
||||
|
||||
|
||||
@router.get("")
|
||||
async def list_memories(
|
||||
actor: Actor = Depends(current_actor),
|
||||
svc: MemoryService = Depends(memory_service),
|
||||
):
|
||||
items = await svc.list_public(actor)
|
||||
return ok({"items": items})
|
||||
|
||||
|
||||
@router.delete("/{memory_id}")
|
||||
async def delete_memory(
|
||||
memory_id: str,
|
||||
actor: Actor = Depends(current_actor),
|
||||
svc: MemoryService = Depends(memory_service),
|
||||
):
|
||||
deleted = await svc.delete(actor, memory_id)
|
||||
if not deleted:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="记忆不存在")
|
||||
return ok({"ok": True})
|
||||
Reference in New Issue
Block a user