2022-06-06 13:48:53 +00:00
|
|
|
package model
|
|
|
|
|
2022-06-09 15:05:27 +00:00
|
|
|
import "time"
|
|
|
|
|
2022-07-10 06:45:39 +00:00
|
|
|
type Storage struct {
|
2022-07-12 06:11:37 +00:00
|
|
|
ID uint `json:"id" gorm:"primaryKey"` // unique key
|
|
|
|
MountPath string `json:"mount_path" gorm:"unique" binding:"required"` // must be standardized
|
|
|
|
Index int `json:"index"` // use to sort
|
|
|
|
Driver string `json:"driver"` // driver used
|
|
|
|
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-06-07 08:38:31 +00: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 05:58:21 +00:00
|
|
|
WebProxy bool `json:"web_proxy"`
|
|
|
|
WebdavPolicy string `json:"webdav_policy"`
|
2022-06-07 08:38:31 +00:00
|
|
|
DownProxyUrl string `json:"down_proxy_url"`
|
2022-06-06 13:48:53 +00:00
|
|
|
}
|
2022-06-08 08:20:58 +00:00
|
|
|
|
2022-07-12 10:41:16 +00:00
|
|
|
func (a *Storage) GetStorage() Storage {
|
|
|
|
return *a
|
2022-06-08 08:20:58 +00:00
|
|
|
}
|
2022-06-15 10:48:30 +00:00
|
|
|
|
2022-07-10 06:45:39 +00:00
|
|
|
func (a *Storage) SetStatus(status string) {
|
2022-06-15 10:48:30 +00:00
|
|
|
a.Status = status
|
|
|
|
}
|
2022-06-27 05:58:21 +00: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()
|
|
|
|
}
|