feat: 增加公告栏并让用户自选学时判断

This commit is contained in:
Nixevol
2026-11-19 04:08:30 +08:00
parent 3fe6d4c111
commit 4d4fe224bc
20 changed files with 789 additions and 64 deletions
+35
View File
@@ -44,6 +44,13 @@ class SettingsBody(BaseModel):
hours_source: str = "api"
class NoticeBody(BaseModel):
title: str
body: str
link_url: str = ""
published_at: str
class PauseBody(BaseModel):
paused: bool
@@ -204,6 +211,34 @@ def put_users_study_settings(
)
@admin_router.get("/notices")
def get_notices(db: Session = Depends(get_db), _: str = Depends(require_admin)) -> list[dict]:
from admin.notices import list_notices
return list_notices(db)
@admin_router.post("/notices")
def post_notice(body: NoticeBody, db: Session = Depends(get_db), _: str = Depends(require_admin)) -> dict:
from admin.notices import create_notice
return create_notice(db, body.title, body.body, body.link_url, body.published_at)
@admin_router.put("/notices/{notice_id}")
def put_notice(notice_id: int, body: NoticeBody, db: Session = Depends(get_db), _: str = Depends(require_admin)) -> dict:
from admin.notices import update_notice
return update_notice(db, notice_id, body.title, body.body, body.link_url, body.published_at)
@admin_router.delete("/notices/{notice_id}")
def remove_notice(notice_id: int, db: Session = Depends(get_db), _: str = Depends(require_admin)) -> dict:
from admin.notices import delete_notice
return delete_notice(db, notice_id)
@admin_router.get("/users/{employee_id}/credentials")
def get_credentials(
employee_id: str, response: Response, db: Session = Depends(get_db), _: str = Depends(require_admin)