mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 01:48:04 +08:00
feat: document update change to batch api
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
import {
|
||||
useMutation,
|
||||
useQuery,
|
||||
} from '@tanstack/react-query'
|
||||
import { get } from '../base'
|
||||
import type { SimpleDocumentDetail } from '@/models/datasets'
|
||||
import { get, patch } from '../base'
|
||||
import type { SimpleDocumentDetail, UpdateDocumentBatchParams } from '@/models/datasets'
|
||||
import type { CommonResponse } from '@/models/common'
|
||||
|
||||
const NAME_SPACE = 'knowledge/document'
|
||||
|
||||
@ -23,3 +25,15 @@ export const useDocumentList = (payload: {
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
const toBatchDocumentsIdParams = (documentIds: string[]) => {
|
||||
return documentIds.map(id => `document_id=${id}`).join('=')
|
||||
}
|
||||
|
||||
export const useDocumentBatchAction = () => {
|
||||
return useMutation({
|
||||
mutationFn: ({ action, datasetId, documentIds }: UpdateDocumentBatchParams) => {
|
||||
return patch<CommonResponse>(`/datasets/${datasetId}/documents/status/${action}?${toBatchDocumentsIdParams(documentIds)}`)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user