fix: 资产验证支持虚拟号(virtual_no)查询
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m27s

resolveAsset 查询 IoT 卡时仅匹配 iccid,导致用户输入
虚拟号时返回"资产不存在"(1180)。将查询条件扩展为
iccid OR virtual_no,与设备查询逻辑保持一致。

顺带将 jwt.ParseWithClaims 回调的 interface{} 替换为 any。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-10 11:42:23 +08:00
parent 51fa027eb8
commit 4a18aac6ce

View File

@@ -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)
}