diff --git a/__pycache__/dependencies.cpython-310.pyc b/__pycache__/dependencies.cpython-310.pyc index a78ebeb..b6e9a00 100644 Binary files a/__pycache__/dependencies.cpython-310.pyc and b/__pycache__/dependencies.cpython-310.pyc differ diff --git a/__pycache__/main.cpython-310.pyc b/__pycache__/main.cpython-310.pyc index 92730ad..f5f6e95 100644 Binary files a/__pycache__/main.cpython-310.pyc and b/__pycache__/main.cpython-310.pyc differ diff --git a/internal/__pycache__/__init__.cpython-310.pyc b/internal/__pycache__/__init__.cpython-310.pyc index 394be32..1e80e35 100644 Binary files a/internal/__pycache__/__init__.cpython-310.pyc and b/internal/__pycache__/__init__.cpython-310.pyc differ diff --git a/internal/__pycache__/database.cpython-310.pyc b/internal/__pycache__/database.cpython-310.pyc index c61ba96..341a062 100644 Binary files a/internal/__pycache__/database.cpython-310.pyc and b/internal/__pycache__/database.cpython-310.pyc differ diff --git a/internal/__pycache__/models.cpython-310.pyc b/internal/__pycache__/models.cpython-310.pyc index c80ab82..f91df9a 100644 Binary files a/internal/__pycache__/models.cpython-310.pyc and b/internal/__pycache__/models.cpython-310.pyc differ diff --git a/internal/models.py b/internal/models.py index 4626aba..564d59a 100644 --- a/internal/models.py +++ b/internal/models.py @@ -33,37 +33,21 @@ class User(BaseModel): class UserInDB(User): hashed_password: str = None -class BlogList(BaseModel): - blogname:Annotated[str,Field( - title="博客名", - examples=['blogname'], - pattern=r'^.{2,50}$', - description="允许2-50个字符" - )] - blogtype:Annotated[str,Field( - title="博客类型", - default=None, - description="博客类型允许为空" - )] - viewsnum:Annotated[int,Field( - title="访问量", +class TypeList(BaseModel): + blogid:Annotated[int,Field( + title="博客id", default=None, - description="访问量可以为空" + description="博客id可以为空" )] - addtime:Annotated[datetime,Field( - title="发布时间", - description="数据库中提供了默认值" + typename:Annotated[str,Field( + title="类型名称", + examples=['typename'], + pattern=r'^.{2,50}$', + description="允许2-50个字符" )] descr:Annotated[str,Field( title="备注", default=None, - description="备注允许为空" + description="博客类型允许为空" )] - -class BlogAdd(BlogList): - blogcontent:Annotated[str,Field( - title="博客内容", - examples=['blogcontent'], - pattern=r'^.{2,}$', - description="不能为空,允许2个或更多字符" - )] \ No newline at end of file + \ No newline at end of file diff --git a/main.py b/main.py index 37a1e9e..6fac410 100644 --- a/main.py +++ b/main.py @@ -5,7 +5,6 @@ from dependencies import * from internal.models import Token from fastapi.middleware.cors import CORSMiddleware from routers import usermanage,typemanage -from internal.models import BlogList app=FastAPI() app.include_router(usermanage.router) app.include_router(typemanage.router) diff --git a/routers/__pycache__/__init__.cpython-310.pyc b/routers/__pycache__/__init__.cpython-310.pyc index 8cb2262..0001bfb 100644 Binary files a/routers/__pycache__/__init__.cpython-310.pyc and b/routers/__pycache__/__init__.cpython-310.pyc differ diff --git a/routers/__pycache__/typemanage.cpython-310.pyc b/routers/__pycache__/typemanage.cpython-310.pyc index 1f6b860..a0b8d40 100644 Binary files a/routers/__pycache__/typemanage.cpython-310.pyc and b/routers/__pycache__/typemanage.cpython-310.pyc differ diff --git a/routers/__pycache__/usermanage.cpython-310.pyc b/routers/__pycache__/usermanage.cpython-310.pyc index 11b4276..18d263c 100644 Binary files a/routers/__pycache__/usermanage.cpython-310.pyc and b/routers/__pycache__/usermanage.cpython-310.pyc differ diff --git a/routers/typemanage.py b/routers/typemanage.py index 692672d..92d554f 100644 --- a/routers/typemanage.py +++ b/routers/typemanage.py @@ -5,8 +5,8 @@ router=APIRouter( tags=["分类管理"] ) -@router.get("/typelist",response_model=list[BlogList]) +@router.get("/typelist",response_model=list[TypeList]) def read_type_all(_:User=Depends(get_current_active_user)): - select_query="SELECT blogname,blogtype,viewsnum,addtime,descr FROM blogs;" + select_query="SELECT blogid,typename,descr FROM types;" type_all=execute_query(select_query,fetchall=True) return type_all