Skip to content

Commit

Permalink
gf map nil 转换问题
Browse files Browse the repository at this point in the history
  • Loading branch information
glennliao committed Aug 2, 2023
1 parent 33fdbd9 commit cf16a4e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
8 changes: 7 additions & 1 deletion drivers/goframe/executor/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (a *ActionExecutor) Update(ctx context.Context, table string, data model.Ma
continue
}
if k == consts.Raw {
m = m.Where(v.(map[string]any))
m = m.Where(v.(map[string][]any))
delete(where, k)
continue
}
Expand Down Expand Up @@ -119,6 +119,12 @@ func (a *ActionExecutor) Update(ctx context.Context, table string, data model.Ma
delete(data, k)
continue
}

if data[k] == nil {
// 此处目前不允许外部设置null
delete(data, k)
}

}

_ret, err := m.Where(where).Update(data)
Expand Down
19 changes: 9 additions & 10 deletions drivers/goframe/web/gf.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/glennliao/apijson-go/consts"
"github.com/glennliao/apijson-go/model"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
Expand Down Expand Up @@ -161,16 +162,14 @@ func CommonResponse(handler func(ctx context.Context, req model.Map) (res model.
}
} else {

if _, ok := err.(*gerror.Error); ok {
// if e.Code() == gcode.CodeNil {
// code = 400
// msg = e.Error()
// } else {
// code = 500
// msg = "系统异常"
// }
code = 500
msg = "系统异常"
if e, ok := err.(*gerror.Error); ok {
if e.Code() == gcode.CodeInvalidParameter {
code = 400
msg = e.Error()
} else {
code = 500
msg = "系统异常"
}
} else {
code = 500
msg = "系统异常"
Expand Down

0 comments on commit cf16a4e

Please sign in to comment.