fix: use lo

This commit is contained in:
Rogee
2025-01-14 15:02:52 +08:00
parent 9cd7659d14
commit b429f30916

View File

@@ -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("未绑定微信")
} }