软删除

This commit is contained in:
Ubuntu
2025-12-25 11:23:23 +00:00
parent 658548b61c
commit 7da2295368
4 changed files with 127 additions and 19 deletions
+22 -2
View File
@@ -89,15 +89,25 @@ async def get_admin_dashboard_stats(
@router.get("/channels", response_model=SuccessResponse)
async def list_channels(
include_inactive: bool = Query(False, description="是否包含已删除(inactive)的渠道"),
principal: dict = Depends(require_auth),
db: AsyncSession = Depends(get_db)
):
"""
获取所有渠道列表
Args:
include_inactive: 是否包含已删除的渠道,默认False只返回活跃的
"""
_verify_admin_permission(principal)
result = await db.execute(select(Channel))
# 默认只返回活跃的渠道,除非明确请求包含已删除的
if include_inactive:
result = await db.execute(select(Channel))
else:
result = await db.execute(
select(Channel).where(Channel.status != "inactive")
)
channels = result.scalars().all()
data = [
@@ -511,15 +521,25 @@ async def list_model_providers(
@router.get("/resources/agents", response_model=SuccessResponse)
async def list_all_agents(
include_inactive: bool = Query(False, description="是否包含已删除(inactive)的Agent"),
principal: dict = Depends(require_auth),
db: AsyncSession = Depends(get_db)
):
"""
获取所有Agent资源
Args:
include_inactive: 是否包含已删除的Agent,默认False只返回活跃的
"""
_verify_admin_permission(principal)
result = await db.execute(select(Agent))
# 默认只返回活跃的Agent,除非明确请求包含已删除的
if include_inactive:
result = await db.execute(select(Agent))
else:
result = await db.execute(
select(Agent).where(Agent.status != "inactive")
)
agents = result.scalars().all()
data = [