fix: use lo
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
|||||||
|
|
||||||
"github.com/go-pay/gopay/wechat/v3"
|
"github.com/go-pay/gopay/wechat/v3"
|
||||||
"github.com/gofiber/fiber/v3"
|
"github.com/gofiber/fiber/v3"
|
||||||
|
"github.com/samber/lo"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -49,15 +50,11 @@ func (ctl *PayController) JSPay(ctx fiber.Ctx, claim *jwt.Claims, orderID string
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var oauth *model.UserOauths
|
oauth, ok := lo.Find(oauths, func(v model.UserOauths) bool {
|
||||||
for _, v := range oauths {
|
return v.Channel == fields.AuthChannelWeChat
|
||||||
if v.Channel == fields.AuthChannelWeChat {
|
})
|
||||||
oauth = &v
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if oauth == nil {
|
if !ok {
|
||||||
return nil, errorx.BadRequest.WithMsg("未绑定微信")
|
return nil, errorx.BadRequest.WithMsg("未绑定微信")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user