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

@ -30,7 +30,7 @@ const ChunkCreatingModal: React.FC<IModalProps<any> & kFProps> = ({
const { t } = useTranslation();
useEffect(() => {
if (data?.retcode === 0) {
if (data?.code === 0) {
const { content_with_weight, important_kwd = [] } = data.data;
form.setFieldsValue({ content: content_with_weight });
setKeywords(important_kwd);

View File

@ -96,14 +96,14 @@ export const useUpdateChunk = () => {
const onChunkUpdatingOk = useCallback(
async ({ content, keywords }: { content: string; keywords: string }) => {
const retcode = await createChunk({
const code = await createChunk({
content_with_weight: content,
doc_id: documentId,
chunk_id: chunkId,
important_kwd: keywords, // keywords
});
if (retcode === 0) {
if (code === 0) {
hideChunkUpdatingModal();
}
},

View File

@ -148,20 +148,20 @@ export const useHandleUploadDocument = () => {
async (fileList: UploadFile[]): Promise<number | undefined> => {
if (fileList.length > 0) {
const ret: any = await uploadDocument(fileList);
if (typeof ret?.retmsg !== 'string') {
if (typeof ret?.message !== 'string') {
return;
}
const count = getUnSupportedFilesCount(ret?.retmsg);
const count = getUnSupportedFilesCount(ret?.message);
/// 500 error code indicates that some file types are not supported
let retcode = ret?.retcode;
let code = ret?.code;
if (
ret?.retcode === 0 ||
(ret?.retcode === 500 && count !== fileList.length) // Some files were not uploaded successfully, but some were uploaded successfully.
ret?.code === 0 ||
(ret?.code === 500 && count !== fileList.length) // Some files were not uploaded successfully, but some were uploaded successfully.
) {
retcode = 0;
code = 0;
hideDocumentUploadModal();
}
return retcode;
return code;
}
},
[uploadDocument, hideDocumentUploadModal],