feat: 通用问答页面

This commit is contained in:
wenjinbo 2025-10-11 14:04:57 +08:00
parent 9897dd9551
commit 0c6ca10438
5 changed files with 74 additions and 36 deletions

View File

@ -194,7 +194,12 @@ const handleAddSubmit = async () => {
// Authorization: `Bearer ${localStorage.getItem('datasetsKey')}`,
// },
// })
await createDataset(addForm.value)
const aclStore = useAclStore()
const userId = aclStore.userId
await createDataset({
...addForm.value,
userId
})
ElMessage.success(t('vabI18n.knowledge.dialog.createSuccess'))
addFormVisible.value = false

View File

@ -2,6 +2,7 @@ package com.bjtds.brichat.controller;
import com.bjtds.brichat.entity.dataset.DatasetUpdateReq;
import com.bjtds.brichat.entity.dataset.DatasetsCreateReq;
import com.bjtds.brichat.entity.dataset.TUserDataset;
import com.bjtds.brichat.entity.dify.DatasetDto;
import com.bjtds.brichat.entity.dto.UserBindDatasetDto;
@ -20,6 +21,9 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@Api(tags = "知识库管理")
@ -46,14 +50,14 @@ public class DatasetManageController {
/**
* 获取当前用户可访问的知识库
*
* @param pageNo
* @param pageSize
* @param userId
* @return
*/
@GetMapping("/currUserDatasets")
public Pagination<TUserDataset> getCurrUserDatasets(
@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
public Pagination<TUserDataset> getCurrUserDatasets(@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", required = false, defaultValue = "9") Integer pageSize,
@RequestParam(value = "userId", required = false, defaultValue = "") Long userId) {
return datasetManagerService.getCurrUserDatasets(pageNo, pageSize, userId);
@ -61,12 +65,13 @@ public class DatasetManageController {
/**
* 删除知识库
*
* @param id
*/
@DeleteMapping("/{id}")
public void delete(@PathVariable String id) {
//TODO 解绑与该知识库相关的用户
// 解绑与该知识库相关的用户
datasetManagerService.deleteDataset(id);
difyDatasetService.delete(id);
@ -81,8 +86,8 @@ public class DatasetManageController {
}
@PostMapping("/create")
public ResultUtils create(@RequestBody DatasetCreateRequest datasetCreateRequest) {
ResponseEntity<DatasetDto>res = difyDatasetApiService.createDataset(datasetCreateRequest.getName(), datasetCreateRequest.getDescription());
public ResultUtils create(@RequestBody DatasetsCreateReq req) {
ResponseEntity<DatasetDto> res = difyDatasetApiService.createDataset(req.getName(), req.getDescription());
DatasetDto datasetDto = res.getBody();
String datasetId = datasetDto.getId();
//构建es索引
@ -93,6 +98,8 @@ public class DatasetManageController {
log.error("创建es索引失败,知识库id:{}", datasetId, e);
}
//添加知识库与用户关联关系
datasetManagerService.userBindDatasets(UserBindDatasetDto.builder().userId(req.getUserId()).datasetIds(Arrays.asList(datasetId)).build());
return ResultUtils.success(res.getBody());
}
@ -108,9 +115,9 @@ public class DatasetManageController {
}
/**
* 获取用户和知识库关联列表
*
* @param pageNo
* @param pageSize
* @param nameFilter
@ -120,13 +127,11 @@ public class DatasetManageController {
* @throws Exception
*/
@GetMapping("/usersLinkDataset")
public com.bjtds.common.utils.Pagination<UserLinkDatasetDto> getUsersLinkDatasetList(
@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
public com.bjtds.common.utils.Pagination<UserLinkDatasetDto> getUsersLinkDatasetList(@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize,
@RequestParam(value = "nameFilter", required = false, defaultValue = "") String nameFilter,
@RequestParam(value = "deptFilter", required = false, defaultValue = "") String deptFilter,
@RequestParam(value = "roleFilter", required = false, defaultValue = "") String roleFilter
) throws Exception{
@RequestParam(value = "roleFilter", required = false, defaultValue = "") String roleFilter) throws Exception {
return datasetManagerService.getUserLinkDatasetsList(pageNo, pageSize, nameFilter, deptFilter, roleFilter);
}
@ -163,6 +168,4 @@ public class DatasetManageController {
}
}

View File

@ -9,24 +9,39 @@ import lombok.Getter;
@Getter
@AllArgsConstructor
public enum ChatTypeVo {
/**故障诊断问答*/
/**
* 故障诊断问答
*/
diagnose(1, "diagnose", "故障诊断问答"),
/**通用问答/智能问答*/
/**
* 通用问答/智能问答
*/
intelQa(2, "intelQa", "智能问答"),
/**图形报表问答*/
/**
* 图形报表问答
*/
chartReport(3, "chartReport", "图形报表问答"),
/**应急助手问答*/
/**
* 应急助手问答
*/
emerg(4, "emerg", "应急助手问答"),
/**诊断代码查询**/
/**
* 诊断代码查询
**/
codeQuery(5, "codeQuery", "诊断代码查询"),
/**
* 一事一流程数据处理
*/
ysylcDataProc(6,"ysylcDataProc","一事一流程数据处理");
ysylcDataProc(6, "ysylcDataProc", "一事一流程数据处理"),
/***
*通用问答
*/
commQA(7, "commQA", "通用问答");
private final int code;
private final String name;

View File

@ -0,0 +1,11 @@
package com.bjtds.brichat.entity.dataset;
import lombok.Data;
@Data
public class DatasetsCreateReq {
private String name;
private String description;
private Long userId;
}

View File

@ -1,10 +1,14 @@
package com.bjtds.brichat.entity.dto;
import lombok.Builder;
import lombok.Data;
import java.util.List;
@Data
@Builder
public class UserBindDatasetDto {
private Long userId;
private List<String> datasetIds;
}