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