This commit is contained in:
Lizandro Guarnizo
2026-06-03 21:32:50 -05:00
parent f087fd46f1
commit c05a2a8137
10 changed files with 453 additions and 175 deletions
+15 -7
View File
@@ -9,13 +9,14 @@ import (
type OssApi struct {
gorm.Model
Name string `gorm:"size:100;not null" json:"name"` // Alias o nombre interno
Endpoint string `gorm:"not null" json:"endpoint"` // Endpoint del access point
AccessKeyID string `gorm:"not null" json:"access_key_id"` // Access Key ID
AccessKeySecret string `gorm:"not null" json:"access_key_secret"` // Access Key Secret
BucketName string `gorm:"not null" json:"bucket_name"` // Nombre del bucket o access point
Region string `gorm:"size:50" json:"region"` // Región, opcional
IsActive bool `gorm:"default:true" json:"is_active"` // Activar o desactivar config
Name string `gorm:"size:100;not null" json:"name"` // Alias o nombre interno
Provider string `gorm:"size:20;default:alibaba" json:"provider"` // alibaba | s3
Endpoint string `gorm:"not null" json:"endpoint"` // Endpoint del access point
AccessKeyID string `gorm:"not null" json:"access_key_id"` // Access Key ID
AccessKeySecret string `gorm:"not null" json:"access_key_secret"` // Access Key Secret
BucketName string `gorm:"not null" json:"bucket_name"` // Nombre del bucket o access point
Region string `gorm:"size:50" json:"region"` // Región, opcional
IsActive bool `gorm:"default:true" json:"is_active"` // Activar o desactivar config
Notes string `gorm:"type:text" json:"notes"`
}
@@ -84,6 +85,13 @@ func GetOssApiByID(id uint) (*OssApi, error) {
return &item, nil
}
// GetActiveOssApis obtiene todas las configuraciones activas
func GetActiveOssApis() ([]OssApi, error) {
var items []OssApi
err := app.Http.Database.DB.Where("is_active = ?", true).Order("id DESC").Find(&items).Error
return items, err
}
// GetLastActiveOssApi obtiene el último registro activo
func GetLastActiveOssApi() (*OssApi, error) {
var ossConfig OssApi