fix(vtencent): only show 50 files (close #5805)

pull/5816/head
Andy Hsu 2024-01-04 21:54:39 +08:00
parent fd96a7ccf4
commit 126cfe9f93
1 changed files with 20 additions and 12 deletions

View File

@ -100,27 +100,35 @@ func (d *Vtencent) LoadUser() (string, error) {
}
func (d *Vtencent) GetFiles(dirId string) ([]File, error) {
api := "https://api.vs.tencent.com/PaaS/Material/SearchResource"
form := fmt.Sprintf(`{
var res []File
//offset := 0
for {
api := "https://api.vs.tencent.com/PaaS/Material/SearchResource"
form := fmt.Sprintf(`{
"Text":"",
"Text":"",
"Offset":0,
"Limit":20000,
"Offset":%d,
"Limit":50,
"Sort":{"Field":"%s","Order":"%s"},
"CreateTimeRanges":[],
"MaterialTypes":[],
"ReviewStatuses":[],
"Tags":[],
"SearchScopes":[{"Owner":{"Type":"PERSON","Id":"%s"},"ClassId":%s,"SearchOneDepth":true}]
}`, d.Addition.OrderBy, d.Addition.OrderDirection, d.TfUid, dirId)
var resps RspFiles
_, err := d.request(api, http.MethodPost, func(req *resty.Request) {
req.SetBody(form).ForceContentType("application/json")
}, &resps)
if err != nil {
return []File{}, err
}`, len(res), d.Addition.OrderBy, d.Addition.OrderDirection, d.TfUid, dirId)
var resp RspFiles
_, err := d.request(api, http.MethodPost, func(req *resty.Request) {
req.SetBody(form).ForceContentType("application/json")
}, &resp)
if err != nil {
return nil, err
}
res = append(res, resp.Data.ResourceInfoSet...)
if len(resp.Data.ResourceInfoSet) <= 0 || len(res) >= resp.Data.TotalCount {
break
}
}
return resps.Data.ResourceInfoSet, nil
return res, nil
}
func (d *Vtencent) CreateUploadMaterial(classId int, fileName string, UploadSummaryKey string) (RspCreatrMaterial, error) {