feat: 通用问答页面
This commit is contained in:
parent
9897dd9551
commit
0c6ca10438
|
|
@ -194,7 +194,12 @@ const handleAddSubmit = async () => {
|
||||||
// Authorization: `Bearer ${localStorage.getItem('datasetsKey')}`,
|
// 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'))
|
ElMessage.success(t('vabI18n.knowledge.dialog.createSuccess'))
|
||||||
addFormVisible.value = false
|
addFormVisible.value = false
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.bjtds.brichat.controller;
|
||||||
|
|
||||||
|
|
||||||
import com.bjtds.brichat.entity.dataset.DatasetUpdateReq;
|
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.dataset.TUserDataset;
|
||||||
import com.bjtds.brichat.entity.dify.DatasetDto;
|
import com.bjtds.brichat.entity.dify.DatasetDto;
|
||||||
import com.bjtds.brichat.entity.dto.UserBindDatasetDto;
|
import com.bjtds.brichat.entity.dto.UserBindDatasetDto;
|
||||||
|
|
@ -20,6 +21,9 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@Api(tags = "知识库管理")
|
@Api(tags = "知识库管理")
|
||||||
|
|
@ -46,14 +50,14 @@ public class DatasetManageController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前用户可访问的知识库
|
* 获取当前用户可访问的知识库
|
||||||
|
*
|
||||||
* @param pageNo
|
* @param pageNo
|
||||||
* @param pageSize
|
* @param pageSize
|
||||||
* @param userId
|
* @param userId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/currUserDatasets")
|
@GetMapping("/currUserDatasets")
|
||||||
public Pagination<TUserDataset> getCurrUserDatasets(
|
public Pagination<TUserDataset> getCurrUserDatasets(@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
|
||||||
@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
|
|
||||||
@RequestParam(value = "pageSize", required = false, defaultValue = "9") Integer pageSize,
|
@RequestParam(value = "pageSize", required = false, defaultValue = "9") Integer pageSize,
|
||||||
@RequestParam(value = "userId", required = false, defaultValue = "") Long userId) {
|
@RequestParam(value = "userId", required = false, defaultValue = "") Long userId) {
|
||||||
return datasetManagerService.getCurrUserDatasets(pageNo, pageSize, userId);
|
return datasetManagerService.getCurrUserDatasets(pageNo, pageSize, userId);
|
||||||
|
|
@ -61,12 +65,13 @@ public class DatasetManageController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除知识库
|
* 删除知识库
|
||||||
|
*
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public void delete(@PathVariable String id) {
|
public void delete(@PathVariable String id) {
|
||||||
|
|
||||||
//TODO 解绑与该知识库相关的用户
|
// 解绑与该知识库相关的用户
|
||||||
datasetManagerService.deleteDataset(id);
|
datasetManagerService.deleteDataset(id);
|
||||||
|
|
||||||
difyDatasetService.delete(id);
|
difyDatasetService.delete(id);
|
||||||
|
|
@ -81,8 +86,8 @@ public class DatasetManageController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public ResultUtils create(@RequestBody DatasetCreateRequest datasetCreateRequest) {
|
public ResultUtils create(@RequestBody DatasetsCreateReq req) {
|
||||||
ResponseEntity<DatasetDto>res = difyDatasetApiService.createDataset(datasetCreateRequest.getName(), datasetCreateRequest.getDescription());
|
ResponseEntity<DatasetDto> res = difyDatasetApiService.createDataset(req.getName(), req.getDescription());
|
||||||
DatasetDto datasetDto = res.getBody();
|
DatasetDto datasetDto = res.getBody();
|
||||||
String datasetId = datasetDto.getId();
|
String datasetId = datasetDto.getId();
|
||||||
//构建es索引
|
//构建es索引
|
||||||
|
|
@ -93,6 +98,8 @@ public class DatasetManageController {
|
||||||
log.error("创建es索引失败,知识库id:{}", datasetId, e);
|
log.error("创建es索引失败,知识库id:{}", datasetId, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//添加知识库与用户关联关系
|
||||||
|
datasetManagerService.userBindDatasets(UserBindDatasetDto.builder().userId(req.getUserId()).datasetIds(Arrays.asList(datasetId)).build());
|
||||||
return ResultUtils.success(res.getBody());
|
return ResultUtils.success(res.getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,9 +115,9 @@ public class DatasetManageController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户和知识库关联列表
|
* 获取用户和知识库关联列表
|
||||||
|
*
|
||||||
* @param pageNo
|
* @param pageNo
|
||||||
* @param pageSize
|
* @param pageSize
|
||||||
* @param nameFilter
|
* @param nameFilter
|
||||||
|
|
@ -120,13 +127,11 @@ public class DatasetManageController {
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@GetMapping("/usersLinkDataset")
|
@GetMapping("/usersLinkDataset")
|
||||||
public com.bjtds.common.utils.Pagination<UserLinkDatasetDto> getUsersLinkDatasetList(
|
public com.bjtds.common.utils.Pagination<UserLinkDatasetDto> getUsersLinkDatasetList(@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
|
||||||
@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
|
|
||||||
@RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize,
|
@RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize,
|
||||||
@RequestParam(value = "nameFilter", required = false, defaultValue = "") String nameFilter,
|
@RequestParam(value = "nameFilter", required = false, defaultValue = "") String nameFilter,
|
||||||
@RequestParam(value = "deptFilter", required = false, defaultValue = "") String deptFilter,
|
@RequestParam(value = "deptFilter", required = false, defaultValue = "") String deptFilter,
|
||||||
@RequestParam(value = "roleFilter", required = false, defaultValue = "") String roleFilter
|
@RequestParam(value = "roleFilter", required = false, defaultValue = "") String roleFilter) throws Exception {
|
||||||
) throws Exception{
|
|
||||||
return datasetManagerService.getUserLinkDatasetsList(pageNo, pageSize, nameFilter, deptFilter, roleFilter);
|
return datasetManagerService.getUserLinkDatasetsList(pageNo, pageSize, nameFilter, deptFilter, roleFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -163,6 +168,4 @@ public class DatasetManageController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,24 +9,39 @@ import lombok.Getter;
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum ChatTypeVo {
|
public enum ChatTypeVo {
|
||||||
/**故障诊断问答*/
|
/**
|
||||||
|
* 故障诊断问答
|
||||||
|
*/
|
||||||
diagnose(1, "diagnose", "故障诊断问答"),
|
diagnose(1, "diagnose", "故障诊断问答"),
|
||||||
|
|
||||||
/**通用问答/智能问答*/
|
/**
|
||||||
|
* 通用问答/智能问答
|
||||||
|
*/
|
||||||
intelQa(2, "intelQa", "智能问答"),
|
intelQa(2, "intelQa", "智能问答"),
|
||||||
|
|
||||||
/**图形报表问答*/
|
/**
|
||||||
|
* 图形报表问答
|
||||||
|
*/
|
||||||
chartReport(3, "chartReport", "图形报表问答"),
|
chartReport(3, "chartReport", "图形报表问答"),
|
||||||
|
|
||||||
/**应急助手问答*/
|
/**
|
||||||
|
* 应急助手问答
|
||||||
|
*/
|
||||||
emerg(4, "emerg", "应急助手问答"),
|
emerg(4, "emerg", "应急助手问答"),
|
||||||
|
|
||||||
/**诊断代码查询**/
|
/**
|
||||||
|
* 诊断代码查询
|
||||||
|
**/
|
||||||
codeQuery(5, "codeQuery", "诊断代码查询"),
|
codeQuery(5, "codeQuery", "诊断代码查询"),
|
||||||
/**
|
/**
|
||||||
* 一事一流程数据处理
|
* 一事一流程数据处理
|
||||||
*/
|
*/
|
||||||
ysylcDataProc(6,"ysylcDataProc","一事一流程数据处理");
|
ysylcDataProc(6, "ysylcDataProc", "一事一流程数据处理"),
|
||||||
|
|
||||||
|
/***
|
||||||
|
*通用问答
|
||||||
|
*/
|
||||||
|
commQA(7, "commQA", "通用问答");
|
||||||
|
|
||||||
private final int code;
|
private final int code;
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
package com.bjtds.brichat.entity.dto;
|
package com.bjtds.brichat.entity.dto;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@Builder
|
||||||
public class UserBindDatasetDto {
|
public class UserBindDatasetDto {
|
||||||
|
|
||||||
private Long userId;
|
private Long userId;
|
||||||
private List<String> datasetIds;
|
private List<String> datasetIds;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue