新增开场白配置管理

This commit is contained in:
WangJing 2025-07-23 17:41:28 +08:00
parent 97f976bbc5
commit a03ef97f78
21 changed files with 683 additions and 43 deletions

View File

@ -2,11 +2,11 @@
# 此文件修改后需要重启项目
NODE_ENV=development
#VUE_APP_BASE_URL='/vab-mock-server'
# VUE_APP_BASE_URL='http://localhost:10001'
# VUE_APP_API_BASE_URL='http://localhost:8080'
VUE_APP_BASE_URL='http://localhost:10001'
VUE_APP_API_BASE_URL='http://localhost:8080'
#北京服务器配置
VUE_APP_BASE_URL='http://192.168.1.211:80/brichat'
VUE_APP_API_BASE_URL='http://192.168.1.211:80/brichat'
# VUE_APP_BASE_URL='http://192.168.1.211:80/brichat'
# VUE_APP_API_BASE_URL='http://192.168.1.211:80/brichat'
#武汉公司服务器
# VUE_APP_BASE_URL='http://192.168.8.253:80/brichat'
# VUE_APP_API_BASE_URL='http://192.168.8.253:80/brichat'

View File

@ -2,11 +2,11 @@
# 此文件修改后需要重启项目
NODE_ENV=production
# VUE_APP_BASE_URL='/vab-mock-server'
# VUE_APP_BASE_URL='http://localhost:10001'
# VUE_APP_API_BASE_URL='http://localhost:10001'
VUE_APP_BASE_URL='http://localhost:10001'
VUE_APP_API_BASE_URL='http://localhost:10001'
#北京服务器
VUE_APP_BASE_URL='http://192.168.1.211:80/brichat'
VUE_APP_API_BASE_URL='http://192.168.1.211:80/brichat'
# VUE_APP_BASE_URL='http://192.168.1.211:80/brichat'
# VUE_APP_API_BASE_URL='http://192.168.1.211:80/brichat'
#武汉公司服务器
# VUE_APP_BASE_URL='http://192.168.8.253:80/brichat'
# VUE_APP_API_BASE_URL='http://192.168.8.253:80/brichat'

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
export function getRemark(chatType: string) {
return request({
url: '/brichat-service/prologue/getRemark',
method: 'get',
params: { chatType },
})
}
export function saveRemark(data: any) {
return request({
url: '/brichat-service/prologue/saveRemark',
method: 'post',
data,
})
}
// 获取指定 chatType 下的推荐问题列表
export function getRecommendations(chatType: string) {
return request({
url: '/brichat-service/prologue/getRecommendations',
method: 'get',
params: { chatType },
})
}
// 编辑推荐问题
export function eidtRecommendation(data: any) {
return request({
url: '/brichat-service/prologue/eidtRecommendation',
method: 'post',
data,
})
}
// 删除指定的推荐问题
export function deleteRecommendation(id: string) {
return request({
url: '/brichat-service/prologue/deleteRecommendation',
method: 'delete',
params: { id },
})
}

View File

@ -523,5 +523,27 @@ export default {
addSuccess: 'Add Successfully',
addFail:'Add Failed'
},
prologue:{
chatType: 'Chat Type',
selectChatType: 'Select Chat Type',
prologueContent: 'Prologue Content',
addRecommend: 'Add Recommendation',
recommendQuestion: 'Recommended Question',
actions: 'Actions',
edit: 'Edit',
delete: 'Delete',
confirmDelete: 'Are you sure you want to delete this recommendation?',
confirmSave: 'Are you sure you want to save the changes?',
deleteSuccess: 'Deleted successfully',
deleteFailure: 'Failed to delete, please try again later',
saveSuccess: 'Saved successfully',
saveFailure: 'Failed to save, please try again later',
loadSuccess: 'Loaded successfully',
loadFailure: 'Failed to load, please try again later',
noContent: 'No content found',
loading: 'Loading...',
updateRecommendation: 'Update Recommendation',
addRecommendation: 'Add Recommendation',
}
},
}

View File

@ -523,5 +523,27 @@ export default {
addSuccess:'新增成功',
addFail:'新增失敗',
},
prologue:{
chatType: '聊天類型',
selectChatType: '選擇聊天類型',
prologueContent: '開場白內容',
addRecommend: '新增推薦問題',
recommendQuestion: '推薦問題',
actions: '操作',
edit: '編輯',
delete: '刪除',
confirmDelete: '確定要刪除該推薦問題嗎?',
confirmSave: '是否確認保存修改?',
deleteSuccess: '刪除成功',
deleteFailure: '刪除失敗,請稍後重試',
saveSuccess: '保存成功',
saveFailure: '保存失敗,請稍後重試',
loadSuccess: '加載成功',
loadFailure: '加載失敗,請稍後重試',
noContent: '未找到內容',
loading: '加載中...',
updateRecommendation: '更新推薦問題',
addRecommendation: '新增推薦問題',
}
},
}

View File

@ -531,5 +531,27 @@ export default {
addSuccess: '新增成功',
addFail: '新增失败',
},
prologue:{
chatType: '聊天类型',
selectChatType: '选择聊天类型',
prologueContent: '开场白内容',
addRecommend: '新增推荐问题',
recommendQuestion: '推荐问题',
actions: '操作',
edit: '编辑',
delete: '删除',
confirmDelete: '确定要删除该推荐问题吗?',
confirmSave: '是否确认保存修改?',
deleteSuccess: '删除成功',
deleteFailure: '删除失败,请稍后重试',
saveSuccess: '保存成功',
saveFailure: '保存失败,请稍后重试',
loadSuccess: '加载成功',
loadFailure: '加载失败,请稍后重试',
noContent: '未找到内容',
loading: '加载中...',
updateRecommendation: '更新推荐问题',
addRecommendation: '新增推荐问题',
}
},
}

View File

@ -1,27 +1,30 @@
<template>
<div class="main-container">
<ChatBox
:chat-type="chatType"
:user-id="userId"
:placeholder="placeholder"
:openRemark="openRemark"
:recommend-questions="recommendQuestions"
@stream-complete="handleStreamComplete"
@source-click="handleSourceClick"
@message-received="handleMessageReceived"
@chat-created="handleChatCreated"
@chat-switched="handleChatSwitched"
/>
<!-- 等待 openRemark 数据加载完成后再渲染 ChatBox -->
<ChatBox
v-if="openRemark"
:chat-type="chatType"
:user-id="userId"
:placeholder="placeholder"
:openRemark="openRemark"
:recommend-questions="recommendQuestions"
@stream-complete="handleStreamComplete"
@source-click="handleSourceClick"
@message-received="handleMessageReceived"
@chat-created="handleChatCreated"
@chat-switched="handleChatSwitched"
/>
</div>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
import ChatBox from '@/views/chatweb/components/ChatBox.vue'
import { useAclStore } from '@/store/modules/acl'
import { ElMessage } from 'element-plus'
import { useI18n } from 'vue-i18n'
import { getRemark,getRecommendations } from '@/api/prologue'
const { t, locale } = useI18n()
const aclStore = useAclStore()
@ -29,15 +32,56 @@ const aclStore = useAclStore()
// ChatBox -
const chatType = ref('3') //
const userId = computed(() => aclStore.getUserId) // ID
const placeholder = ref('请输入您的图表报告问题...') //
const openRemark = ref(`Hello 😊, I am BRI assistant, a senior data analyst. You can ask questions, and I can analyze the retrieved data and convert it into a visual chart.
| Function | Narrative |
|--------------|----------|
| Supported types | Bar chart (bar), line chart (line), pie chart (pie), scatter chart (scatter), scatter chart (bubble) with ripple effect <br>chart (effectScatter), candlestick chart (candlestick), radar chart (radar), heat map (heatmap), <br>tree map (tree), rectangular tree map (treemap), sunburst chart (sunburst), map (map), path map (lines), <br>relationship diagram (graph), box plot (boxplot), parallel coordinate system (parallel), dashboard (gauge), funnel chart (funnel), <br>Sankey diagram (sankey), theme river diagram (themeRiver) and pictorial column chart (pictorialBar). |
| Question template | [question], [graph type] |`) // 开场白
const recommendQuestions = ref(['各系统的故障次数,折线图','大學站和何東樓車廠站在5月发生的故障统计饼图'])
const placeholder = computed(() => t('vabI18n.chat.placeEnterChart'))
// const openRemark = ref(`Hello 😊, I am BRI assistant, a senior data analyst. You can ask questions, and I can analyze the retrieved data and convert it into a visual chart.
// | Function | Narrative |
// |--------------|----------|
// | Supported types | Bar chart (bar), line chart (line), pie chart (pie), scatter chart (scatter), scatter chart (bubble) with ripple effect <br>chart (effectScatter), candlestick chart (candlestick), radar chart (radar), heat map (heatmap), <br>tree map (tree), rectangular tree map (treemap), sunburst chart (sunburst), map (map), path map (lines), <br>relationship diagram (graph), box plot (boxplot), parallel coordinate system (parallel), dashboard (gauge), funnel chart (funnel), <br>Sankey diagram (sankey), theme river diagram (themeRiver) and pictorial column chart (pictorialBar). |
// | Question template | [question], [graph type] |`) //
const openRemark = ref('')
const recommendQuestions = ref<string[]>([]) //
// const recommendQuestions = ref(['线','5'])
// ChatBox
// openRemark
const fetchOpenRemark = async () => {
try {
const response = await getRemark(chatType.value) // chatType
if (response.data && response.data.content) {
openRemark.value = response.data.content // openRemark
} else {
openRemark.value = '默认的开场白' //
}
} catch (error) {
ElMessage.error('加载开场白失败,请稍后重试')
console.error(error)
}
}
//
const fetchRecommendations = async () => {
try {
const response = await getRecommendations(chatType.value) // chatType
if (response.data) {
recommendQuestions.value = response.data.map(item => item.questionContent) //
} else {
recommendQuestions.value = []
}
} catch (error) {
ElMessage.error('加载推荐问题失败,请稍后重试')
console.error(error)
}
}
// openRemark
onMounted(() => {
fetchOpenRemark()
fetchRecommendations()
})
//
const handleStreamComplete = (data: {
conversationId: string
@ -49,6 +93,7 @@ console.log('图表报告 - 对话完成:', data)
//
}
//
const handleSourceClick = (source: {
fileName: string

View File

@ -1,6 +1,7 @@
<template>
<div class="main-container">
<ChatBox
v-if="isRemarkLoaded"
:chat-type="chatType"
:user-id="userId"
:placeholder="placeholder"
@ -21,19 +22,62 @@ import ChatBox from '@/views/chatweb/components/ChatBox.vue'
import { useAclStore } from '@/store/modules/acl'
import { ElMessage } from 'element-plus'
import { useI18n } from 'vue-i18n'
import { getRemark,getRecommendations} from '@/api/prologue'
const { t, locale } = useI18n()
const aclStore = useAclStore()
const isRemarkLoaded = ref(false)
// ChatBox -
const chatType = ref('5') //
const userId = computed(() => aclStore.getUserId) // ID
// const placeholder = ref('...') //
const placeholder = computed(() => t('vabI18n.chat.placeEnterDiag'))
const openRemark = ref('您好,我是北铁所的诊断代码查询助手,可以帮助您快速定位到故障的诊断代码相关信息,您可以输入如下格式问题:故障描述+代码+数字, 例如: ') //
const recommendQuestions = ref(['配属潮州所的CRH2A-1248车组担当D7303次饶平-广州东1101分车组运行至惠州南一罗浮山区间IDU报01车司机室HVAC送风机速度反馈故障代码001','配属潮州所的CRH2A-1248车组担当D7303次饶平-广州东1101分车组运行至惠州南一罗浮山区间IDU报02车接触器K断开故障车牵引丢失。'])
const openRemark = ref('')
const recommendQuestions = ref<string[]>([]) //
// const openRemark = ref(',,:++, : ') //
// const recommendQuestions = ref(['CRH2A-1248D7303-广1101IDU01HVAC001','CRH2A-1248D7303-广1101IDU02K'])
// ChatBox
// openRemark
const fetchOpenRemark = async () => {
try {
const response = await getRemark(chatType.value) // chatType
if (response.data && response.data.content) {
openRemark.value = response.data.content // openRemark
} else {
openRemark.value = '默认的开场白' //
}
isRemarkLoaded.value = true // true
} catch (error) {
ElMessage.error('加载开场白失败,请稍后重试')
console.error(error)
isRemarkLoaded.value = true
}
}
//
const fetchRecommendations = async () => {
try {
const response = await getRecommendations(chatType.value) // chatType
if (response.data) {
recommendQuestions.value = response.data.map(item => item.questionContent) //
} else {
recommendQuestions.value = []
}
} catch (error) {
ElMessage.error('加载推荐问题失败,请稍后重试')
console.error(error)
}
}
// openRemark
onMounted(() => {
fetchOpenRemark()
fetchRecommendations()
})
//
const handleStreamComplete = (data: {
conversationId: string

View File

@ -4,6 +4,7 @@
<!-- 左侧聊天对话框 -->
<el-col :span="showChart ? 14 : 24" class="chat-panel">
<ChatBox
v-if="isRemarkLoaded"
:chat-type="chatType"
:user-id="userId"
:placeholder="placeholder"
@ -61,6 +62,8 @@ import { sendMessages } from '@/api/historicalRecords'
import { getMaintStatData, type TraceFile } from '@/api/chat'
import { ElMessage } from 'element-plus'
import { useI18n } from 'vue-i18n'
import { getRemark,getRecommendations} from '@/api/prologue'
const { t, locale } = useI18n()
const userStore = useUserStore()
const aclStore = useAclStore()
@ -69,12 +72,14 @@ const aclStore = useAclStore()
const chatType = ref('1') //
const userId = computed(() => aclStore.getUserId) // ID
const placeholder = ref('输入您的问题...') //
const openRemark = ref(`Hello😊, I am a BRI assistant, a senior train fault analysis expert. You can ask questions about train faults, and I can analyze the retrieved data. Please refer to the following tips:
| Question templates for different functions | Description |
|--------------|----------|
| Fault diagnosis | [Train car number] + [Fault problem/fault phenomenon] |
| Maintenance record query | [Train car number] + [Latest N maintenance records] |`) // 开场白
const recommendQuestions = ref(['T34 train, What to do if the Passenger Door cannot be opened','The latest 5 maintenance records of T34 train'])
const openRemark = ref('')
const recommendQuestions = ref<string[]>([])
// const openRemark = ref(`Hello😊, I am a BRI assistant, a senior train fault analysis expert. You can ask questions about train faults, and I can analyze the retrieved data. Please refer to the following tips:
// | Question templates for different functions | Description |
// |--------------|----------|
// | Fault diagnosis | [Train car number] + [Fault problem/fault phenomenon] |
// | Maintenance record query | [Train car number] + [Latest N maintenance records] |`) //
// const recommendQuestions = ref(['T34 train, What to do if the Passenger Door cannot be opened','The latest 5 maintenance records of T34 train'])
const showChart = ref(false)
const pdfUrl = ref('/static-resources/files/pdfFile/开悟大模型智能体平台简介1.pdf')
@ -82,6 +87,7 @@ const pdfVisible = ref(false)
const dialogVisible = ref(false)
const pdfFiles = ref([])
const loadChart = ref(true)
const isRemarkLoaded = ref(false)
//
type ConversationIdInfo = Record<string, string>
@ -129,6 +135,46 @@ interface PieChartDataItem {
name: string
}
// openRemark
const fetchOpenRemark = async () => {
try {
const response = await getRemark(chatType.value) // chatType
if (response.data && response.data.content) {
openRemark.value = response.data.content // openRemark
} else {
openRemark.value = '默认的开场白' //
}
isRemarkLoaded.value = true // true
} catch (error) {
ElMessage.error('加载开场白失败,请稍后重试')
console.error(error)
isRemarkLoaded.value = true
}
}
//
const fetchRecommendations = async () => {
try {
const response = await getRecommendations(chatType.value) // chatType
if (response.data) {
recommendQuestions.value = response.data.map(item => item.questionContent) //
} else {
recommendQuestions.value = []
}
} catch (error) {
ElMessage.error('加载推荐问题失败,请稍后重试')
console.error(error)
}
}
// openRemark
onMounted(() => {
fetchOpenRemark()
fetchRecommendations()
})
const openPdf = (url: string) => {
pdfUrl.value = url.replace('/var/www/assets/', '/')
console.log('pdfUrl.value', pdfUrl.value)

View File

@ -1,6 +1,7 @@
<template>
<div class="main-container">
<ChatBox
v-if="isRemarkLoaded"
:chat-type="chatType"
:user-id="userId"
:placeholder="placeholder"
@ -20,17 +21,41 @@ import { ref, computed } from 'vue'
import ChatBox from '@/views/chatweb/components/ChatBox.vue'
import { useAclStore } from '@/store/modules/acl'
import { ElMessage } from 'element-plus'
import { getRemark } from '@/api/prologue'
const aclStore = useAclStore()
const isRemarkLoaded = ref(false)
// ChatBox -
const chatType = ref('2') //
const userId = computed(() => aclStore.getUserId) // ID
const placeholder = ref('请输入您的智能问答问题...') //
const openRemark = ref('你好,我是北京铁道所的车辆智能运维助手☺️,欢迎您向本助手提问车辆故障问题!') //
const recommendQuestions = ref(['配属广州南所的CRH2A-2298车组担当D7200/7197次深圳北-汕头),12:27分车组在普宁站集控关门时因旅客阻门导致MON报229803车4位车门关闭故障代码111机械师检查车门无异常通知司机再次关门后正常。','配属广州动车所的CRH1A-1011车组担当C8001次广州东—深圳6:45分在广州东站待开时机械师汇报pis无法输入车次'])
// const openRemark = ref('') //
const openRemark = ref('')
const recommendQuestions = ref(['配属广州南所的CRH2A-2298车组担当D7200/7197次深圳北-汕头),12:27分车组在普宁站集控关门时因旅客阻门导致MON报229803车4位车门关闭故障代码111机械师检查车门无异常通知司机再次关门后正常。','配属广州动车所的CRH1A-1011车组担当C8001次广州东—深圳6:45分在广州东站待开时机械师汇报pis无法输入车次'])
// ChatBox
// openRemark
const fetchOpenRemark = async () => {
try {
const response = await getRemark(chatType.value) // chatType
if (response.data && response.data.content) {
openRemark.value = response.data.content // openRemark
} else {
openRemark.value = '默认的开场白' //
}
isRemarkLoaded.value = true
} catch (error) {
ElMessage.error('加载开场白失败,请稍后重试')
console.error(error)
isRemarkLoaded.value = true
}
}
// openRemark
onMounted(() => {
fetchOpenRemark()
})
//
const handleStreamComplete = (data: {
conversationId: string

View File

@ -0,0 +1,147 @@
<template>
<el-card>
<el-form :model="form" label-width="120px">
<el-form-item>
<el-button type="primary" @click="load">查询</el-button>
<el-button type="success" @click="save">保存</el-button>
</el-form-item>
<el-form-item :label="聊天类型">
<el-select v-model="form.chatType" placeholder="选择聊天类型">
<el-option label="故障诊断" value="1" />
<el-option label="智能问答" value="2" />
<el-option label="图表报告" value="3" />
<el-option label="应急助手问答" value="4" />
<el-option label="诊断代码查询" value="5" />
</el-select>
</el-form-item>
<el-form-item label="开场白内容">
<el-input type="textarea" v-model="form.content" rows="8"></el-input>
</el-form-item>
<!-- 新增推荐问题 -->
<el-form-item>
<el-button type="primary" @click="addRecommend">新增推荐问题</el-button>
</el-form-item>
<!-- 推荐问题列表 -->
<el-table :data="recommendations" style="width: 100%" border>
<el-table-column label="推荐问题" prop="questionContent" />
<el-table-column label="操作" width="180">
<template v-slot="scope">
<el-button size="mini" @click="editRecommend(scope.row)">编辑</el-button>
<el-button size="mini" type="danger" @click="deleteRecommend(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form>
</el-card>
</template>
<script setup lang="ts">
import { ref, watch, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getRemark, saveRemark, getRecommendations, editRecommendation, deleteRecommendation } from '@/api/prologue'
import { useI18n } from 'vue-i18n'
const { t, locale } = useI18n()
defineOptions({
name: 'prologueManage',
})
const form = ref({
chatType: '1', // ''
content: '',
})
const recommendations = ref([]) //
const currentRecommendation = ref({ questionContent: '' }) //
//
const load = async () => {
try {
const res = await getRemark(form.value.chatType) // chatType
if (res.data) {
form.value.content = res.data.content
ElMessage.success('加载成功')
await loadRecommendations() //
} else {
form.value.content = ''
ElMessage.error('未找到开场白内容')
}
} catch (error) {
ElMessage.error('加载失败,请稍后重试')
}
}
//
const loadRecommendations = async () => {
try {
const res = await getRecommendations(form.value.chatType) // 使 chatType
if (res.data) {
console.log('recommend questions return data:', res.data)
recommendations.value = res.data // res.data
}
} catch (error) {
ElMessage.error('加载推荐问题失败')
}
}
// chatType content
watch(
() => form.value.chatType,
() => {
load()
}
)
//
const save = () => {
ElMessageBox.confirm('是否确认保存修改?', '提示', {
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
}).then(async () => {
try {
await saveRemark(form.value)
ElMessage.success('保存成功')
} catch (error) {
ElMessage.error('保存失败,请稍后重试')
}
})
}
//
const addRecommend = () => {
// currentRecommendation.value = { questionContent: '' } //
// dialogVisible.value = true //
}
//
const editRecommend = (row: any) => {
// currentRecommendation.value = { ...row } //
// dialogVisible.value = true //
}
//
const deleteRecommend = (row: any) => {
ElMessageBox.confirm('确定要删除该推荐问题吗?', '删除确认', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(async () => {
try {
await deleteRecommendation(row.id) // id
console.log('待删除的row.id',row.id)
ElMessage.success('删除成功')
await loadRecommendations() //
} catch (error) {
ElMessage.error('删除失败')
}
})
}
//
onMounted(load)
</script>

View File

@ -0,0 +1,51 @@
package com.bjtds.brichat.controller;
import com.bjtds.brichat.entity.sys.ApiKey;
import com.bjtds.brichat.entity.sys.PrologueQuestion;
import com.bjtds.brichat.entity.sys.SystemRemark;
import com.bjtds.brichat.service.PrologueService;
import com.bjtds.brichat.util.ResultUtils;
import com.netflix.discovery.converters.Auto;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Api(tags = "开场白配置")
@RestController
@Slf4j
@CrossOrigin(value = "*",maxAge = 3600)
@RequestMapping("/prologue")
public class PrologueController {
@Autowired
private PrologueService prologueService;
@GetMapping("/getRemark")
public ResultUtils getRemark(@RequestParam String chatType) {
SystemRemark systemRemark = prologueService.getRemark(chatType);
return ResultUtils.success(systemRemark);
}
@PostMapping("/saveRemark")
public ResultUtils saveRemark(@RequestBody SystemRemark remark) {
return ResultUtils.success(prologueService.saveOrUpdate(remark));
}
@GetMapping("/getRecommendations")
public ResultUtils getRecommendations(@RequestParam String chatType) {
List<PrologueQuestion> questions = prologueService.getRecommendations(chatType);
return ResultUtils.success(questions);
}
@DeleteMapping("/deleteRecommendation")
public ResultUtils deleteRecommendation(@RequestParam Integer id) {
return ResultUtils.success(prologueService.deleteRecommendQuestionById(id));
}
}

View File

@ -0,0 +1,25 @@
package com.bjtds.brichat.entity.sys;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PrologueQuestion {
private Integer id;
// 聊天类型1 表示诊断助手2 表示通用问答...
private String chatType;
// 推荐问题内容
private String questionContent;
// 更新时间
private LocalDateTime updatedAt;
}

View File

@ -0,0 +1,25 @@
package com.bjtds.brichat.entity.sys;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SystemRemark {
private Integer id;
// 聊天类型1 表示诊断助手2 表示通用问答...
private String chatType;
// 开场白内容
private String content;
// 更新时间
private LocalDateTime updatedAt;
}

View File

@ -0,0 +1,19 @@
package com.bjtds.brichat.mapper.opengauss;
import com.bjtds.brichat.entity.sys.PrologueQuestion;
import com.bjtds.brichat.entity.sys.SystemRemark;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface PrologueMapper {
SystemRemark findByChatType(String chatType);
Boolean updateRemark(SystemRemark remark);
List<PrologueQuestion> getQuestionsbyChatType(String chatType);
Boolean deleteQuesById(Integer id);
}

View File

@ -0,0 +1,18 @@
package com.bjtds.brichat.service;
import com.bjtds.brichat.entity.sys.PrologueQuestion;
import com.bjtds.brichat.entity.sys.SystemRemark;
import java.util.List;
public interface PrologueService {
SystemRemark getRemark(String chatType);
Boolean saveOrUpdate(SystemRemark remark);
List<PrologueQuestion> getRecommendations(String chatType);
Boolean deleteRecommendQuestionById(Integer id);
}

View File

@ -0,0 +1,45 @@
package com.bjtds.brichat.service.impl;
import com.bjtds.brichat.entity.sys.PrologueQuestion;
import com.bjtds.brichat.entity.sys.SystemRemark;
import com.bjtds.brichat.mapper.opengauss.PrologueMapper;
import com.bjtds.brichat.service.PrologueService;
import com.netflix.discovery.converters.Auto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
@Slf4j
@Service
public class PrologueServiceImpl implements PrologueService {
@Autowired
private PrologueMapper prologueMapper;
@Override
public SystemRemark getRemark(String chatType) {
return prologueMapper.findByChatType(chatType);
}
@Override
public Boolean saveOrUpdate(SystemRemark remark) {
SystemRemark re = new SystemRemark();
re.setContent(remark.getContent());
re.setChatType(remark.getChatType());
re.setUpdatedAt(LocalDateTime.now());
return prologueMapper.updateRemark(re);
}
@Override
public List<PrologueQuestion> getRecommendations(String chatType) {
return prologueMapper.getQuestionsbyChatType(chatType);
}
@Override
public Boolean deleteRecommendQuestionById(Integer id) {
return prologueMapper.deleteQuesById(id);
}
}

View File

@ -48,4 +48,4 @@ dify:
email: bjtds@bjtds.com # 请替换为实际的 Dify 服务邮箱,若不需要调用 server相关接口可不填
password: 123456Aa # 请替换为实际的 Dify 服务密码,若不需要调用 server相关接口可不填
dataset:
api-key: ${dify-dataset-api-key:dataset-0Hij9IwoWYbJe1vvwVh8y7DS} # 请替换为实际的知识库api-key, 若不需要调用知识库可不填
api-key: ${dify-dataset-api-key:dataset-zVa4uJBUem96P19o8iBtyihQ} # 请替换为实际的知识库api-key, 若不需要调用知识库可不填

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bjtds.brichat.mapper.opengauss.PrologueMapper">
<resultMap id="remarkResultMap" type="com.bjtds.brichat.entity.sys.SystemRemark">
<result column="id" property="id" />
<result column="chat_type" property="chatType" />
<result column="content" property="content" />
<result column="updated_at" property="updatedAt" />
</resultMap>
<resultMap id="RecommendResultMap" type="com.bjtds.brichat.entity.sys.PrologueQuestion">
<result column="id" property="id" />
<result column="chat_type" property="chatType" />
<result column="question_content" property="questionContent" />
<result column="updated_at" property="updatedAt" />
</resultMap>
<update id="updateRemark">
update bripg.t_chat_prologue
set content= #{content} , updated_at =#{updatedAt}
where chat_type = #{chatType}
</update>
<delete id="deleteQuesById">
DELETE FROM bripg.t_chat_recommendations
WHERE id = #{id}
</delete>
<select id="findByChatType" resultMap="remarkResultMap">
SELECT id, chat_type, content, updated_at
FROM bripg.t_chat_prologue
WHERE chat_type = #{chatType}
</select>
<select id="getQuestionsbyChatType" resultMap="RecommendResultMap">
SELECT * FROM bripg.t_chat_recommendations
WHERE chat_type = #{chatType}
</select>
</mapper>

View File

@ -13,7 +13,7 @@ spring:
# url: jdbc:opengauss://${db-host:192.168.8.241}:${db-port:15000}/${db-name:bridb}
# username: ${db-username:bripg}
# password: ${db-passwd:Chuangrui139*}
url: jdbc:opengauss://${db-host:192.168.8.253}:${db-port:6600}/${db-name:bridb}
url: jdbc:opengauss://${db-host:192.168.1.211}:${db-port:6600}/${db-name:bridb}
username: ${db-username:bripg}
password: ${db-passwd:Chuangrui139*}
servlet:

View File

@ -17,7 +17,7 @@ spring:
# password: ${db-passwd:Chuangrui139*}
#
#pg版本
url: jdbc:opengauss://${db-host:192.168.8.253}:${db-port:6600}/${db-name:bridb}
url: jdbc:opengauss://${db-host:192.168.1.211}:${db-port:6600}/${db-name:bridb}
username: ${db-username:bripg}
password: ${db-passwd:Chuangrui139*}
# hikari: