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