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