2023-01-16 05:54:44 +00:00
|
|
|
package model
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
2023-03-17 07:37:28 +00:00
|
|
|
type StorageA struct {
|
2023-01-16 05:54:44 +00:00
|
|
|
ID uint `json:"id" gorm:"primaryKey"` // unique key
|
|
|
|
MountPath string `json:"mount_path" gorm:"unique" binding:"required"` // must be standardized
|
|
|
|
Order int `json:"order"` // use to sort
|
|
|
|
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"`
|
|
|
|
Disabled bool `json:"disabled"` // if disabled
|
|
|
|
Sort
|
|
|
|
Proxy
|
|
|
|
}
|
|
|
|
|
|
|
|
type Sort struct {
|
|
|
|
OrderBy string `json:"order_by"`
|
|
|
|
OrderDirection string `json:"order_direction"`
|
|
|
|
ExtractFolder string `json:"extract_folder"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Proxy struct {
|
|
|
|
WebProxy bool `json:"web_proxy"`
|
|
|
|
WebdavPolicy string `json:"webdav_policy"`
|
|
|
|
DownProxyUrl string `json:"down_proxy_url"`
|
|
|
|
}
|
|
|
|
|
2023-03-17 07:37:28 +00:00
|
|
|
func (s *StorageA) GetStorage() *StorageA {
|
2023-01-16 05:54:44 +00:00
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
2023-03-17 07:37:28 +00:00
|
|
|
func (s *StorageA) SetStorage(storage StorageA) {
|
2023-01-16 05:54:44 +00:00
|
|
|
*s = storage
|
|
|
|
}
|
|
|
|
|
2023-03-17 07:37:28 +00:00
|
|
|
func (s *StorageA) SetStatus(status string) {
|
2023-01-16 05:54:44 +00:00
|
|
|
s.Status = status
|
|
|
|
}
|
|
|
|
|
|
|
|
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()
|
|
|
|
}
|