mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-29 04:08:12 +08:00
Refactor: Consolidation WEB API & HTTP API for document delete api (#14254)
### What problem does this PR solve? Before consolidation Web API: POST /v1/document/rm Http API - DELETE /api/v1/datasets/<dataset_id>/documents After consolidation, Restful API -- DELETE /api/v1/datasets/<dataset_id>/documents ### Type of change - [x] Refactoring
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
import i18n from '@/locales/config';
|
||||
import { EMPTY_METADATA_FIELD } from '@/pages/dataset/dataset/use-select-filters';
|
||||
import kbService, {
|
||||
deleteDocument,
|
||||
documentFilter,
|
||||
listDocument,
|
||||
renameDocument,
|
||||
@@ -315,6 +316,7 @@ export const useRunDocument = () => {
|
||||
|
||||
export const useRemoveDocument = () => {
|
||||
const queryClient = useQueryClient();
|
||||
const { id: datasetId } = useParams();
|
||||
const {
|
||||
data,
|
||||
isPending: loading,
|
||||
@@ -322,7 +324,8 @@ export const useRemoveDocument = () => {
|
||||
} = useMutation({
|
||||
mutationKey: [DocumentApiAction.RemoveDocument],
|
||||
mutationFn: async (documentIds: string | string[]) => {
|
||||
const { data } = await kbService.documentRm({ doc_id: documentIds });
|
||||
const ids = Array.isArray(documentIds) ? documentIds : [documentIds];
|
||||
const { data } = await deleteDocument(datasetId!, ids);
|
||||
if (data.code === 0) {
|
||||
message.success(i18n.t('message.deleted'));
|
||||
queryClient.invalidateQueries({
|
||||
@@ -435,7 +438,7 @@ export const useSetDocumentMeta = () => {
|
||||
}
|
||||
return data?.code;
|
||||
} catch (error) {
|
||||
message.error('error');
|
||||
message.error('error:' + error);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -18,8 +18,6 @@ const {
|
||||
kbList,
|
||||
getDocumentList,
|
||||
documentChangeStatus,
|
||||
documentRm,
|
||||
documentDelete,
|
||||
documentCreate,
|
||||
documentChangeParser,
|
||||
documentThumbnails,
|
||||
@@ -72,10 +70,6 @@ const methods = {
|
||||
url: documentChangeStatus,
|
||||
method: 'post',
|
||||
},
|
||||
documentRm: {
|
||||
url: documentRm,
|
||||
method: 'post',
|
||||
},
|
||||
documentCreate: {
|
||||
url: documentCreate,
|
||||
method: 'post',
|
||||
@@ -137,10 +131,6 @@ const methods = {
|
||||
url: knowledgeGraph,
|
||||
method: 'get',
|
||||
},
|
||||
documentDelete: {
|
||||
url: documentDelete,
|
||||
method: 'delete',
|
||||
},
|
||||
listTagByKnowledgeIds: {
|
||||
url: listTagByKnowledgeIds,
|
||||
method: 'get',
|
||||
@@ -276,6 +266,9 @@ export const renameDocument = (
|
||||
data: { name?: string },
|
||||
) => request.patch(api.documentRename(datasetId, documentId), { data });
|
||||
|
||||
export const deleteDocument = (datasetId: string, documentIds: string[]) =>
|
||||
request.delete(api.documentDelete(datasetId), { data: { ids: documentIds } });
|
||||
|
||||
export const getMetaDataService = ({
|
||||
kb_id,
|
||||
doc_ids,
|
||||
|
||||
@@ -109,8 +109,8 @@ export default {
|
||||
getDocumentList: (datasetId: string) =>
|
||||
`${restAPIv1}/datasets/${datasetId}/documents`,
|
||||
documentChangeStatus: `${webAPI}/document/change_status`,
|
||||
documentRm: `${webAPI}/document/rm`,
|
||||
documentDelete: `${webAPI}/api/document`,
|
||||
documentDelete: (datasetId: string) =>
|
||||
`${restAPIv1}/datasets/${datasetId}/documents`,
|
||||
documentRename: (datasetId: string, documentId: string) =>
|
||||
`${restAPIv1}/datasets/${datasetId}/documents/${documentId}`,
|
||||
documentCreate: `${webAPI}/document/create`,
|
||||
|
||||
Reference in New Issue
Block a user