Commit 4614cc5c authored by zhanglu's avatar zhanglu

🐛 fix: 帖子封面

parent b9ae2308
...@@ -6,5 +6,5 @@ class Tag(Schema): ...@@ -6,5 +6,5 @@ class Tag(Schema):
id: int = Field(None, description="标签ID") id: int = Field(None, description="标签ID")
name: str = Field(None, description="标签名") name: str = Field(None, description="标签名")
type: str = Field(None, description="标签类型") type: int = Field(None, description="标签类型")
gm_url: str = Field(None, description="跳转协议") gm_url: str = Field(None, description="跳转协议")
...@@ -85,8 +85,8 @@ class TractateFormat(BaseFormat): ...@@ -85,8 +85,8 @@ class TractateFormat(BaseFormat):
# 有视频且封面是短视频,逻辑不变 # 有视频且封面是短视频,逻辑不变
# 没有视频,封面是图片,替换图片第一张的image_url为封面图 # 没有视频,封面是图片,替换图片第一张的image_url为封面图
# 客户端卡片展示取值逻辑:ios有视频取video 没有视频取images; Android都取images # 客户端卡片展示取值逻辑:ios有视频取video 没有视频取images; Android都取images
cover_url = info.pop('cover_url', '') cover_url = info.get('cover_url', '')
cover_type = info.pop('cover_type', TRACTATE_COVER_TYPE.NO_COVER) cover_type = info.get('cover_type', TRACTATE_COVER_TYPE.NO_COVER)
if all([video, cover_type == TRACTATE_COVER_TYPE.IMAGE]): if all([video, cover_type == TRACTATE_COVER_TYPE.IMAGE]):
cover_url = Picture.get_aspectscale_path(cover_url) cover_url = Picture.get_aspectscale_path(cover_url)
...@@ -116,6 +116,11 @@ class TractateFormat(BaseFormat): ...@@ -116,6 +116,11 @@ class TractateFormat(BaseFormat):
tractate = TractateInfo(**tractate_data) tractate = TractateInfo(**tractate_data)
cover_url = info.get('cover_url', '')
cover_type = info.get('cover_type', TRACTATE_COVER_TYPE.NO_COVER)
if cover_type and cover_url:
tractate.set_cover = True
video, images = self.get_video_and_image(info) video, images = self.get_video_and_image(info)
if video: if video:
tractate.video = self.get_video( tractate.video = self.get_video(
......
...@@ -36,6 +36,7 @@ class TractateInfo(Schema): ...@@ -36,6 +36,7 @@ class TractateInfo(Schema):
user: User = Field(..., description="用户信息") user: User = Field(..., description="用户信息")
images: Optional[Image] = Field({}, description="图片") images: Optional[Image] = Field({}, description="图片")
video: Optional[Video] = Field({}, description="视频") video: Optional[Video] = Field({}, description="视频")
set_cover: bool = Field(False, description="是否设置封面")
class TractateList(Schema): class TractateList(Schema):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment