wip: list

This commit is contained in:
loveuer
2024-09-29 22:15:28 +08:00
parent b2c13508f4
commit 5e0885f22d
13 changed files with 241 additions and 19 deletions

View File

@ -1,9 +1,35 @@
package model
import "gorm.io/gorm"
import (
"github.com/loveuer/nf-disk/internal/opt"
"gorm.io/gorm"
)
func Init(tx *gorm.DB) error {
return tx.AutoMigrate(
func Init(tx *gorm.DB) (err error) {
if err = tx.AutoMigrate(
&Connection{},
)
); err != nil {
return err
}
if opt.Debug {
if err = tx.Create([]*Connection{
{
Name: "dev-minio",
Endpoint: "http://10.220.10.15:9000",
Access: "8ALV3DUZI31YG4BDRJ0Z",
Key: "CRqwS1MsiUj27TbRK+3T2n+LpKWd07VvaDKuzU0H",
},
{
Name: "test",
Endpoint: "http://10.220.10.14:19000",
Access: "",
Key: "",
},
}).Error; err != nil {
return err
}
}
return
}

View File

@ -11,6 +11,8 @@ type Connection struct {
Endpoint string `json:"endpoint" gorm:"column:endpoint"`
Access string `json:"access" gorm:"column:access"`
Key string `json:"key" gorm:"column:key"`
Active bool `json:"active" gorm:"-"`
}
func (c *Connection) Create(tx *gorm.DB) error {