2022-06-06 21:48:53 +08:00
|
|
|
package model
|
|
|
|
|
2022-06-09 23:05:27 +08:00
|
|
|
import "time"
|
|
|
|
|
2022-07-10 14:45:39 +08:00
|
|
|
type Storage struct {
|
2022-08-07 13:33:53 +08:00
|
|
|
ID uint `json:"id" gorm:"primaryKey"` // unique key
|
|
|
|
MountPath string `json:"mount_path" gorm:"unique" binding:"required"` // must be standardized
|
2022-09-07 15:55:15 +08:00
|
|
|
Order int `json:"order"` // use to sort
|
2022-08-07 13:33:53 +08:00
|
|
|
Driver string `json:"driver"` // driver used
|
|
|
|
CacheExpiration int `json:"cache_expiration"` // cache expire time
|
|
|
|
Status string `json:"status"`
|
|
|
|
Addition string `json:"addition" gorm:"type:text"` // Additional information, defined in the corresponding driver
|
|
|
|
Remark string `json:"remark"`
|
|
|
|
Modified time.Time `json:"modified"`
|
2022-08-11 21:08:50 +08:00
|
|
|
Disabled bool `json:"disabled"` // if disabled
|
2023-03-24 22:44:33 +08:00
|
|
|
EnableSign bool `json:"enable_sign"`
|
2022-06-07 16:38:31 +08:00
|
|
|
Sort
|
|
|
|
Proxy
|
|
|
|
}
|
|
|
|
|
|
|
|
type Sort struct {
|
|
|
|
OrderBy string `json:"order_by"`
|
|
|
|
OrderDirection string `json:"order_direction"`
|
|
|
|
ExtractFolder string `json:"extract_folder"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Proxy struct {
|
2022-06-27 13:58:21 +08:00
|
|
|
WebProxy bool `json:"web_proxy"`
|
|
|
|
WebdavPolicy string `json:"webdav_policy"`
|
2022-06-07 16:38:31 +08:00
|
|
|
DownProxyUrl string `json:"down_proxy_url"`
|
2022-06-06 21:48:53 +08:00
|
|
|
}
|
2022-06-08 16:20:58 +08:00
|
|
|
|
2022-08-30 21:52:06 +08:00
|
|
|
func (s *Storage) GetStorage() *Storage {
|
|
|
|
return s
|
2022-06-08 16:20:58 +08:00
|
|
|
}
|
2022-06-15 18:48:30 +08:00
|
|
|
|
2022-12-13 18:03:30 +08:00
|
|
|
func (s *Storage) SetStorage(storage Storage) {
|
|
|
|
*s = storage
|
|
|
|
}
|
|
|
|
|
2022-08-30 21:52:06 +08:00
|
|
|
func (s *Storage) SetStatus(status string) {
|
|
|
|
s.Status = status
|
2022-06-15 18:48:30 +08:00
|
|
|
}
|
2022-06-27 13:58:21 +08:00
|
|
|
|
|
|
|
func (p Proxy) Webdav302() bool {
|
|
|
|
return p.WebdavPolicy == "302_redirect"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p Proxy) WebdavProxy() bool {
|
|
|
|
return p.WebdavPolicy == "use_proxy_url"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p Proxy) WebdavNative() bool {
|
|
|
|
return !p.Webdav302() && !p.WebdavProxy()
|
|
|
|
}
|