Skip to content

Commit

Permalink
s This is the 1st commit message: (#233)
Browse files Browse the repository at this point in the history
fix: fix response type

mod: code review
  • Loading branch information
hetao92 authored May 30, 2022
1 parent 5601db9 commit 1a5f420
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 21 deletions.
4 changes: 2 additions & 2 deletions app/pages/Import/FileUpload/FileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import Icon from '@app/components/Icon';
import CSVPreviewLink from '@app/components/CSVPreviewLink';
import { getFileSize } from '@app/utils/file';
import cls from 'classnames';
import styles from './index.module.less';
import { StudioFile } from '@app/interfaces/import';
import styles from './index.module.less';
interface IProps {
fileList: any[];
onDelete: (index: number) => void;
Expand Down Expand Up @@ -36,7 +36,7 @@ const FileList = (props: IProps) => {
key: 'operation',
render: (_, file, index) => {
if(!file.content) {
return null
return null;
}
return (
<div className={styles.operation}>
Expand Down
2 changes: 1 addition & 1 deletion app/stores/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class FilesStore {
const { code, data } = (await service.getFiles()) as any;
if (code === 0 && data) {
this.update({
fileList: data,
fileList: data.list || [],
});
}
};
Expand Down
24 changes: 12 additions & 12 deletions app/utils/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,25 @@ service.interceptors.request.use(config => {

service.interceptors.response.use(
(response: any) => {

// const isExecReq = /api-nebula\/db\/(exec|batchExec)$/.test(response.config?.url);
if (response.data?.data?.data && Object.keys(response.data.data).length === 1) {
response.data.data = response.data.data.data;
}
return response.data;
},
(error: any) => {
if (error.response?.status) {
message.error(
`${intl.get('common.requestError')}: ${error.response.status} ${
error.response.statusText
}`,
);
const res = error.response.data || {};
if(res.code !== 0 && res.message) {
message.error(res.message);
} else {
message.error(
`${intl.get('common.requestError')}: ${error.response.status} ${
error.response.statusText
}`,
);
}
// relogin
if (error.response.data?.code === HttpResCode.ErrSession) {
if (res.code === HttpResCode.ErrSession) {
getRootStore().global.logout();
}
return error.response.data;
return res;
} else {
message.error(`${intl.get('common.requestError')}: ${error}`);
return error;
Expand Down
5 changes: 3 additions & 2 deletions server/api/studio/internal/service/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

"github.com/vesoft-inc/go-pkg/middleware"
"github.com/vesoft-inc/go-pkg/response"
"github.com/vesoft-inc/nebula-http-gateway/ccore/nebula/gateway/dao"
"github.com/vesoft-inc/nebula-studio/server-v2/api/studio/internal/svc"
"github.com/vesoft-inc/nebula-studio/server-v2/api/studio/internal/types"
Expand Down Expand Up @@ -114,7 +115,7 @@ func (s *gatewayService) ExecNGQL(request *types.ExecNGQLParams) (*types.AnyResp
return nil, ecode.WithErrorMessage(ecode.ErrInternalServer, err, "execute failed")
}

return &types.AnyResponse{Data: execute}, nil
return &types.AnyResponse{Data: response.StandardHandlerDataFieldAny(execute)}, nil
}

func (s *gatewayService) BatchExecNGQL(request *types.BatchExecNGQLParams) (*types.AnyResponse, error) {
Expand Down Expand Up @@ -153,5 +154,5 @@ func (s *gatewayService) BatchExecNGQL(request *types.BatchExecNGQLParams) (*typ
data = append(data, gqlRes)
}

return &types.AnyResponse{Data: data}, nil
return &types.AnyResponse{Data: response.StandardHandlerDataFieldAny(data)}, nil
}
2 changes: 1 addition & 1 deletion server/api/studio/internal/types/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/vesoft-inc/nebula-studio/server-v2
go 1.17

require (
github.com/vesoft-inc/go-pkg v0.0.0-20220516090733-5ce93ad3254b
github.com/vesoft-inc/go-pkg v0.0.0-20220530040051-17c1bd2e8dd4
github.com/vesoft-inc/nebula-importer v1.0.1-0.20220505095506-93febd41c2be
github.com/zeromicro/go-zero v1.3.3
)
Expand Down
4 changes: 2 additions & 2 deletions server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMT
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/vesoft-inc/go-pkg v0.0.0-20220516090733-5ce93ad3254b h1:MVAkGU2YH1p3PhWN0T+r0bkv+gn5b33J2tEdnXXZAUE=
github.com/vesoft-inc/go-pkg v0.0.0-20220516090733-5ce93ad3254b/go.mod h1:HCAXRhF2io+nPLQnl+RQ6XyVcp1Xdv6NgslXRBBCiEU=
github.com/vesoft-inc/go-pkg v0.0.0-20220530040051-17c1bd2e8dd4 h1:PIHQdemdD/YrOHJtPUTpC1+BpcKokuj1HXyGo6CErjM=
github.com/vesoft-inc/go-pkg v0.0.0-20220530040051-17c1bd2e8dd4/go.mod h1:HCAXRhF2io+nPLQnl+RQ6XyVcp1Xdv6NgslXRBBCiEU=
github.com/vesoft-inc/nebula-go/v3 v3.0.0-20220425030225-cdb52399b40a h1:/8l9RT6gU0cUS1Cgzqv3A9dKto19VQBjVk1BqAAqqvM=
github.com/vesoft-inc/nebula-go/v3 v3.0.0-20220425030225-cdb52399b40a/go.mod h1:+sXv05jYQBARdTbTcIEsWVXCnF/6ttOlDK35xQ6m54s=
github.com/vesoft-inc/nebula-http-gateway/ccore v0.0.0-20220518092450-316a5f6420ef h1:Hco8JsAXm2ujRpJjo+qGnVyASHXDnopHwA20anmmnV4=
Expand Down

0 comments on commit 1a5f420

Please sign in to comment.