Browse Source

新增反馈运营看板删除功能

TDesign-Vue-Next-1.20.6
wanghanlin 2 weeks ago
parent
commit
d5585206cf
  1. 1
      frontend/src/api/feedback.ts
  2. 17
      frontend/src/views/FeedbackOps.vue
  3. 26
      src/main/java/com/wok/supportbot/controller/MessageFeedbackController.java
  4. 14
      src/main/java/com/wok/supportbot/service/MessageFeedbackService.java

1
frontend/src/api/feedback.ts

@ -21,3 +21,4 @@ export function listFeedbackConversations(params: Record<string, any>): Promise<
}
export function getFeedbackMessages(conversationId: string): Promise<ApiResponse> { return request.get(`/feedback/messages?conversationId=${encodeURIComponent(conversationId)}`).then(r => r.data) }
export function markFeedbackProcessed(id: string, data: any): Promise<ApiResponse> { return request.put(`/feedback/${id}/processed`, data).then(r => r.data) }
export function deleteFeedback(id: string): Promise<ApiResponse> { return request.delete(`/feedback/${id}`).then(r => r.data) }

17
frontend/src/views/FeedbackOps.vue

@ -38,6 +38,7 @@
<t-button size="small" variant="text" theme="primary" @click="createFaqFromRow(row)" v-if="row.feedbackType === 'THUMBS_UP'">生成 FAQ</t-button>
<t-button size="small" variant="text" theme="warning" @click="openFaqAction(row)" v-if="row.feedbackType === 'THUMBS_DOWN'">关联 FAQ</t-button>
<t-button size="small" variant="text" v-if="!row.processed" @click="markHandled(row)">标记已处理</t-button>
<t-button size="small" variant="text" theme="danger" @click="removeFeedback(row)">删除</t-button>
</t-space>
</template>
</t-table>
@ -83,12 +84,15 @@
<script setup lang="ts">
import { ref, onMounted, computed } from 'vue'
import { listFeedbackConversations, getFeedbackMessages, markFeedbackProcessed } from '@/api/feedback'
import { listFeedbackConversations, getFeedbackMessages, markFeedbackProcessed, deleteFeedback } from '@/api/feedback'
import { listFaqs, createFaqFromFeedback, appendFaqFromFeedback, editFaqFromFeedback } from '@/api/faq'
import { getCategoryTree } from '@/api/category'
import { useConfirm } from '@/composables/useConfirm'
import { toast } from '@/utils/toast'
import { renderMarkdown } from '@/utils/markdown'
const { confirm } = useConfirm()
const filterFeedbackType = ref(''); const filterReasonCategory = ref(''); const filterProcessed = ref(''); const filterDate = ref('')
const feedbacks = ref<any[]>([]); const loading = ref(false)
const page = ref(1); const pageSize = ref(20); const total = ref(0)
@ -227,6 +231,17 @@ async function markHandled(row: any) {
} catch (e: any) { toast('操作失败:' + e.message, 'error') }
}
async function removeFeedback(row: any) {
const fbId = row.feedbackId || row.feedback_id
if (!fbId) { toast('未找到反馈记录', 'error'); return }
if (!await confirm('确认删除该反馈记录?')) return
try {
const r = await deleteFeedback(fbId)
if (r.success) { toast('删除成功', 'success'); loadList(page.value) }
else toast(r.message || '删除失败', 'error')
} catch (e: any) { toast('删除失败:' + e.message, 'error') }
}
function createFaqFromRow(row: any) {
// SQL user_question / userQuestion
faqModal.value = {

26
src/main/java/com/wok/supportbot/controller/MessageFeedbackController.java

@ -149,6 +149,32 @@ public class MessageFeedbackController {
}
}
/**
* 删除反馈逻辑删除
*/
@DeleteMapping("/feedback/{id}")
@PreAuthorize("hasAnyRole('admin','kb_operator')")
public ResponseEntity<Map<String, Object>> deleteFeedback(@PathVariable Long id) {
try {
messageFeedbackService.deleteFeedback(id);
return ResponseEntity.ok(Map.of(
"success", true,
"message", "删除成功"
));
} catch (IllegalArgumentException e) {
return ResponseEntity.status(400).body(Map.of(
"success", false,
"message", e.getMessage()
));
} catch (Exception e) {
log.error("删除反馈失败: id={}", id, e);
return ResponseEntity.status(500).body(Map.of(
"success", false,
"message", "删除失败:" + e.getMessage()
));
}
}
/**
* 获取反馈统计数据
*

14
src/main/java/com/wok/supportbot/service/MessageFeedbackService.java

@ -258,6 +258,20 @@ public class MessageFeedbackService {
return messageFeedbackMapper.selectById(id);
}
/**
* 删除反馈逻辑删除
*
* @param id 反馈 ID
*/
public void deleteFeedback(Long id) {
MessageFeedback feedback = messageFeedbackMapper.selectById(id);
if (feedback == null) {
throw new IllegalArgumentException("反馈不存在: id=" + id);
}
messageFeedbackMapper.deleteById(id);
log.info("反馈已删除: id={}", id);
}
/**
* 按会话ID查询所有反馈
*

Loading…
Cancel
Save