🐛 sql group

This commit is contained in:
微凉 2021-10-30 17:34:34 +08:00
parent 0324ea1fcb
commit 2780efaea8
7 changed files with 23 additions and 11 deletions

View File

@ -140,6 +140,13 @@ func initSettings() {
Description: "logo", Description: "logo",
Group: model.PUBLIC, Group: model.PUBLIC,
}, },
{
Key: "icon_color",
Value: "blue.400",
Type: "string",
Description: "icon's color",
Group: model.PUBLIC,
},
}, },
} }
for k, v := range settingsMap { for k, v := range settingsMap {

View File

@ -19,9 +19,9 @@ var (
) )
var ( var (
TextTypes = []string{"txt", "go"} TextTypes = []string{"txt", "go", "md"}
OfficeTypes = []string{"doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf"} OfficeTypes = []string{"doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf"}
VideoTypes = []string{"mp4", "mkv", "avi", "mov", "rmvb"} VideoTypes = []string{"mp4", "mkv", "avi", "mov", "rmvb"}
AudioTypes = []string{"mp3", "flac"} AudioTypes = []string{"mp3", "flac","ogg"}
ImageTypes = []string{"jpg","jpeg","png","gif","bmp","svg"} ImageTypes = []string{"jpg","jpeg","png","gif","bmp","svg"}
) )

View File

@ -103,14 +103,14 @@ func (a AliDrive) GetFiles(fileId string, account *model.Account) ([]AliFile, er
SetBody(JsonStr(Json{ SetBody(JsonStr(Json{
"drive_id": account.DriveId, "drive_id": account.DriveId,
"fields": "*", "fields": "*",
"image_thumbnail_process": "image/resize,w_50", "image_thumbnail_process": "image/resize,w_400/format,jpeg",
"image_url_process": "image/resize,w_1920/format,jpeg", "image_url_process": "image/resize,w_1920/format,jpeg",
"limit": account.Limit, "limit": account.Limit,
"marker": marker, "marker": marker,
"order_by": account.OrderBy, "order_by": account.OrderBy,
"order_direction": account.OrderDirection, "order_direction": account.OrderDirection,
"parent_file_id": fileId, "parent_file_id": fileId,
"video_thumbnail_process": "video/snapshot,t_0,f_jpg,w_50", "video_thumbnail_process": "video/snapshot,t_0,f_jpg,ar_auto,w_300",
//"url_expire_sec": 1600, //"url_expire_sec": 1600,
})).Post("https://api.aliyundrive.com/v2/file/list") })).Post("https://api.aliyundrive.com/v2/file/list")
if err != nil { if err != nil {

View File

@ -2,6 +2,7 @@ package model
import ( import (
"github.com/Xhofe/alist/conf" "github.com/Xhofe/alist/conf"
"time"
) )
type Account struct { type Account struct {
@ -15,10 +16,11 @@ type Account struct {
Status string `json:"status"` Status string `json:"status"`
CronId int CronId int
DriveId string DriveId string
Limit int `json:"limit"` Limit int `json:"limit"`
OrderBy string `json:"order_by"` OrderBy string `json:"order_by"`
OrderDirection string `json:"order_direction"` OrderDirection string `json:"order_direction"`
Proxy bool `json:"proxy"` Proxy bool `json:"proxy"`
UpdatedAt *time.Time `json:"updated_at"`
} }
var accountsMap = map[string]Account{} var accountsMap = map[string]Account{}
@ -68,7 +70,7 @@ func GetAccountFiles() []*File {
Name: v.Name, Name: v.Name,
Size: 0, Size: 0,
Type: conf.FOLDER, Type: conf.FOLDER,
UpdatedAt: nil, UpdatedAt: v.UpdatedAt,
}) })
} }
return files return files

View File

@ -24,7 +24,7 @@ func SaveSettings(items []SettingItem) error {
func GetSettingsByGroup(t int) (*[]SettingItem, error) { func GetSettingsByGroup(t int) (*[]SettingItem, error) {
var items []SettingItem var items []SettingItem
if err := conf.DB.Where("group = ?", t).Find(&items).Error; err != nil { if err := conf.DB.Where("`group` = ?", t).Find(&items).Error; err != nil {
return nil, err return nil, err
} }
return &items, nil return &items, nil

View File

@ -5,6 +5,7 @@ import (
"github.com/Xhofe/alist/drivers" "github.com/Xhofe/alist/drivers"
"github.com/Xhofe/alist/model" "github.com/Xhofe/alist/model"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"time"
) )
func GetAccounts(ctx *fiber.Ctx) error { func GetAccounts(ctx *fiber.Ctx) error {
@ -24,6 +25,8 @@ func SaveAccount(ctx *fiber.Ctx) error {
return ErrorResp(ctx, fmt.Errorf("no [%s] driver", req.Type), 400) return ErrorResp(ctx, fmt.Errorf("no [%s] driver", req.Type), 400)
} }
old, ok := model.GetAccount(req.Name) old, ok := model.GetAccount(req.Name)
now := time.Now()
req.UpdatedAt = &now
if err := model.SaveAccount(req); err != nil { if err := model.SaveAccount(req); err != nil {
return ErrorResp(ctx, err, 500) return ErrorResp(ctx, err, 500)
} else { } else {

View File

@ -34,7 +34,7 @@ func GetFileType(ext string) int {
if ext == "" { if ext == "" {
return conf.UNKNOWN return conf.UNKNOWN
} }
ext = ext[1:] ext = strings.TrimLeft(ext,".")
if IsContain(conf.OfficeTypes, ext) { if IsContain(conf.OfficeTypes, ext) {
return conf.OFFICE return conf.OFFICE
} }