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

@@ -151,7 +151,7 @@ export const useSendMessage = (
const res = await send(params);
if (receiveMessageError(res)) {
antMessage.error(res?.data?.retmsg);
antMessage.error(res?.data?.message);
// cancel loading
setValue(message.content);
@@ -227,7 +227,7 @@ export const useSendNextMessage = () => {
const res = await send(params);
if (receiveMessageError(res)) {
antMessage.error(res?.data?.retmsg);
antMessage.error(res?.data?.message);
// cancel loading
setValue(message.content);

View File

@@ -497,15 +497,15 @@ export const useSaveGraphBeforeOpeningDebugDrawer = (show: () => void) => {
const { send } = useSendMessageWithSse(api.runCanvas);
const handleRun = useCallback(async () => {
const saveRet = await saveGraph();
if (saveRet?.retcode === 0) {
if (saveRet?.code === 0) {
// Call the reset api before opening the run drawer each time
const resetRet = await resetFlow();
// After resetting, all previous messages will be cleared.
if (resetRet?.retcode === 0) {
if (resetRet?.code === 0) {
// fetch prologue
const sendRet = await send({ id });
if (receiveMessageError(sendRet)) {
message.error(sendRet?.data?.retmsg);
message.error(sendRet?.data?.message);
} else {
refetch();
show();

View File

@@ -53,7 +53,7 @@ export const useSaveFlow = () => {
// },
});
if (ret?.retcode === 0) {
if (ret?.code === 0) {
hideFlowSettingModal();
navigate(`/flow/${ret.data.id}`);
}

View File

@@ -144,7 +144,7 @@ export const buildDslComponentsByGraph = (
};
export const receiveMessageError = (res: any) =>
res && (res?.response.status !== 200 || res?.data?.retcode !== 0);
res && (res?.response.status !== 200 || res?.data?.code !== 0);
// Replace the id in the object with text
export const replaceIdWithText = (