feat(content): 发布体系 大/小图 + 公开 + 园区端发布
- 迁移0018:content_items 加 card_mode/is_public/source/tenant_id
- ContentRepository:_to_dict/create/update 含新字段;list 加 public_only/tenant_id 过滤
- /opc/content 仅 published+公开;/opc/content/{id} 非公开→404
- 园区端 POST /park/api/content:发布人强制=园区名、source=carrier、tenant=本园、is_public 默认false(仅大屏)、card_mode默认small
- 园区端 GET /park/api/content:本园区内容(含未公开)供大屏
- schemas 补 card_mode/is_public
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -92,8 +92,8 @@ async def opc_content(
|
||||
type: str = "news",
|
||||
db: Database = Depends(get_db),
|
||||
):
|
||||
"""C 端资讯:type ∈ policy(政策)/news(资讯)/skill(技能)/dynamic(动态),仅 published。公开浏览。"""
|
||||
return {"items": await db.content.list(ctype=type, status="published")}
|
||||
"""C 端资讯:type ∈ policy/news/skill/dynamic,仅 published + 公开(is_public)。公开浏览。"""
|
||||
return {"items": await db.content.list(ctype=type, status="published", public_only=True)}
|
||||
|
||||
|
||||
@router.get("/content/{content_id}", summary="资讯详情")
|
||||
@@ -102,7 +102,7 @@ async def opc_content_detail(
|
||||
db: Database = Depends(get_db),
|
||||
):
|
||||
item = await db.content.get(content_id)
|
||||
if item is None or item.get("status") != "published":
|
||||
if item is None or item.get("status") != "published" or not item.get("is_public"):
|
||||
raise HTTPException(status_code=404, detail="内容不存在")
|
||||
# 阅读数自增(每次详情浏览 +1)
|
||||
if item.get("status") == "published":
|
||||
|
||||
@@ -93,6 +93,8 @@ class ContentCreateRequest(BaseModel):
|
||||
link: str = "" # 外链
|
||||
publisher_name: str = "" # 发布人昵称(空则用操作者)
|
||||
publisher_avatar: str = "" # 发布人头像
|
||||
card_mode: str = "big" # big 大图 | small 小图(运营端设)
|
||||
is_public: bool = True # 是否公开
|
||||
status: str = "draft"
|
||||
|
||||
|
||||
@@ -113,6 +115,10 @@ class ContentUpdateRequest(BaseModel):
|
||||
link: str | None = None
|
||||
publisher_name: str | None = None
|
||||
publisher_avatar: str | None = None
|
||||
card_mode: str | None = None
|
||||
is_public: bool | None = None
|
||||
source: str | None = None
|
||||
tenant_id: str | None = None
|
||||
status: str | None = None
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user