peixue-dev/Archive/[一次性]管理师补充反馈功能最终修复方案-2026-01-28.md

196 lines
5.3 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.

# 管理师补充反馈功能最终修复方案
## 📋 业务流程
1. **陪伴员**:选择工单 → 填写反馈 → 保存到 `growth_record`
2. **管理师**:查看陪伴员反馈列表 → 选择一条反馈 → 添加补充内容 → 保存到 `growth_record.supplement` 字段
## 🔍 问题根源
### 数据流分析
```
陪伴员提交反馈
growth_record 表(每日反馈)
管理师查看反馈列表(从 growth_record 表查询)
管理师点击"补充反馈"
前端调用PUT /api/manager/feedback/teacher/{id}
后端接口ManagerFeedbackController.updateTeacherFeedback()
更新 growth_record.supplement 字段
```
### 之前的问题
1. **后端接口已修复**`ManagerFeedbackController.updateTeacherFeedback()` 已改为查询 `growth_record`
2. **前端代码混乱**:尝试调用不存在的新接口 `/api/growth-record/update-supplement/{id}`
3. **参数名不统一**:前端传 `managerSupplement`,后端期望 `supplement`
## ✅ 最终修复方案
### 1. 后端修改(已完成)
**文件**`peidu/backend/src/main/java/com/peidu/controller/ManagerFeedbackController.java`
**修改内容**
- `updateTeacherFeedback` 方法查询 `growth_record` 表(不是 `work_order` 表)
- 兼容两种参数名:`supplement` 和 `managerSupplement`
- 返回错误信息改为"成长记录不存在"(而不是"工单不存在"
```java
@PutMapping("/teacher/{id}")
public Result<String> updateTeacherFeedback(
@PathVariable Long id,
@RequestBody Map<String, Object> params
) {
try {
// ✅ 查询 growth_record 表
GrowthRecord growthRecord = growthRecordService.getById(id);
if (growthRecord == null) {
return Result.error("成长记录不存在");
}
// ✅ 兼容两种参数名
String supplement = null;
if (params.containsKey("managerSupplement")) {
supplement = params.get("managerSupplement").toString();
} else if (params.containsKey("supplement")) {
supplement = params.get("supplement").toString();
}
if (supplement == null || supplement.trim().isEmpty()) {
return Result.error("补充内容不能为空");
}
growthRecord.setSupplement(supplement);
growthRecord.setUpdateTime(LocalDateTime.now());
boolean updated = growthRecordService.updateById(growthRecord);
if (updated) {
return Result.success("修改成功");
} else {
return Result.error("修改失败");
}
} catch (Exception e) {
e.printStackTrace();
return Result.error("修改失败:" + e.getMessage());
}
}
```
### 2. 前端修改(已完成)
**文件**`peidu/uniapp/src/manager-package/pages/manager/feedback.vue`
**修改内容**
- 简化 `submitEdit` 方法
- 直接使用 `managerApi.updateTeacherFeedback()` 方法
- 参数名使用 `supplement`(后端已兼容)
```javascript
async submitEdit() {
if (!this.editForm.supplement.trim()) {
uni.showToast({ title: '请输入补充内容', icon: 'none' })
return
}
try {
uni.showLoading({ title: '提交中...' })
// 🔥 使用 managerApi 的 updateTeacherFeedback 方法
const res = await managerApi.updateTeacherFeedback(this.currentFeedback.id, {
supplement: this.editForm.supplement
})
if (res && (res.code === 200 || res.code === '200')) {
uni.showToast({ title: '修改成功', icon: 'success' })
this.showEditModal = false
this.page = 1
this.list = []
this.loadList()
} else {
const errorMsg = res?.message || res?.msg || '修改失败'
uni.showToast({ title: errorMsg, icon: 'none' })
}
} catch (error) {
console.error('[补充反馈] 修改异常:', error)
const errorMsg = error?.message || error?.msg || error?.data?.message || '修改失败'
uni.showToast({ title: errorMsg, icon: 'none' })
} finally {
uni.hideLoading()
}
}
```
## 🚀 部署步骤
### 1. 重启后端
```bash
# 停止后端服务Ctrl+C
# 重新启动
cd peidu/backend
mvn spring-boot:run
```
### 2. 重新编译前端
```bash
cd peidu/uniapp
npm run dev:mp-weixin
```
### 3. 清除微信开发者工具缓存
1. 点击"清缓存" -> "清除全部缓存"
2. 重新编译
## 🧪 测试步骤
1. 管理师登录
2. 进入"反馈管理"
3. 切换到"陪伴员反馈"标签
4. 点击任意一条反馈
5. 点击"补充反馈"按钮
6. 输入补充内容(如:"111"
7. 点击"确定"
8. 验证:
- ✅ 提示"修改成功"
- ✅ 列表刷新
- ✅ 该反馈显示"已补充"徽章
## 📊 数据验证
### 查询补充内容
```sql
SELECT
id,
content AS '陪伴员反馈',
supplement AS '管理师补充',
create_time AS '创建时间',
update_time AS '更新时间'
FROM growth_record
WHERE supplement IS NOT NULL
ORDER BY update_time DESC
LIMIT 10;
```
## 🎯 关键点
1. **统一接口**:前后端都使用 `/api/manager/feedback/teacher/{id}` 接口
2. **统一参数**:参数名使用 `supplement`
3. **统一数据源**:都操作 `growth_record`
4. **不涉及工单**:管理师补充反馈不需要查询 `work_order`
## 📅 修复时间
2026-01-28
## 👤 修复人员
Kiro AI Assistant