"""品牌/首页 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}