统一删除文件索引和删除文件接口,全在后端运行
This commit is contained in:
parent
e48671fb48
commit
81ccde15f5
|
|
@ -1226,13 +1226,6 @@ try {
|
||||||
|
|
||||||
// 调用删除接口
|
// 调用删除接口
|
||||||
await deleteDocument(parseInt(row.id))
|
await deleteDocument(parseInt(row.id))
|
||||||
try{
|
|
||||||
//删除es索引
|
|
||||||
await deleteFileIndex(row.difyDocId,datasetId.value)
|
|
||||||
console.log("删除es索引成功,文档id:{}",row.difyDocId)
|
|
||||||
} catch (error) {
|
|
||||||
console.error("删除es索引失败,文档id:{}",row.difyDocId,error)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 成功处理
|
// 成功处理
|
||||||
ElNotification({
|
ElNotification({
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import com.bjtds.brichat.entity.dto.PdfTaskDto;
|
||||||
import com.bjtds.brichat.service.DatasetFilesService;
|
import com.bjtds.brichat.service.DatasetFilesService;
|
||||||
import com.bjtds.brichat.service.DatasetsDocService;
|
import com.bjtds.brichat.service.DatasetsDocService;
|
||||||
import com.bjtds.brichat.service.DeepAnalysisQueueService;
|
import com.bjtds.brichat.service.DeepAnalysisQueueService;
|
||||||
|
import com.bjtds.brichat.service.EsTDatasetFilesService;
|
||||||
import com.bjtds.brichat.service.dify.DifyDatasetApiService;
|
import com.bjtds.brichat.service.dify.DifyDatasetApiService;
|
||||||
import com.bjtds.brichat.util.Constants;
|
import com.bjtds.brichat.util.Constants;
|
||||||
import com.bjtds.brichat.util.ResultUtils;
|
import com.bjtds.brichat.util.ResultUtils;
|
||||||
|
|
@ -27,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -70,6 +72,9 @@ public class DatasetDocController {
|
||||||
@Resource
|
@Resource
|
||||||
private DeepAnalysisQueueService deepAnalysisQueueService;
|
private DeepAnalysisQueueService deepAnalysisQueueService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EsTDatasetFilesService esTDatasetFilesService;
|
||||||
|
|
||||||
|
|
||||||
@Value("${dify.url}")
|
@Value("${dify.url}")
|
||||||
private String difyUrl;
|
private String difyUrl;
|
||||||
|
|
@ -137,9 +142,14 @@ public class DatasetDocController {
|
||||||
for (TDatasetFiles tdatasetFiles : allFilesByParentId) {
|
for (TDatasetFiles tdatasetFiles : allFilesByParentId) {
|
||||||
if(tdatasetFiles.getDifyDocId() != null && !tdatasetFiles.getDifyDocId().isEmpty()){
|
if(tdatasetFiles.getDifyDocId() != null && !tdatasetFiles.getDifyDocId().isEmpty()){
|
||||||
difyDatasetService.deleteDocument(tdatasetFiles.getDifyDatasetId(),tdatasetFiles.getDifyDocId());
|
difyDatasetService.deleteDocument(tdatasetFiles.getDifyDatasetId(),tdatasetFiles.getDifyDocId());
|
||||||
|
//删除es索引
|
||||||
|
try{
|
||||||
|
esTDatasetFilesService.deleteDocIndex(tdatasetFiles.getDifyDatasetId(),tdatasetFiles.getDifyDocId());
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("删除es索引失败,文档id:{}",tdatasetFiles.getDifyDocId(),e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
datasetFilesService.physicalDeleteFile(tdatasetFiles.getId());
|
datasetFilesService.physicalDeleteFile(tdatasetFiles.getId());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -147,7 +157,14 @@ public class DatasetDocController {
|
||||||
datasetFilesService.deleteFile(fileId);
|
datasetFilesService.deleteFile(fileId);
|
||||||
} else{
|
} else{
|
||||||
if(fileInfo.getDifyDocId() != null && !fileInfo.getDifyDocId().isEmpty()){
|
if(fileInfo.getDifyDocId() != null && !fileInfo.getDifyDocId().isEmpty()){
|
||||||
|
|
||||||
difyDatasetService.deleteDocument(fileInfo.getDifyDatasetId(),fileInfo.getDifyDocId());
|
difyDatasetService.deleteDocument(fileInfo.getDifyDatasetId(),fileInfo.getDifyDocId());
|
||||||
|
//删除es索引
|
||||||
|
try{
|
||||||
|
esTDatasetFilesService.deleteDocIndex(fileInfo.getDifyDatasetId(),fileInfo.getDifyDocId());
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("删除es索引失败,文档id:{}",fileInfo.getDifyDocId(),e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
datasetFilesService.physicalDeleteFile(fileId);
|
datasetFilesService.physicalDeleteFile(fileId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -141,16 +141,16 @@ public class KnowledgeBaseController {
|
||||||
result.put("finished", finished);
|
result.put("finished", finished);
|
||||||
return ResultUtils.success(result);
|
return ResultUtils.success(result);
|
||||||
}
|
}
|
||||||
@ApiOperation("删除索引下的文件")
|
// @ApiOperation("删除索引下的文件")
|
||||||
@DeleteMapping("/deleteFileIndex")
|
// @DeleteMapping("/deleteFileIndex")
|
||||||
public ResultUtils deleteFileIndex(@RequestParam("documentId") String documentId,@RequestParam("datasetId")String datasetId) throws Exception {
|
// public ResultUtils deleteFileIndex(@RequestParam("documentId") String documentId,@RequestParam("datasetId")String datasetId) throws Exception {
|
||||||
try{
|
// try{
|
||||||
esTDatasetFilesService.deleteDocIndex(datasetId,documentId);
|
// esTDatasetFilesService.deleteDocIndex(datasetId,documentId);
|
||||||
return ResultUtils.success("索引删除成功");
|
// return ResultUtils.success("索引删除成功");
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
return ResultUtils.error("索引删除失败: " + e.getMessage());
|
// return ResultUtils.error("索引删除失败: " + e.getMessage());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
@ApiOperation("删除所有索引")
|
@ApiOperation("删除所有索引")
|
||||||
@DeleteMapping("/deleteAllIndex")
|
@DeleteMapping("/deleteAllIndex")
|
||||||
public ResultUtils deleteAllIndex() throws Exception {
|
public ResultUtils deleteAllIndex() throws Exception {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue