Skip to content

Commit 62a5a5a

Browse files
laijinhangcg33
authored andcommitted
Update response.go
1 parent a45d01e commit 62a5a5a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

plugins/admin/modules/response/response.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ func OkWithData(ctx *context.Context, data map[string]interface{}) {
3838
}
3939

4040
func BadRequest(ctx *context.Context, msg string) {
41-
user := ctx.UserValue["user"].(models.UserModel)
41+
var user = models.UserModel{}
42+
var ok bool
43+
if user, ok = ctx.UserValue["user"].(models.UserModel); !ok {
44+
user.Id = -1
45+
}
4246
ctx.JSON(http.StatusBadRequest, map[string]interface{}{
4347
"code": http.StatusBadRequest,
4448
"msg": language.GetUser(msg, user.Id),

0 commit comments

Comments
 (0)