Skip to content

Commit

Permalink
mod: fix server (vesoft-inc#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
hetao92 committed Mar 31, 2022
1 parent c777554 commit 63263ec
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/config/example-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ web:
# tasks_dir:
# sqlitedb_file_path:
# ip:
# port: 7001 # (production env), defaut is 9000 (test env)
port: 9000 # (for test env, use 7001 in production env)
48 changes: 48 additions & 0 deletions server/pkg/webserver/controller/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,54 @@ type disConnectDBParams struct {
Nsid string `json:"nsid"`
}

func BatchExecNGQL(ctx iris.Context) base.Result {
params := new(batchExecNGQLParams)
err := ctx.ReadJSON(params)
if err != nil {
zap.L().Warn("execNGQLParams get fail", zap.Error(err))
return base.Response{
Code: base.Error,
Message: err.Error(),
}
}
nsid := ctx.GetCookie("nsid")
data := make([]map[string]interface{}, 0)

for i := 0; i < len(params.Gqls); i++ {
gql := params.Gqls[i]
execute, _, err := dao.Execute(nsid, gql, make([]string, 0))
gqlRes := make(map[string]interface{})
gqlRes["gql"] = gql
if err != nil {
gqlRes["message"] = err.Error()
gqlRes["code"] = base.Error
} else {
gqlRes["code"] = base.Success
}
gqlRes["data"] = execute
data = append(data, gqlRes)
}

if len(params.ParamList) > 0 {
execute, _, err := dao.Execute(nsid, "", params.ParamList)
gqlRes := make(map[string]interface{})
gqlRes["gql"] = strings.Join(params.ParamList, "; ")
if err != nil {
gqlRes["message"] = err.Error()
gqlRes["code"] = base.Error
} else {
gqlRes["code"] = base.Success
}
gqlRes["data"] = execute
data = append(data, gqlRes)
}

return base.Response{
Code: base.Success,
Data: data,
}
}

func ExecNGQL(ctx iris.Context) base.Result {
params := new(execNGQLParams)
if err := ctx.ReadJSON(params); err != nil {
Expand Down

0 comments on commit 63263ec

Please sign in to comment.