fix: is the root folder required (close #1633)

pull/1831/head
Noah Hsu 2022-09-11 16:23:46 +08:00
parent fba1471ec4
commit 969018db37
3 changed files with 11 additions and 12 deletions

View File

@ -6,10 +6,10 @@ import (
)
type Addition struct {
Username string `json:"username" required:"true"`
Password string `json:"password" required:"true"`
VCode string `json:"validate_code"`
RootFolderID string `json:"root_folder_id"`
Username string `json:"username" required:"true"`
Password string `json:"password" required:"true"`
VCode string `json:"validate_code"`
driver.RootID
OrderBy string `json:"order_by" type:"select" options:"filename,filesize,lastOpTime" default:"filename"`
OrderDirection string `json:"order_direction" type:"select" options:"asc,desc" default:"asc"`
Type string `json:"type" type:"select" options:"personal,family" default:"personal"`
@ -17,10 +17,6 @@ type Addition struct {
RapidUpload bool `json:"rapid_upload"`
}
func (a Addition) GetRootId() string {
return a.RootFolderID
}
var config = driver.Config{
Name: "189CloudPC",
DefaultRoot: "-11",

View File

@ -28,11 +28,11 @@ type IRootId interface {
}
type RootPath struct {
RootFolderPath string `json:"root_folder_path" required:"true"`
RootFolderPath string `json:"root_folder_path"`
}
type RootID struct {
RootFolderID string `json:"root_folder_id" required:"true"`
RootFolderID string `json:"root_folder_id"`
}
func (r RootPath) GetRootPath() string {

View File

@ -145,8 +145,11 @@ func getAdditionalItems(t reflect.Type, defaultRoot string) []driver.Item {
if tag.Get("type") != "" {
item.Type = tag.Get("type")
}
if (item.Name == "root_folder_id" || item.Name == "root_folder_path") && item.Default == "" {
item.Default = defaultRoot
if item.Name == "root_folder_id" || item.Name == "root_folder_path" {
if item.Default == "" {
item.Default = defaultRoot
}
item.Required = item.Default != ""
}
// set default type to string
if item.Type == "" {