feat: 实现后端核心业务逻辑 (Auth鉴权、二维码服务、看板与产品端点)

This commit is contained in:
2026-08-04 17:09:47 +08:00
parent 2b967afbf6
commit b22de514a1
11 changed files with 407 additions and 0 deletions

View File

@ -0,0 +1,34 @@
"""二维码生成服务 — 参考 MOM 系统 label_service.py 的 QR 生成逻辑"""
import io
import qrcode
from qrcode.image.pil import PilImage
def generate_qrcode_png(content: str, size_px: int = 300) -> io.BytesIO:
"""
生成二维码 PNG 图片,返回 BytesIO 流。
参数:
content: 二维码内容(如 16 位序列号)
size_px: 输出图片尺寸(像素),默认 300×300
返回:
io.BytesIO: PNG 格式的图片字节流
"""
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_M,
box_size=10,
border=2,
)
qr.add_data(content)
qr.make(fit=True)
img: PilImage = qr.make_image(fill_color="black", back_color="white")
img = img.convert("RGB")
img = img.resize((size_px, size_px))
buf = io.BytesIO()
img.save(buf, format="PNG")
buf.seek(0)
return buf