Files
cmroubao/docs/tasks/T-228.md
T

90 lines
4.1 KiB
Markdown
Raw Normal View History

2026-07-29 09:09:40 +08:00
---
id: T-228
title: 移除 Python ERP Connector 并完成 Go 切换
phase: 2
deps:
- T-227
2026-07-29 10:14:30 +08:00
status: DONE
2026-07-29 09:09:40 +08:00
created: 2026-07-29
context_ref: d62a4af
work_branch: null
write_paths:
- docs/tasks/T-228.md
- docs/00-ai-start-here.md
- docs/03-tech-stack.md
- docs/04-architecture.md
- docs/05-coding-rules.md
- docs/06-tasks.md
- docs/api.md
- docs/current-state.md
- docs/integrations/**
2026-07-29 10:14:30 +08:00
- .gitignore
2026-07-29 09:09:40 +08:00
- README.md
- backend-api/README.md
- backend-api/cmd/api/**
- backend-api/internal/config/**
- backend-api/internal/platform/erpconnector/**
2026-07-29 10:14:30 +08:00
- backend-api/internal/repository/sqlite/**
2026-07-29 09:09:40 +08:00
- erp-connector/**
- scripts/start-erp-connector.bat
- start-backend.bat
- init.ps1
---
## 问题 / 背景
Go 直连 source 经 T-227 验证后,保留 Python Connector、8091 loopback 端口、服务密钥、
启动脚本和双份协议实现只会造成漂移与错误配置。需要受控删除旧路径,并把启动、文档和
验证统一为单一 Go 后端。
## 关联需求与交互
- 功能:F-011、F-012。
- 用户故事:US-011、US-012。
- 交互:IX-012、IX-013;页面入口保持不变。
- 架构:运行时只保留 Go API 进程直接访问 ERP;外部 ERP 仍是受控边界。
## 方案
1. 删除仓库内 `erp-connector/`、Connector 启动脚本、HTTP client、`CMROUBAO_ERP_CONNECTOR_*`
配置和共享 API Key 文档。
2. 保留外部原始研究脚本 `D:\chengma\shunyunbaoerp\shunyunbaoerp_single.py` 不受仓库
删除影响;它不是运行时依赖。
3. 统一启动脚本为 Go 后端环境校验和启动;ERP 未配置或会话失效时 Admin 提供可修复
会话状态,而不是在输入单号后才暴露 Connector 配置错误。
4. 删除前运行全仓引用扫描、Go 测试/race/vet、根验证和隔离 SQLite/Gin smoke;保留
脱敏 fixture,不保留真实 Cookie、订单号或 HAR。
## 验收要点
2026-07-29 10:14:30 +08:00
- [x] 仓库不再包含 Python Connector、8091 监听、Connector API Key 或其启动命令。
- [x] Go 后端在 ERP 凭证缺失、未登录和伪 ERP 成功路径下均返回稳定、可操作状态。
- [x] `rg` 证明已跟踪文件无 Connector 运行时引用、真实凭证、Cookie、JWT 或订单样本。
- [x] `go test ./...`、`go test -race ./...`、`go vet ./...` 和根验证通过。
- [x] 文档只说明单 Go 后端、人工验证码和外部 ERP 风险;真实线上 smoke 结果明确记录。
2026-07-29 09:09:40 +08:00
## 边界
- 不删除工作区外的原始 Python 研究脚本或用户私有 HAR。
- 不自动登录、自动 OCR 或无人值守定时同步。
- 不改变 Admin/采购任务的授权、下单和付款边界。
## 执行记录
- 2026-07-29:由 T-227 依赖创建,等待 Go 查询链路验收后进行删除。
2026-07-29 10:14:30 +08:00
- 2026-07-29:开始实施;T-227 已由 `a822edd` 完成。确认外部原始研究脚本不在本次
删除范围内,清理仅作用于仓库内旧 Connector、端口、共享服务密钥及其文档。
- 2026-07-29:删除 `erp-connector/`、`internal/platform/erpconnector/` 和
`scripts/start-erp-connector.bat`,同时移除 `CMROUBAO_ERP_CONNECTOR_*`、8091 默认值、
共享 API Key 兼容和旧错误码。外部
`D:\chengma\shunyunbaoerp\shunyunbaoerp_single.py` 未读取、未修改、未删除。
- 2026-07-29:`start-backend.bat` 只启动 Go 后端;ERP 未配置时 `/erp` 给出可修复状态,
同步 run 使用 `ERP_NOT_CONFIGURED` 或 `ERP_SESSION_REQUIRED`,不再依赖第二进程。
- 验证:在 `backend-api/` 执行 `$env:GOTOOLCHAIN='local'; go test ./...; go test -race ./...;`
`go vet ./...; go build ./cmd/api; go build ./cmd/migrate; go build ./cmd/authctl`,全部通过。
根目录执行 `./init.ps1`,Android 测试/Debug APK 和 Go 标准验证全部通过。
- 扫描:排除历史任务执行记录后,`rg` 未找到 Connector 运行时引用、8091、共享 API Key、
真实凭证、Cookie、JWT 或订单样本;工作区内 `erp-connector/` 已不存在。
- 未运行:未配置真实 ERP 凭证,未执行线上验证码/受控单号 smoke;上线前仍需人员完成
`/erp` 人工验证码登录,并确认厂商开放 API、数据使用和个人信息处理授权。