mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-11 14:15:40 +08:00
Refactor: Migrate document metadata config update API (#14286)
### What problem does this PR solve? Before migration Web API: POST /v1/document/update_metadata_setting After consolidation, Restful API PUT /api/v1/datasets/<dataset_id>/documents/<document_id>/metadata/config ### Type of change - [x] Refactoring
This commit is contained in:
@@ -4,6 +4,7 @@ import { useSelectedIds } from '@/hooks/logic-hooks/use-row-selection';
|
||||
import { DocumentApiAction } from '@/hooks/use-document-request';
|
||||
import kbService, {
|
||||
getMetaDataService,
|
||||
updateDocumentMetaDataConfig,
|
||||
updateMetaData,
|
||||
} from '@/services/knowledge-service';
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
@@ -432,10 +433,14 @@ export const useManageMetaDataModal = (
|
||||
const handleSaveSingleFileSettings = useCallback(
|
||||
async (callback: () => void) => {
|
||||
const data = util.tableDataToMetaDataSettingJSON(tableData);
|
||||
if (otherData?.documentId) {
|
||||
const { data: res } = await kbService.documentUpdateMetaData({
|
||||
// otherData contains: documentId
|
||||
if (otherData?.documentId && id) {
|
||||
const { data: res } = await updateDocumentMetaDataConfig({
|
||||
kb_id: id,
|
||||
doc_id: otherData.documentId,
|
||||
metadata: data,
|
||||
data: {
|
||||
metadata: data,
|
||||
},
|
||||
});
|
||||
if (res.code === 0) {
|
||||
message.success(t('message.operated'));
|
||||
|
||||
@@ -41,7 +41,6 @@ const {
|
||||
fetchPipelineDatasetLogs,
|
||||
checkEmbedding,
|
||||
kbUpdateMetaData,
|
||||
documentUpdateMetaData,
|
||||
} = api;
|
||||
|
||||
const methods = {
|
||||
@@ -177,14 +176,6 @@ const methods = {
|
||||
url: kbUpdateMetaData,
|
||||
method: 'post',
|
||||
},
|
||||
documentUpdateMetaData: {
|
||||
url: documentUpdateMetaData,
|
||||
method: 'post',
|
||||
},
|
||||
// getMetaData: {
|
||||
// url: getMetaData,
|
||||
// method: 'get',
|
||||
// },
|
||||
};
|
||||
|
||||
const kbService = registerServer<keyof typeof methods>(methods, request);
|
||||
@@ -289,6 +280,19 @@ export const updateMetaData = ({
|
||||
data: any;
|
||||
}) => request.post(api.updateMetaData, { data: { kb_id, doc_ids, ...data } });
|
||||
|
||||
export const updateDocumentMetaDataConfig = ({
|
||||
kb_id,
|
||||
doc_id,
|
||||
data,
|
||||
}: {
|
||||
kb_id: string;
|
||||
doc_id: string;
|
||||
data: any;
|
||||
}) =>
|
||||
request.put(api.documentUpdateMetaDataConfig(kb_id, doc_id), {
|
||||
data: { ...data },
|
||||
});
|
||||
|
||||
export const listDataPipelineLogDocument = (
|
||||
params?: IFetchKnowledgeListRequestParams,
|
||||
body?: IFetchDocumentListRequestBody,
|
||||
|
||||
@@ -87,7 +87,8 @@ export default {
|
||||
`${restAPIv1}/datasets/${datasetId}/metadata/summary`,
|
||||
updateMetaData: `${webAPI}/document/metadata/update`,
|
||||
kbUpdateMetaData: `${webAPI}/kb/update_metadata_setting`,
|
||||
documentUpdateMetaData: `${webAPI}/document/update_metadata_setting`,
|
||||
documentUpdateMetaDataConfig: (datasetId: string, documentId: string) =>
|
||||
`${restAPIv1}/datasets/${datasetId}/documents/${documentId}/metadata/config`,
|
||||
|
||||
// tags
|
||||
listTag: (knowledgeId: string) => `${webAPI}/kb/${knowledgeId}/tags`,
|
||||
|
||||
Reference in New Issue
Block a user