From 40129961a04854f9563b97642f8463334c9746ff Mon Sep 17 00:00:00 2001 From: Ching Date: Sun, 9 Feb 2025 18:16:30 +0800 Subject: [PATCH] =?UTF-8?q?feat(models):=20=E6=B7=BB=E5=8A=A0=E6=89=AB?= =?UTF-8?q?=E7=A0=81=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为了记录扫码操作,添加了一个新的方法add_log到ScanLog模型中。 --- app.py | 1 + models.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/app.py b/app.py index 1c4d6b2..89c605f 100644 --- a/app.py +++ b/app.py @@ -531,6 +531,7 @@ def add_to_stream(): stream_id = r.xadd(STREAM_KEY, data) if data['data'].isnumeric(): + models.ScanLog.add_log(data['data']) bark_push('扫码成功', '条形码 %s' % data['data']) else: bark_push('扫码成功', '二维码 %s' % data['data']) diff --git a/models.py b/models.py index 618a7af..82d3b6d 100644 --- a/models.py +++ b/models.py @@ -49,6 +49,10 @@ class ScanLog(BaseModel): 'scan_at': self.scan_at } + @classmethod + def add_log(cls, barcode): + # Add log to database + cls.create(barcode=barcode) # Create tables