2022-11-28 05:45:25 +00:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type IndexProgress struct {
|
|
|
|
ObjCount uint64 `json:"obj_count"`
|
|
|
|
IsDone bool `json:"is_done"`
|
|
|
|
LastDoneTime *time.Time `json:"last_done_time"`
|
|
|
|
Error string `json:"error"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type SearchReq struct {
|
|
|
|
Parent string `json:"parent"`
|
|
|
|
Keywords string `json:"keywords"`
|
2023-08-06 07:13:23 +00:00
|
|
|
// 0 for all, 1 for dir, 2 for file
|
|
|
|
Scope int `json:"scope"`
|
2022-11-28 05:45:25 +00:00
|
|
|
PageReq
|
|
|
|
}
|
|
|
|
|
|
|
|
type SearchNode struct {
|
|
|
|
Parent string `json:"parent" gorm:"index"`
|
2022-12-12 12:20:01 +00:00
|
|
|
Name string `json:"name"`
|
2022-11-28 05:45:25 +00:00
|
|
|
IsDir bool `json:"is_dir"`
|
|
|
|
Size int64 `json:"size"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *SearchReq) Validate() error {
|
|
|
|
if p.Page < 1 {
|
|
|
|
return fmt.Errorf("page can't < 1")
|
|
|
|
}
|
|
|
|
if p.PerPage < 1 {
|
|
|
|
return fmt.Errorf("per_page can't < 1")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2022-12-05 05:28:39 +00:00
|
|
|
|
|
|
|
func (s *SearchNode) Type() string {
|
|
|
|
return "SearchNode"
|
|
|
|
}
|