From 4a18aac6ce60bda6217a9559a488c69793bbe279 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 10 Apr 2026 11:42:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B5=84=E4=BA=A7=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=99=9A=E6=8B=9F=E5=8F=B7(virtual=5Fno)?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit resolveAsset 查询 IoT 卡时仅匹配 iccid,导致用户输入 虚拟号时返回"资产不存在"(1180)。将查询条件扩展为 iccid OR virtual_no,与设备查询逻辑保持一致。 顺带将 jwt.ParseWithClaims 回调的 interface{} 替换为 any。 Co-Authored-By: Claude Sonnet 4.6 --- internal/service/client_auth/service.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/client_auth/service.go b/internal/service/client_auth/service.go index d9ec59e..d4ef74f 100644 --- a/internal/service/client_auth/service.go +++ b/internal/service/client_auth/service.go @@ -390,7 +390,7 @@ func (s *Service) checkAssetVerifyRateLimit(ctx context.Context, clientIP string func (s *Service) resolveAsset(ctx context.Context, identifier string) (string, uint, error) { var card model.IotCard if err := s.db.WithContext(ctx). - Where("iccid = ?", identifier). + Where("iccid = ? OR virtual_no = ?", identifier, identifier). First(&card).Error; err == nil { return assetTypeIotCard, card.ID, nil } else if err != gorm.ErrRecordNotFound { @@ -430,7 +430,7 @@ func (s *Service) verifyAssetToken(assetToken string) (*assetTokenClaims, error) return nil, errors.New(errors.CodeInvalidParam) } - parsed, err := jwt.ParseWithClaims(assetToken, &assetTokenClaims{}, func(token *jwt.Token) (interface{}, error) { + parsed, err := jwt.ParseWithClaims(assetToken, &assetTokenClaims{}, func(token *jwt.Token) (any, error) { if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok { return nil, errors.New(errors.CodeInvalidToken) }