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:
Pine
2026-08-27 15:42:39 +08:00
parent a60f0ed180
commit 89bd7e8390
6 changed files with 100 additions and 6 deletions
+45
View File
@@ -1079,3 +1079,48 @@ async def carrier_company_compute(cid: str, body: CompanyComputeBody, user: dict
logging.getLogger(__name__).warning("企业配额发放失败 %s: %s", m.get("username"), exc)
return {"ok": True, "company": updated, "quota_add": body.quota_add}
# ==================== 园区端:发布资讯 + 大屏内容 ====================
class ParkContentBody(BaseModel):
type: str = "news"
title: str
summary: str = ""
body: str = ""
cover: str = ""
video: str = ""
video_cover: str = ""
link: str = ""
card_mode: str = "small" # 园区默认小图;运营端可改大/小图
@router.post("/api/content", summary="园区端发布资讯(发布人=园区名,默认不公开)")
async def carrier_publish_content(
body: ParkContentBody,
request: Request,
db=Depends(_carrier_db),
user: dict = Depends(_carrier_user),
):
t = await _my_park(user)
item = await db.content.create({
"type": body.type, "title": body.title, "summary": body.summary, "body": body.body,
"cover": body.cover, "video": body.video, "video_cover": body.video_cover, "link": body.link,
"publisher_name": t["name"], "publisher_avatar": "", # 发布人强制=园区名,不可改
"source": "carrier", "tenant_id": t["id"],
"card_mode": body.card_mode or "small",
"is_public": False, # 默认不公开:仅本园区大屏;由运营端切公开
"status": "published",
})
await write_audit(db, action="content.publish", resource="content", resource_id=item["id"],
detail=f"carrier {item['title']}", user=user, request=request)
return {"ok": True, "content": item}
@router.get("/api/content", summary="园区资讯列表(本园区,含未公开,供大屏)")
async def carrier_content_list(
db=Depends(_carrier_db),
user: dict = Depends(_carrier_user),
):
t = await _my_park(user)
return {"items": await db.content.list(tenant_id=t["id"])}