fix select key

This commit is contained in:
Sakurasan
2025-04-20 18:33:59 +08:00
parent b83c6d9786
commit b80f0759a5
5 changed files with 29 additions and 26 deletions

View File

@@ -91,11 +91,11 @@ func (dao *ApiKeyDAO) FindApiKeysBySupportModel(db *gorm.DB, modelName string) (
case "postgres":
return nil, errors.New("not support")
}
err := db.Model(&model.ApiKey{}).
Joins("CROSS JOIN JSON_EACH(apikeys.support_models)").
Where("active = true").
Where("value = ?", modelName).
Find(&apiKeys).Error
err := db.Raw(`
SELECT a.*
FROM apikeys a
JOIN json_each(a.support_models) AS je ON je.value = ?
WHERE a.active = true`, modelName).Scan(&apiKeys).Error
return apiKeys, err
}