pump / backend /app /branding_api.py
Claude
Claude Opus 4.8
品牌/首页可配置 + 登录封面页
1199a79 unverified
Raw History Blame Contribute Delete
858 Bytes
"""品牌/首页 API:公开读(首页用) + 管理写 + 简易登录校验。"""
from __future__ import annotations
from fastapi import APIRouter
from pydantic import BaseModel
from .branding import BrandingStore, BrandingUpdate
router = APIRouter(prefix="/api/branding", tags=["品牌/首页"])
store = BrandingStore()
class LoginRequest(BaseModel):
password: str = ""
@router.get("")
def get_branding():
"""公开只读:首页/大屏读取水厂名、公司、联系方式等(不含登录口令)。"""
return store.public()
@router.put("")
def put_branding(update: BrandingUpdate):
return store.save(update).model_dump()
@router.post("/login")
def login(req: LoginRequest):
"""简易登录校验(可选):未设口令则始终放行;设了则比对。"""
ok = store.verify(req.password)
return {"success": ok}