mahjong_group/docs/1.0.0/历史需求/站内信功能-快速启动指南.md
2026-01-01 14:39:23 +08:00

198 lines
4.4 KiB
Markdown
Raw 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.

# 站内信功能 - 快速启动指南
## 🚀 5分钟快速部署
### 第1步执行数据库脚本1分钟
```sql
-- 打开数据库管理工具(如 SQL Server Management Studio
-- 选择你的数据库
-- 执行文件:数据库\SqlServer\创建站内信表.sql
-- 验证:查询表是否存在
SELECT * FROM SQMessage
SELECT * FROM SQMessageRead
```
### 第2步重启应用2分钟
```bash
# 停止应用
# 编译项目Visual Studio: Ctrl+Shift+B
# 启动应用F5
```
### 第3步测试后台功能2分钟
1. 登录后台管理系统
2. 访问SQ管理 → 站内信管理
3. 点击"发送全员广播"
4. 填写测试消息并发送
5. 刷新列表,查看是否显示
---
## 📝 前端对接3步骤
### 步骤1添加接口定义
`common/server/interface/sq.js` 中添加:
```javascript
/**
* 获取消息列表
*/
export const getMessageList = async (pageIndex = 1, pageSize = 20, messageType = 0) => {
const res = await request.get("SQ/GetMessageList", {
pageIndex, pageSize, messageType
});
if (res.code == 0) {
return res.data;
}
return [];
}
/**
* 获取未读消息数量
*/
export const getUnreadCount = async () => {
const res = await request.get("SQ/GetUnreadCount");
if (res.code == 0) {
return res.data.count;
}
return 0;
}
/**
* 标记所有消息为已读
*/
export const markAllAsRead = async () => {
const res = await request.post("SQ/MarkAllAsRead");
return res.code == 0;
}
```
### 步骤2在"我的"页面显示红点
```javascript
// 在页面 onShow 或 mounted 中调用
import { getUnreadCount } from '@/common/server/interface/sq.js'
async mounted() {
const count = await getUnreadCount();
if (count > 0) {
// 显示红点
this.showRedDot = true;
}
}
```
### 步骤3消息列表页调用接口
```javascript
import { getMessageList, markAllAsRead } from '@/common/server/interface/sq.js'
export default {
data() {
return {
messageList: [],
currentIndex: 0 // 0=全部1=私信
}
},
async onShow() {
await this.loadMessages();
await markAllAsRead(); // 自动标记已读
},
methods: {
async loadMessages() {
const type = this.currentIndex === 0 ? 0 : 1;
this.messageList = await getMessageList(1, 20, type);
}
}
}
```
---
## ✅ 快速验证清单
### 后台功能验证
- [ ] 能访问站内信管理页面
- [ ] 能发送全员广播
- [ ] 消息列表正常显示
- [ ] 能查看消息详情
- [ ] 能删除消息
### 前端功能验证(需前端对接完成)
- [ ] 能获取消息列表
- [ ] 能获取未读数量
- [ ] 能标记已读
- [ ] "我的消息"显示红点
- [ ] 消息内容正常显示
### 自动通知验证
- [ ] 创建组局
- [ ] 组局成功后收到通知
- [ ] 组局失败后收到通知
---
## 🔧 常见问题快速解决
### 问题1表不存在
**错误**`Invalid object name 'SQMessage'`
**解决**:执行数据库脚本 `创建站内信表.sql`
### 问题2依赖注入失败
**错误**`No service for type ISQMessageServices`
**解决**
1. 检查命名空间是否正确
2. 重新编译项目
3. 如使用手动注入,参考文档添加配置
### 问题3接口404
**错误**`404 Not Found`
**解决**
1. 检查接口路径:`/api/SQ/GetMessageList`
2. 确认应用已重启
3. 检查路由配置
### 问题4前端获取不到数据
**错误**:返回空数组
**解决**
1. 先在后台发送测试消息
2. 检查用户是否已登录
3. 检查Token是否有效
---
## 📞 获取帮助
### 查看文档
- **需求文档**`站内信需求.md`
- **开发总结**`站内信功能开发总结.md`
- **部署检查**`站内信功能完成情况检查.md`
- **后台使用**`后台-站内信管理使用说明.md`
- **交付清单**`站内信功能最终交付清单.md`
### 问题排查
按以下顺序检查:
1. 数据库表是否创建 ✓
2. 应用是否重启 ✓
3. 依赖注入是否正常 ✓
4. 接口路径是否正确 ✓
5. 用户Token是否有效 ✓
---
## 🎯 下一步行动
### 立即可做
1. ✅ 执行数据库脚本
2. ✅ 重启应用
3. ✅ 测试后台功能
4. ✅ 发送测试消息
### 需要前端配合
1. ⏳ 添加接口定义
2. ⏳ 实现消息列表页
3. ⏳ 实现未读红点
4. ⏳ 测试前端功能
---
**祝你部署顺利!** 🎉