✨ settings
This commit is contained in:
@ -12,7 +12,7 @@ type Account struct {
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
AccessToken string `json:"access_token"`
|
||||
RootFolder string `json:"root_folder"`
|
||||
Status string
|
||||
Status string `json:"status"`
|
||||
CronId int
|
||||
DriveId string
|
||||
Limit int `json:"limit"`
|
||||
@ -74,10 +74,10 @@ func GetAccountFiles() []*File {
|
||||
return files
|
||||
}
|
||||
|
||||
func GetAccounts() []*Account {
|
||||
accounts := make([]*Account, 0)
|
||||
func GetAccounts() []Account {
|
||||
accounts := make([]Account, 0)
|
||||
for _, v := range accountsMap {
|
||||
accounts = append(accounts, &v)
|
||||
accounts = append(accounts, v)
|
||||
}
|
||||
return accounts
|
||||
}
|
||||
|
@ -7,4 +7,5 @@ type File struct {
|
||||
Size int64 `json:"size"`
|
||||
Type int `json:"type"`
|
||||
UpdatedAt *time.Time `json:"updated_at"`
|
||||
Thumbnail string `json:"thumbnail"`
|
||||
}
|
||||
|
@ -14,16 +14,25 @@ type SettingItem struct {
|
||||
Key string `json:"key" gorm:"primaryKey" validate:"required"`
|
||||
Value string `json:"value"`
|
||||
Description string `json:"description"`
|
||||
Type int `json:"type"`
|
||||
Type string `json:"type"`
|
||||
Group int `json:"group"`
|
||||
}
|
||||
|
||||
func SaveSettings(items []SettingItem) error {
|
||||
return conf.DB.Save(items).Error
|
||||
}
|
||||
|
||||
func GetSettingByType(t int) (*[]SettingItem, error) {
|
||||
func GetSettingsByGroup(t int) (*[]SettingItem, error) {
|
||||
var items []SettingItem
|
||||
if err := conf.DB.Where("type = ?", t).Find(&items).Error; err != nil {
|
||||
if err := conf.DB.Where("group = ?", t).Find(&items).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &items, nil
|
||||
}
|
||||
|
||||
func GetSettings() (*[]SettingItem, error) {
|
||||
var items []SettingItem
|
||||
if err := conf.DB.Find(&items).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &items, nil
|
||||
@ -36,4 +45,3 @@ func GetSettingByKey(key string) (*SettingItem, error) {
|
||||
}
|
||||
return &items, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user