meta api

This commit is contained in:
微凉
2021-11-02 19:25:54 +08:00
parent 8b81aeb5a1
commit 510292c8b0
6 changed files with 98 additions and 28 deletions

View File

@ -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{}

View File

@ -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
}