fix: dashboard.py 顶层 import CoverSettings,解决运行时 500
This commit is contained in:
@@ -12,11 +12,12 @@ from datetime import datetime
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, UploadFile, File, Form, status
|
from fastapi import APIRouter, Depends, HTTPException, UploadFile, File, Form, status
|
||||||
from sqlmodel import Session
|
from sqlmodel import Session, select
|
||||||
|
|
||||||
from app.core.deps import get_current_user, require_role
|
from app.core.deps import get_current_user, require_role
|
||||||
from app.db.session import get_session
|
from app.db.session import get_session
|
||||||
from app.models.user import User, UserRole
|
from app.models.user import User, UserRole
|
||||||
|
from app.models.cover_settings import CoverSettings
|
||||||
|
|
||||||
router = APIRouter(prefix="/api/dashboard", tags=["仪表盘"])
|
router = APIRouter(prefix="/api/dashboard", tags=["仪表盘"])
|
||||||
|
|
||||||
@@ -41,8 +42,6 @@ def get_current_cover(
|
|||||||
current_user: User = Depends(get_current_user),
|
current_user: User = Depends(get_current_user),
|
||||||
):
|
):
|
||||||
"""查询当前题图设置(三角色均可读)。"""
|
"""查询当前题图设置(三角色均可读)。"""
|
||||||
from app.models.cover_settings import CoverSettings
|
|
||||||
|
|
||||||
row = session.exec(
|
row = session.exec(
|
||||||
select(CoverSettings).where(CoverSettings.key == "dashboard_cover")
|
select(CoverSettings).where(CoverSettings.key == "dashboard_cover")
|
||||||
).first()
|
).first()
|
||||||
@@ -95,9 +94,6 @@ def upload_cover(
|
|||||||
with open(filepath, "wb") as f:
|
with open(filepath, "wb") as f:
|
||||||
f.write(contents)
|
f.write(contents)
|
||||||
|
|
||||||
# 更新数据库
|
|
||||||
from app.models.cover_settings import CoverSettings
|
|
||||||
|
|
||||||
cover_path = f"{STATIC_COVERS_URL}/{filename}"
|
cover_path = f"{STATIC_COVERS_URL}/{filename}"
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user