feat: 更新 EmojiResponse 模型,添加 format 和 usage_count 字段
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
from pathlib import Path
|
||||||
from typing import Annotated, List, Optional
|
from typing import Annotated, List, Optional
|
||||||
|
|
||||||
from fastapi import File, Form, UploadFile
|
from fastapi import File, Form, UploadFile
|
||||||
@@ -19,9 +20,11 @@ class EmojiResponse(BaseModel):
|
|||||||
|
|
||||||
id: int
|
id: int
|
||||||
full_path: str
|
full_path: str
|
||||||
|
format: str
|
||||||
emoji_hash: str
|
emoji_hash: str
|
||||||
description: str
|
description: str
|
||||||
query_count: int
|
query_count: int
|
||||||
|
usage_count: int
|
||||||
is_registered: bool
|
is_registered: bool
|
||||||
is_banned: bool
|
is_banned: bool
|
||||||
emotion: Optional[str]
|
emotion: Optional[str]
|
||||||
@@ -145,13 +148,16 @@ def emoji_to_response(image: Images) -> EmojiResponse:
|
|||||||
if item not in deduped_emotions:
|
if item not in deduped_emotions:
|
||||||
deduped_emotions.append(item)
|
deduped_emotions.append(item)
|
||||||
emotion = ",".join(deduped_emotions) if deduped_emotions else None
|
emotion = ",".join(deduped_emotions) if deduped_emotions else None
|
||||||
|
image_format = Path(image.full_path).suffix.lower().lstrip(".") or "unknown"
|
||||||
|
|
||||||
return EmojiResponse(
|
return EmojiResponse(
|
||||||
id=image.id if image.id is not None else 0,
|
id=image.id if image.id is not None else 0,
|
||||||
full_path=image.full_path,
|
full_path=image.full_path,
|
||||||
|
format=image_format,
|
||||||
emoji_hash=image.image_hash,
|
emoji_hash=image.image_hash,
|
||||||
description=image.description,
|
description=image.description,
|
||||||
query_count=image.query_count,
|
query_count=image.query_count,
|
||||||
|
usage_count=image.query_count,
|
||||||
is_registered=image.is_registered,
|
is_registered=image.is_registered,
|
||||||
is_banned=image.is_banned,
|
is_banned=image.is_banned,
|
||||||
emotion=emotion,
|
emotion=emotion,
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ class EmojiResponse(BaseModel):
|
|||||||
|
|
||||||
id: int
|
id: int
|
||||||
full_path: str
|
full_path: str
|
||||||
|
format: str
|
||||||
emoji_hash: str
|
emoji_hash: str
|
||||||
description: str
|
description: str
|
||||||
query_count: int
|
query_count: int
|
||||||
|
usage_count: int
|
||||||
is_registered: bool
|
is_registered: bool
|
||||||
is_banned: bool
|
is_banned: bool
|
||||||
emotion: Optional[str]
|
emotion: Optional[str]
|
||||||
|
|||||||
Reference in New Issue
Block a user