2022-06-15 10:06:42 +00:00
|
|
|
package model
|
2022-06-06 13:48:53 +00:00
|
|
|
|
2022-11-30 12:46:54 +00:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/alist-org/alist/v3/pkg/utils"
|
|
|
|
)
|
2022-06-06 13:48:53 +00:00
|
|
|
|
2022-12-17 11:49:05 +00:00
|
|
|
type ObjWrapName struct {
|
|
|
|
Name string
|
|
|
|
Obj
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o *ObjWrapName) Unwrap() Obj {
|
|
|
|
return o.Obj
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o *ObjWrapName) GetName() string {
|
|
|
|
if o.Name == "" {
|
|
|
|
o.Name = utils.MappingName(o.Obj.GetName())
|
|
|
|
}
|
|
|
|
return o.Name
|
|
|
|
}
|
|
|
|
|
2022-06-15 12:41:17 +00:00
|
|
|
type Object struct {
|
|
|
|
ID string
|
2022-09-02 14:46:31 +00:00
|
|
|
Path string
|
2022-06-15 12:41:17 +00:00
|
|
|
Name string
|
2022-06-23 07:57:36 +00:00
|
|
|
Size int64
|
2022-06-15 12:41:17 +00:00
|
|
|
Modified time.Time
|
|
|
|
IsFolder bool
|
2022-06-06 13:48:53 +00:00
|
|
|
}
|
|
|
|
|
2022-09-02 10:24:14 +00:00
|
|
|
func (o *Object) GetName() string {
|
2022-12-17 11:49:05 +00:00
|
|
|
return o.Name
|
2022-06-06 13:48:53 +00:00
|
|
|
}
|
2022-06-07 14:02:41 +00:00
|
|
|
|
2022-09-02 10:24:14 +00:00
|
|
|
func (o *Object) GetSize() int64 {
|
2022-08-11 12:32:17 +00:00
|
|
|
return o.Size
|
2022-06-07 14:02:41 +00:00
|
|
|
}
|
|
|
|
|
2022-09-02 10:24:14 +00:00
|
|
|
func (o *Object) ModTime() time.Time {
|
2022-08-11 12:32:17 +00:00
|
|
|
return o.Modified
|
2022-06-15 12:41:17 +00:00
|
|
|
}
|
|
|
|
|
2022-09-02 10:24:14 +00:00
|
|
|
func (o *Object) IsDir() bool {
|
2022-08-11 12:32:17 +00:00
|
|
|
return o.IsFolder
|
2022-06-15 12:41:17 +00:00
|
|
|
}
|
|
|
|
|
2022-09-02 10:24:14 +00:00
|
|
|
func (o *Object) GetID() string {
|
2022-08-11 12:32:17 +00:00
|
|
|
return o.ID
|
2022-06-07 14:02:41 +00:00
|
|
|
}
|
2022-06-16 12:25:33 +00:00
|
|
|
|
2022-09-02 14:46:31 +00:00
|
|
|
func (o *Object) GetPath() string {
|
|
|
|
return o.Path
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o *Object) SetPath(id string) {
|
|
|
|
o.Path = id
|
2022-08-11 12:32:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Thumbnail struct {
|
|
|
|
Thumbnail string
|
|
|
|
}
|
|
|
|
|
2022-09-02 10:24:14 +00:00
|
|
|
type Url struct {
|
|
|
|
Url string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w Url) URL() string {
|
|
|
|
return w.Url
|
|
|
|
}
|
|
|
|
|
2022-08-11 12:32:17 +00:00
|
|
|
func (t Thumbnail) Thumb() string {
|
|
|
|
return t.Thumbnail
|
|
|
|
}
|
|
|
|
|
2022-09-02 10:24:14 +00:00
|
|
|
type ObjThumb struct {
|
|
|
|
Object
|
|
|
|
Thumbnail
|
|
|
|
}
|
|
|
|
|
|
|
|
type ObjectURL struct {
|
|
|
|
Object
|
|
|
|
Url
|
|
|
|
}
|
|
|
|
|
|
|
|
type ObjThumbURL struct {
|
2022-08-11 12:32:17 +00:00
|
|
|
Object
|
|
|
|
Thumbnail
|
2022-09-02 10:24:14 +00:00
|
|
|
Url
|
2022-06-16 12:25:33 +00:00
|
|
|
}
|