Skip to content

Commit

Permalink
generate table, add error but fail
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodERPJeff committed Oct 18, 2019
1 parent 9618629 commit e4deaf3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func init() {
new(OAuth2AuthorizationCode),
new(OAuth2Grant),
new(Task),
new(Transfer),
)

gonicNames := []string{"SSL", "UID"}
Expand Down
6 changes: 3 additions & 3 deletions models/transfer_point.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ func TransferPoint(FromID int64, Why string, ToID int64, Qty int) (err error) {
return err
}

// if _, err = sess.Insert(&Transfer{FromID: FromID, ToID: ToID, Why: Why, Qty: Qty}); err != nil {
// return err
// }
if _, err = sess.Insert(&Transfer{FromID: FromID, ToID: ToID, Why: Why, Qty: Qty}); err != nil {
return err
}

if _, err = sess.Exec("UPDATE `user` SET point = point + ? WHERE id = ?", Qty, ToID); err != nil {
return err
Expand Down
5 changes: 5 additions & 0 deletions routers/user/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ func TransferP(ctx *context.Context) {
var err error
Qty, err := strconv.Atoi(ctx.Query("qty"))
if err != nil {
ctx.Flash.Error("请输入数字")

This comment has been minimized.

Copy link
@GoodERPJeff

GoodERPJeff Oct 18, 2019

Author

这里想给用户一个报错,页面不要跳转,应该怎么写呢?现在直接return是来到空页面了。

return
}
if ctx.User.Point < Qty {
ctx.Flash.Error("余额不足!")
return
}
err = models.TransferPoint(ctx.User.ID,
Expand Down

0 comments on commit e4deaf3

Please sign in to comment.