Files
wecome-middleware/README.md
xudw 034d425b21 初始提交: WeCom Middleware项目基础结构
包含以下内容:
1. Spring Boot后端项目结构
2. Vue.js前端项目结构
3. Docker Compose部署配置
4. MySQL数据库初始化脚本
5. Redis缓存配置
6. Nginx反向代理配置
7. 完整的项目文档

技术栈:
- 后端: Spring Boot 2.7.18 + Java 11 + MyBatis Plus
- 前端: Vue.js 3 + TypeScript + Element Plus
- 数据库: MySQL 8.0 + Redis 7
- 部署: Docker Compose + Nginx

已部署服务:
- 后端API: http://localhost:18080
- 前端界面: http://localhost:13000
- 数据库管理: http://localhost:18081
- MySQL: localhost:13306
- Redis: localhost:16379
2026-03-09 12:39:09 +08:00

238 lines
6.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# WeCom Middleware - 企业微信与OpenClaw双向通信中间件
## 🎯 项目概述
这是一个基于Spring Boot + Vue 3的企业微信与OpenClaw双向通信中间件系统。系统通过WebSocket长连接同时连接企业微信智能机器人和OpenClaw网关实现消息的双向路由和转发。
## 🏗️ 技术架构
### 后端技术栈
- **框架**: Spring Boot 3.2.x (单体架构)
- **数据库**: MySQL 8.0 + MyBatis Plus
- **缓存**: Redis 7.x
- **WebSocket**: Spring WebSocket + STOMP
- **安全**: Spring Security + JWT
- **构建工具**: Maven
### 前端技术栈
- **框架**: Vue 3 + TypeScript
- **构建工具**: Vite
- **UI库**: Element Plus
- **状态管理**: Pinia
- **路由**: Vue Router
- **HTTP客户端**: Axios
### 部署架构
- **容器化**: Docker + Docker Compose
- **反向代理**: Nginx
- **数据库**: MySQL + Redis
- **监控**: Spring Boot Actuator
## 📁 项目结构
```
wecom-middleware/
├── backend/ # Spring Boot后端
│ ├── src/main/java/com/wecom/
│ │ ├── config/ # 配置类
│ │ ├── controller/ # REST控制器
│ │ ├── service/ # 业务服务
│ │ ├── websocket/ # WebSocket处理
│ │ ├── entity/ # 实体类
│ │ ├── mapper/ # MyBatis Mapper
│ │ ├── dto/ # 数据传输对象
│ │ └── Application.java
│ └── pom.xml
├── frontend/ # Vue 3前端
│ ├── src/
│ │ ├── views/ # 页面组件
│ │ ├── components/ # 通用组件
│ │ ├── stores/ # Pinia状态管理
│ │ ├── utils/ # 工具函数
│ │ └── websocket/ # WebSocket客户端
│ └── vite.config.ts
├── docker/ # Docker配置
│ ├── Dockerfile.backend
│ ├── Dockerfile.frontend
│ ├── docker-compose.yml
│ └── nginx/
├── scripts/ # 部署脚本
├── docs/ # 文档
└── README.md
```
## 🔗 系统架构图
```
┌─────────────┐ WebSocket ┌─────────────┐ WebSocket ┌─────────────┐
│ OpenClaw │◄─────────────────►│ 本系统 │◄─────────────────►│ 企业微信 │
│ (AI助手) │ Gateway协议 │ (中间件) │ 智能机器人协议 │ (客户端) │
└─────────────┘ └─────────────┘ └─────────────┘
│ │ │
│ │ │
▼ ▼ ▼
AI模型处理 消息路由 + 会话管理 用户交互
```
## 🚀 快速开始
### 1. 环境要求
- Docker 20.10+
- Docker Compose 2.20+
- JDK 17+
- Node.js 18+
### 2. 一键启动
```bash
# 克隆项目
git clone <repository-url>
cd wecom-middleware
# 启动所有服务
docker-compose up -d
# 查看服务状态
docker-compose ps
```
### 3. 访问地址
- **前端管理界面**: http://localhost:8080
- **后端API文档**: http://localhost:8080/swagger-ui.html
- **数据库管理**: http://localhost:8081 (phpMyAdmin)
## 📊 核心功能
### 1. 双向消息路由
- 企业微信 ↔ OpenClaw 消息实时转发
- 支持文本、图片、文件等多种消息类型
- 消息状态跟踪和确认机制
### 2. 会话管理
- 多用户会话隔离
- 会话状态持久化
- 会话超时和清理
### 3. 用户管理
- 企业微信用户同步
- 权限控制和角色管理
- 操作日志记录
### 4. 系统监控
- 实时连接状态监控
- 消息流量统计
- 系统健康检查
### 5. 配置管理
- 企业微信机器人配置
- OpenClaw连接配置
- 系统参数配置
## 🔧 配置说明
### 企业微信配置
```yaml
wecom:
bot-id: ${WECOM_BOT_ID}
secret: ${WECOM_SECRET}
websocket-url: wss://openws.work.weixin.qq.com
```
### OpenClaw配置
```yaml
openclaw:
gateway-url: ws://localhost:18789
auth-token: ${OPENCLAW_TOKEN}
protocol-version: 3
```
### 数据库配置
```yaml
spring:
datasource:
url: jdbc:mysql://mysql:3306/wecom_middleware
username: root
password: ${MYSQL_ROOT_PASSWORD}
redis:
host: redis
port: 6379
```
## 📈 性能指标
- **并发连接**: 支持1000+ WebSocket连接
- **消息延迟**: < 100ms (端到端)
- **可用性**: 99.9% (通过健康检查和自动重连)
- **数据持久化**: 所有消息和状态持久化存储
## 🔒 安全特性
- **传输加密**: WebSocket over TLS
- **身份验证**: JWT Token + 企业微信OAuth
- **权限控制**: 基于角色的访问控制
- **审计日志**: 所有操作记录和追溯
## 🐳 Docker部署
### 构建镜像
```bash
# 构建后端镜像
docker build -f docker/Dockerfile.backend -t wecom-backend:latest .
# 构建前端镜像
docker build -f docker/Dockerfile.frontend -t wecom-frontend:latest .
```
### 使用Docker Compose
```bash
# 开发环境
docker-compose -f docker-compose.dev.yml up
# 生产环境
docker-compose -f docker-compose.prod.yml up -d
```
## 📝 开发指南
### 后端开发
```bash
cd backend
mvn spring-boot:run
```
### 前端开发
```bash
cd frontend
npm install
npm run dev
```
### 数据库迁移
```bash
# 初始化数据库
mysql -u root -p < scripts/init.sql
# 数据迁移
mvn flyway:migrate
```
## 🤝 贡献指南
1. Fork 项目
2. 创建功能分支 (`git checkout -b feature/AmazingFeature`)
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
4. 推送到分支 (`git push origin feature/AmazingFeature`)
5. 开启 Pull Request
## 📄 许可证
本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情
## 📞 支持与联系
- 问题反馈: [GitHub Issues](https://github.com/your-repo/issues)
- 文档: [项目Wiki](https://github.com/your-repo/wiki)
- 邮件: support@example.com
---
**注意**: 本项目是企业微信与OpenClaw的中间件需要同时配置企业微信智能机器人和OpenClaw网关才能正常工作