feat(blog): add admin taxonomy APIs
This commit is contained in:
@@ -22,6 +22,21 @@ class CategorySchema(ModelSchema):
|
||||
return obj.parent_id
|
||||
|
||||
|
||||
class AdminCategorySchema(CategorySchema):
|
||||
post_count: int = 0
|
||||
|
||||
@staticmethod
|
||||
def resolve_post_count(obj):
|
||||
return getattr(obj, "post_count", None) or obj.posts.filter(is_deleted=False).count()
|
||||
|
||||
|
||||
class CategoryWriteSchema(Schema):
|
||||
name: str
|
||||
slug: Optional[str] = None
|
||||
description: Optional[str] = ""
|
||||
parent_id: Optional[int] = None
|
||||
|
||||
|
||||
class CategoryPathSchema(Schema):
|
||||
id: int
|
||||
name: str
|
||||
@@ -45,6 +60,19 @@ class TagSchema(ModelSchema):
|
||||
model_fields = ["id", "name", "slug", "created_at"]
|
||||
|
||||
|
||||
class AdminTagSchema(TagSchema):
|
||||
post_count: int = 0
|
||||
|
||||
@staticmethod
|
||||
def resolve_post_count(obj):
|
||||
return getattr(obj, "post_count", None) or obj.posts.filter(is_deleted=False).count()
|
||||
|
||||
|
||||
class TagWriteSchema(Schema):
|
||||
name: str
|
||||
slug: Optional[str] = None
|
||||
|
||||
|
||||
class TagFilterSchema(Schema):
|
||||
id: int
|
||||
name: str
|
||||
|
||||
Reference in New Issue
Block a user