feat: impl list
This commit is contained in:
parent
9a356ec9d6
commit
7868a1a524
@ -3,10 +3,14 @@ package template
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/internal/driver"
|
"github.com/alist-org/alist/v3/internal/driver"
|
||||||
"github.com/alist-org/alist/v3/internal/errs"
|
"github.com/alist-org/alist/v3/internal/errs"
|
||||||
"github.com/alist-org/alist/v3/internal/model"
|
"github.com/alist-org/alist/v3/internal/model"
|
||||||
|
"github.com/alist-org/alist/v3/pkg/utils"
|
||||||
|
"github.com/go-resty/resty/v2"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -37,7 +41,51 @@ func (d *ILanZou) Drop(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *ILanZou) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) {
|
func (d *ILanZou) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) {
|
||||||
|
offset := 1
|
||||||
|
limit := 60
|
||||||
|
var res []ListItem
|
||||||
|
for {
|
||||||
|
var resp ListResp
|
||||||
|
_, err := d.proved("/record/file/list", http.MethodGet, func(req *resty.Request) {
|
||||||
|
req.SetQueryParams(map[string]string{
|
||||||
|
"type": "0",
|
||||||
|
"folderId": dir.GetID(),
|
||||||
|
"offset": strconv.Itoa(offset),
|
||||||
|
"limit": strconv.Itoa(limit),
|
||||||
|
}).SetResult(&resp)
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
res = append(res, resp.List...)
|
||||||
|
if resp.TotalPage <= resp.Offset {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
offset++
|
||||||
|
}
|
||||||
|
return utils.SliceConvert(res, func(f ListItem) (model.Obj, error) {
|
||||||
|
updTime, err := time.ParseInLocation("2006-01-02 15:04:05", f.UpdTime, time.Local)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
obj := model.Object{
|
||||||
|
ID: strconv.FormatInt(f.FileId, 10),
|
||||||
|
//Path: "",
|
||||||
|
Name: f.FileName,
|
||||||
|
Size: f.FileSize * 1024,
|
||||||
|
Modified: updTime,
|
||||||
|
Ctime: updTime,
|
||||||
|
IsFolder: false,
|
||||||
|
//HashInfo: utils.HashInfo{},
|
||||||
|
}
|
||||||
|
if f.FileType == 2 {
|
||||||
|
obj.IsFolder = true
|
||||||
|
obj.Size = 0
|
||||||
|
obj.ID = strconv.FormatInt(f.FolderId, 10)
|
||||||
|
obj.Name = f.FolderName
|
||||||
|
}
|
||||||
|
return &obj, nil
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *ILanZou) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
|
func (d *ILanZou) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
|
||||||
|
@ -11,17 +11,29 @@ type ListResp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ListItem struct {
|
type ListItem struct {
|
||||||
IconId int `json:"iconId"`
|
IconId int `json:"iconId"`
|
||||||
IsAmt int `json:"isAmt"`
|
IsAmt int `json:"isAmt"`
|
||||||
FolderDesc string `json:"folderDesc"`
|
FolderDesc string `json:"folderDesc,omitempty"`
|
||||||
AddTime string `json:"addTime"`
|
AddTime string `json:"addTime"`
|
||||||
FolderId int `json:"folderId"`
|
FolderId int64 `json:"folderId"`
|
||||||
ParentId int `json:"parentId"`
|
ParentId int64 `json:"parentId"`
|
||||||
NoteType int `json:"noteType"`
|
ParentName string `json:"parentName"`
|
||||||
UpdTime string `json:"updTime"`
|
NoteType int `json:"noteType,omitempty"`
|
||||||
IsShare int `json:"isShare"`
|
UpdTime string `json:"updTime"`
|
||||||
FolderIcon string `json:"folderIcon"`
|
IsShare int `json:"isShare"`
|
||||||
FolderName string `json:"folderName"`
|
FolderIcon string `json:"folderIcon,omitempty"`
|
||||||
FileType int `json:"fileType"`
|
FolderName string `json:"folderName,omitempty"`
|
||||||
Status int `json:"status"`
|
FileType int `json:"fileType"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
IsFileShare int `json:"isFileShare,omitempty"`
|
||||||
|
FileName string `json:"fileName,omitempty"`
|
||||||
|
FileStars float64 `json:"fileStars,omitempty"`
|
||||||
|
IsFileDownload int `json:"isFileDownload,omitempty"`
|
||||||
|
FileComments int `json:"fileComments,omitempty"`
|
||||||
|
FileSize int64 `json:"fileSize,omitempty"`
|
||||||
|
FileIcon string `json:"fileIcon,omitempty"`
|
||||||
|
FileDownloads int `json:"fileDownloads,omitempty"`
|
||||||
|
FileUrl interface{} `json:"fileUrl"`
|
||||||
|
FileLikes int `json:"fileLikes,omitempty"`
|
||||||
|
FileId int64 `json:"fileId,omitempty"`
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user