Summary: - Implement Prompt management infrastructure and core services - Build admin portal frontend with light theme - Integrate CodeMirror 6 editor for non-technical users Phase 3.5.1: Infrastructure Setup - Create capability_schema for Prompt storage - Add prompt_templates and prompt_versions tables - Add prompt:view/edit/debug/publish permissions - Migrate RVW prompts to database (RVW_EDITORIAL, RVW_METHODOLOGY) Phase 3.5.2: PromptService Core - Implement gray preview logic (DRAFT for debuggers, ACTIVE for users) - Module-level debug control (setDebugMode) - Handlebars template rendering - Variable extraction and validation (extractVariables, validateVariables) - Three-level disaster recovery (database -> cache -> hardcoded fallback) Phase 3.5.3: Management API - 8 RESTful endpoints (/api/admin/prompts/*) - Permission control (PROMPT_ENGINEER can edit, SUPER_ADMIN can publish) Phase 3.5.4: Frontend Management UI - Build admin portal architecture (AdminLayout, OrgLayout) - Add route system (/admin/*, /org/*) - Implement PromptListPage (filter, search, debug switch) - Implement PromptEditor (CodeMirror 6 simplified for clinical users) - Implement PromptEditorPage (edit, save, publish, test, version history) Technical Details: - Backend: 6 files, ~2044 lines (prompt.service.ts 596 lines) - Frontend: 9 files, ~1735 lines (PromptEditorPage.tsx 399 lines) - CodeMirror 6: Line numbers, auto-wrap, variable highlight, search, undo/redo - Chinese-friendly: 15px font, 1.8 line-height, system fonts Next Step: Phase 3.5.5 - Integrate RVW module with PromptService Tested: Backend API tests passed (8/8), Frontend pending user testing Status: Ready for Phase 3.5.5 RVW integration
150 lines
2.9 KiB
Markdown
150 lines
2.9 KiB
Markdown
# 部署微信服务号到SAE(快速指南)
|
||
|
||
## 🎯 目标
|
||
将微信服务号回调服务部署到SAE生产环境,使用域名:`iit.xunzhengyixue.com`
|
||
|
||
---
|
||
|
||
## 📋 Step 1: 确认环境变量配置
|
||
|
||
编辑 `backend/.env`,确认以下配置存在:
|
||
|
||
```env
|
||
# 微信服务号配置
|
||
WECHAT_MP_APP_ID=wx062568ff49e4570c
|
||
WECHAT_MP_APP_SECRET=c0d19435d1a1e948939c16d767ec0faf
|
||
WECHAT_MP_TOKEN=IitPatientWechat2026JanToken
|
||
WECHAT_MP_ENCODING_AES_KEY=VIzwMGRG4Ll8Sd7fPxPXLlBaWdsh2rK2qIGpyaEoc1v
|
||
```
|
||
|
||
---
|
||
|
||
## 📋 Step 2: 在SAE控制台配置环境变量
|
||
|
||
1. **登录阿里云SAE控制台**
|
||
2. **进入应用管理 → 选择应用**
|
||
3. **配置管理 → 环境变量**
|
||
4. **添加以下环境变量**:
|
||
|
||
```
|
||
WECHAT_MP_APP_ID=wx062568ff49e4570c
|
||
WECHAT_MP_APP_SECRET=c0d19435d1a1e948939c16d767ec0faf
|
||
WECHAT_MP_TOKEN=IitPatientWechat2026JanToken
|
||
WECHAT_MP_ENCODING_AES_KEY=VIzwMGRG4Ll8Sd7fPxPXLlBaWdsh2rK2qIGpyaEoc1v
|
||
```
|
||
|
||
5. **保存配置**
|
||
|
||
---
|
||
|
||
## 📋 Step 3: 部署代码到SAE
|
||
|
||
```bash
|
||
cd D:\MyCursor\AIclinicalresearch\backend
|
||
.\deploy-to-sae.ps1
|
||
```
|
||
|
||
**等待部署完成**(约5-10分钟)
|
||
|
||
---
|
||
|
||
## 📋 Step 4: 验证部署
|
||
|
||
访问以下URL,确认服务正常:
|
||
|
||
```
|
||
https://iit.xunzhengyixue.com/api/v1/iit/health
|
||
```
|
||
|
||
**期望返回**:
|
||
```json
|
||
{
|
||
"status": "ok",
|
||
"module": "iit-manager",
|
||
"version": "1.1.0"
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
## 📋 Step 5: 配置微信公众平台
|
||
|
||
1. **登录微信公众平台**:https://mp.weixin.qq.com/
|
||
2. **进入:设置与开发 → 基本配置 → 服务器配置**
|
||
3. **点击"修改配置"**
|
||
4. **填写以下信息**:
|
||
|
||
| 配置项 | 值 |
|
||
|--------|-----|
|
||
| **URL** | `https://iit.xunzhengyixue.com/wechat/patient/callback` |
|
||
| **Token** | `IitPatientWechat2026JanToken` |
|
||
| **EncodingAESKey** | `VIzwMGRG4Ll8Sd7fPxPXLlBaWdsh2rK2qIGpyaEoc1v` |
|
||
| **消息加解密方式** | **安全模式(推荐)** |
|
||
| **数据格式** | **XML** |
|
||
|
||
5. **点击"提交"**
|
||
6. **验证成功后点击"启用"**
|
||
|
||
---
|
||
|
||
## ✅ 验证成功标志
|
||
|
||
### 配置阶段:
|
||
- ✅ 页面显示"配置成功"
|
||
- ✅ 服务器配置状态为"已启用"
|
||
|
||
### 测试阶段:
|
||
1. **关注公众号**:AI for 临床研究
|
||
2. **查看SAE日志**,应该看到:
|
||
```
|
||
📥 收到微信服务号回调消息
|
||
🔐 检测到加密消息,开始解密...
|
||
✅ 消息解密成功
|
||
👤 用户关注公众号
|
||
```
|
||
|
||
---
|
||
|
||
## 🔧 如何查看SAE日志
|
||
|
||
1. **登录阿里云SAE控制台**
|
||
2. **应用管理 → 选择应用 → 实例管理**
|
||
3. **点击"日志" → "实时日志"**
|
||
4. **查看最近的日志输出**
|
||
|
||
---
|
||
|
||
## 📝 优势
|
||
|
||
使用生产环境的优势:
|
||
- ✅ 域名 `iit.xunzhengyixue.com` 已备案
|
||
- ✅ HTTPS证书已配置
|
||
- ✅ 已在企业微信中验证过
|
||
- ✅ 无需natapp内网穿透
|
||
- ✅ 稳定性更好
|
||
- ✅ 无需配置域名验证
|
||
|
||
---
|
||
|
||
## ⏱️ 预计用时
|
||
|
||
- 配置环境变量:2分钟
|
||
- 部署到SAE:5-10分钟
|
||
- 配置微信公众平台:3分钟
|
||
- **总计:10-15分钟**
|
||
|
||
---
|
||
|
||
**立即开始部署!** 🚀
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|