Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcf16a4e

Browse files
committed
gf map nil 转换问题
1 parent33fdbd9 commitcf16a4e

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

‎drivers/goframe/executor/action.go

Lines changed: 7 additions & 1 deletion
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
ifk==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+
ifdata[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

Lines changed: 9 additions & 10 deletions
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+
ife,ok:=err.(*gerror.Error);ok {
166+
ife.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)

[8]ページ先頭

©2009-2025 Movatter.jp