✨ meta api
This commit is contained in:
@ -21,6 +21,7 @@ type Account struct {
|
||||
OrderDirection string `json:"order_direction"`
|
||||
Proxy bool `json:"proxy"`
|
||||
UpdatedAt *time.Time `json:"updated_at"`
|
||||
Search bool `json:"search"`
|
||||
}
|
||||
|
||||
var accountsMap = map[string]Account{}
|
||||
|
@ -3,13 +3,12 @@ package model
|
||||
import "github.com/Xhofe/alist/conf"
|
||||
|
||||
type Meta struct {
|
||||
Path string `json:"path" gorm:"primaryKey"`
|
||||
Path string `json:"path" gorm:"primaryKey" validate:"required"`
|
||||
Password string `json:"password"`
|
||||
Hide bool `json:"hide"`
|
||||
Ignore bool `json:"ignore"`
|
||||
Hide string `json:"hide"`
|
||||
}
|
||||
|
||||
func GetMetaByPath(path string) (*Meta,error) {
|
||||
func GetMetaByPath(path string) (*Meta, error) {
|
||||
var meta Meta
|
||||
meta.Path = path
|
||||
err := conf.DB.First(&meta).Error
|
||||
@ -17,4 +16,21 @@ func GetMetaByPath(path string) (*Meta,error) {
|
||||
return nil, err
|
||||
}
|
||||
return &meta, nil
|
||||
}
|
||||
}
|
||||
|
||||
func SaveMeta(meta Meta) error {
|
||||
return conf.DB.Save(meta).Error
|
||||
}
|
||||
|
||||
func DeleteMeta(path string) error {
|
||||
meta := Meta{Path: path}
|
||||
return conf.DB.Delete(&meta).Error
|
||||
}
|
||||
|
||||
func GetMetas() (*[]Meta, error) {
|
||||
var metas []Meta
|
||||
if err := conf.DB.Find(&metas).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &metas, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user