益选便利店查询商品程序
Go to file
2025-12-07 15:58:35 +08:00
.trae/documents 一个手机快速搜索商品的网页 2025-12-07 15:09:21 +08:00
.vercel 修复手机唤醒相机 2025-12-07 15:58:35 +08:00
app 一个手机快速搜索商品的网页 2025-12-07 15:09:21 +08:00
data 一个手机快速搜索商品的网页 2025-12-07 15:09:21 +08:00
static 修复手机唤醒相机 2025-12-07 15:58:35 +08:00
.vercelignore 修复手机唤醒相机 2025-12-07 15:58:35 +08:00
docker-compose.yml 一个手机快速搜索商品的网页 2025-12-07 15:09:21 +08:00
Dockerfile 一个手机快速搜索商品的网页 2025-12-07 15:09:21 +08:00
README.md 一个手机快速搜索商品的网页 2025-12-07 15:09:21 +08:00
requirements.txt 一个手机快速搜索商品的网页 2025-12-07 15:09:21 +08:00
vercel.json 修复手机唤醒相机 2025-12-07 15:58:35 +08:00
商品资料.xlsx 一个手机快速搜索商品的网页 2025-12-07 15:09:21 +08:00
部署文档.md 一个手机快速搜索商品的网页 2025-12-07 15:09:21 +08:00

商品查询系统

功能

  • 导入Excel为数据库以条码为主键Upsert
  • 查询商品:条码精确查、名称模糊查
  • 响应式前端,手机/电脑可用

运行

  1. 安装依赖:python -m pip install fastapi "uvicorn[standard]" pandas openpyxl python-multipart
  2. 启动服务:python -m uvicorn app.main:app --host 0.0.0.0 --port 57777(或设置环境变量 PORT=57777
  3. 打开页面:http://localhost:57777/

导入

  • 页面“导入Excel”选择文件并提交
  • 后端解析Sheet1并映射列:名称(必填)进货价(必填)销售价(必填)条码、可选分类(必填)

接口

  • POST /import 表单上传file
  • GET /products/{barcode} 返回名称、进价、卖价、条码
  • GET /products?q=关键词&limit=20 名称模糊查询
  • GET /health 健康检查

数据库

  • SQLite 文件:data/products.db
  • 表:products(barcode primary key, name, purchase_price, sale_price, category, created_at, source_file)
  • 索引:idx_products_name(name)

注意

  • Excel中文列名需一致
  • 非数字价格会被跳过或置为空
  • 条码为空的行跳过

Docker推荐部署

  • 构建并启动:docker compose up --build -d
  • 端口:宿主机映射 57777:57777
  • 数据与静态资源挂载:
    • ./data:/app/dataSQLite 持久化)
    • ./static:/app/static:ro(前端文件,无需重建镜像即可更新)