4 Commits

Author SHA1 Message Date
liufumingren
18f258014f perf(backend): 扫码记录列表补覆盖索引,count(*) 不再逐行回表
/api/web/records 是 findAndCountAll,列表本身走 idx_scan_time 只要 0.5ms,
慢的是后面那条 count(id):MySQL 只能选 (subject_id, barcode),索引里没有
scanner_id,于是按主键逐行回表判断 —— 线上 16.5 万条时 Rows_examined ≈ 33 万,
慢查询日志里 3.2s~9.9s(冷缓存时走磁盘)。

补 (subject_id, scanner_id, scan_time) 后 count 变成纯索引扫描(Using index),
实测 0.45s(热)/9.9s(冷) → 0.09s。

- 新增迁移 20261116200000-add-scan-record-list-index.js(幂等,已在生产执行)
- sql/schema.sql 基线同步该索引
- README 补索引用途与实测数字

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-17 01:20:26 +08:00
liufumingren
08d9ea103b chore(微信): 移除自建微信授权表 wechat_oauth / wechat_mp_accounts
微信侧接入已统一到登录网关,自建的两套都下线:

- 删除表:wechat_oauth(自建公众号网页授权 + 运维手工维护的绑定关系)、
  wechat_mp_accounts(小程序 code2Session 一键登录);迁移 20261029100000(up 删表、down 按原结构重建)
- 删除代码:service/{wechat,wechat_mp}.js、controller/web/wechat_mp.js、model/{wechat_oauth,wechat_mp_account}.js、
  service/user.js#findByOpenid、user 模型的 hasMany WechatOauth、公众号 OAuth 回调与 /api/web/auth/wechat/*
- 删除环境变量:WECHAT_APPID/SECRET/REDIRECT_URI/API_BASE、WX_MP_*(config.wechat 只剩设备扫码登录用到的串码/二维码参数)
- 小程序:去掉「微信一键登录」tab,只留账号密码登录(删 utils/wechat.ts 与 wechatLogin 调用)
- sql/schema.sql 同步去掉 wechat_oauth 建表

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-29 17:20:28 +08:00
liufumingren
77661b91b1 feat(backend): 引入 sequelize 迁移体系与数据库脚本 2026-10-19 22:04:01 +08:00
liufumingren
bd2363bf00 chore: 初始化仓库(backend / frontend / extension 三块)
- backend/:Egg 3 纯 JSON 接口服务(MySQL 8 + Redis),全部走 header 令牌鉴权;
  已彻底去掉服务端渲染(删除 page 控制器 / app/view / nunjucks / session / CSRF),
  开发时把页面请求反代到前端 dev server,生产托管 frontend/dist(SPA 回退)。
  单测 91 个通过(不需要本机数据库)。
- frontend/:Vite + Vue3 + TypeScript 的 SPA(登录 / 注册 / 找回密码 / 扫码登录与确认 /
  首页统计 / 设备管理 / 扫码记录 / 个人中心 / 测试页),vue-tsc 类型检查与构建通过。
- extension/:MV3 浏览器扩展(零构建),注入第三方 WMS 页面识别运单号并打开溯源页。
- 忽略规则统一放根 .gitignore:node_modules、dist、logs / logs-*、run、typings、
  .env*、config.local.js(含本机数据库与 Redis 密码,绝不入库)。
2026-10-17 08:50:32 +08:00