feat(models): 添加扫码日志记录功能
All checks were successful
continuous-integration/drone/push Build is passing

为了记录扫码操作,添加了一个新的方法add_log到ScanLog模型中。
This commit is contained in:
Ching 2025-02-09 18:16:30 +08:00
parent d8887eaf5b
commit 40129961a0
2 changed files with 5 additions and 0 deletions

1
app.py
View File

@ -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'])

View File

@ -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