教程模块

This commit is contained in:
2025-03-03 22:10:45 +08:00
parent fd46f49c20
commit d3ffd27f00
14 changed files with 161 additions and 11 deletions

28
tutorial/schemas.py Normal file
View File

@@ -0,0 +1,28 @@
from ninja import Schema, ModelSchema
from typing import List, Optional
from .models import Tutorial
class TutorialSlim(Schema):
display: str
title: str
is_public: bool
class TutorialAll(ModelSchema):
class Meta:
model = Tutorial
fields = "__all__"
class TutorialReturn(Schema):
total: int
list: List[TutorialSlim]
first: Optional[TutorialAll]
class TutorialIn(Schema):
display: str
title: str
content: str
is_public: bool = False