Skip to content

Commit cf16a4e

Browse files
committed
gf map nil 转换问题
1 parent 33fdbd9 commit cf16a4e

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

drivers/goframe/executor/action.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (a *ActionExecutor) Update(ctx context.Context, table string, data model.Ma
9090
continue
9191
}
9292
if k == consts.Raw {
93-
m = m.Where(v.(map[string]any))
93+
m = m.Where(v.(map[string][]any))
9494
delete(where, k)
9595
continue
9696
}
@@ -119,6 +119,12 @@ func (a *ActionExecutor) Update(ctx context.Context, table string, data model.Ma
119119
delete(data, k)
120120
continue
121121
}
122+
123+
if data[k] == nil {
124+
// 此处目前不允许外部设置null
125+
delete(data, k)
126+
}
127+
122128
}
123129

124130
_ret, err := m.Where(where).Update(data)

drivers/goframe/web/gf.go

+9-10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/glennliao/apijson-go/consts"
1313
"github.com/glennliao/apijson-go/model"
1414
"github.com/gogf/gf/v2/container/gmap"
15+
"github.com/gogf/gf/v2/errors/gcode"
1516
"github.com/gogf/gf/v2/errors/gerror"
1617
"github.com/gogf/gf/v2/frame/g"
1718
"github.com/gogf/gf/v2/net/ghttp"
@@ -161,16 +162,14 @@ func CommonResponse(handler func(ctx context.Context, req model.Map) (res model.
161162
}
162163
} else {
163164

164-
if _, ok := err.(*gerror.Error); ok {
165-
// if e.Code() == gcode.CodeNil {
166-
// code = 400
167-
// msg = e.Error()
168-
// } else {
169-
// code = 500
170-
// msg = "系统异常"
171-
// }
172-
code = 500
173-
msg = "系统异常"
165+
if e, ok := err.(*gerror.Error); ok {
166+
if e.Code() == gcode.CodeInvalidParameter {
167+
code = 400
168+
msg = e.Error()
169+
} else {
170+
code = 500
171+
msg = "系统异常"
172+
}
174173
} else {
175174
code = 500
176175
msg = "系统异常"

0 commit comments

Comments
 (0)