Unified API response json schema (#3170)

### What problem does this PR solve?

Unified API response json schema

### Type of change

- [x] Refactoring
This commit is contained in:
Zhichang Yu
2024-11-05 11:02:31 +08:00
committed by GitHub
parent 339639a9db
commit 185c6a0c71
53 changed files with 1458 additions and 1470 deletions

View File

@ -57,7 +57,7 @@ export const useFetchNextChunkList = (): ResponseGetType<{
available_int: available,
keywords: searchString,
});
if (data.retcode === 0) {
if (data.code === 0) {
const res = data.data;
return {
data: res.chunks,
@ -126,11 +126,11 @@ export const useDeleteChunk = () => {
mutationKey: ['deleteChunk'],
mutationFn: async (params: { chunkIds: string[]; doc_id: string }) => {
const { data } = await kbService.rm_chunk(params);
if (data.retcode === 0) {
if (data.code === 0) {
setPaginationParams(1);
queryClient.invalidateQueries({ queryKey: ['fetchChunkList'] });
}
return data?.retcode;
return data?.code;
},
});
@ -152,11 +152,11 @@ export const useSwitchChunk = () => {
doc_id: string;
}) => {
const { data } = await kbService.switch_chunk(params);
if (data.retcode === 0) {
if (data.code === 0) {
message.success(t('message.modified'));
queryClient.invalidateQueries({ queryKey: ['fetchChunkList'] });
}
return data?.retcode;
return data?.code;
},
});
@ -179,11 +179,11 @@ export const useCreateChunk = () => {
service = kbService.set_chunk;
}
const { data } = await service(payload);
if (data.retcode === 0) {
if (data.code === 0) {
message.success(t('message.created'));
queryClient.invalidateQueries({ queryKey: ['fetchChunkList'] });
}
return data?.retcode;
return data?.code;
},
});