fix empty models

This commit is contained in:
Sakurasan
2025-04-22 02:52:56 +08:00
parent 8d34f8d6fe
commit 9c604460b1
5 changed files with 7 additions and 6 deletions

View File

@@ -3,6 +3,7 @@ package dao
import (
"errors"
"opencatd-open/internal/model"
"opencatd-open/internal/utils"
"opencatd-open/pkg/config"
"gorm.io/gorm"
@@ -38,6 +39,9 @@ func (dao *ApiKeyDAO) Create(apiKey *model.ApiKey) error {
if apiKey == nil {
return errors.New("apiKey is nil")
}
if len(*apiKey.SupportModels) < 2 {
apiKey.SupportModels = utils.ToPtr("[]")
}
return dao.db.Create(apiKey).Error
}