| | package _189pc |
| |
|
| | import ( |
| | "encoding/xml" |
| | "fmt" |
| | "sort" |
| | "strings" |
| | "time" |
| |
|
| | "github.com/alist-org/alist/v3/pkg/utils" |
| | ) |
| |
|
| | |
| | type RespErr struct { |
| | ResCode any `json:"res_code"` |
| | ResMessage string `json:"res_message"` |
| |
|
| | Error_ string `json:"error"` |
| |
|
| | XMLName xml.Name `xml:"error"` |
| | Code string `json:"code" xml:"code"` |
| | Message string `json:"message" xml:"message"` |
| | Msg string `json:"msg"` |
| |
|
| | ErrorCode string `json:"errorCode"` |
| | ErrorMsg string `json:"errorMsg"` |
| | } |
| |
|
| | func (e *RespErr) HasError() bool { |
| | switch v := e.ResCode.(type) { |
| | case int, int64, int32: |
| | return v != 0 |
| | case string: |
| | return e.ResCode != "" |
| | } |
| | return (e.Code != "" && e.Code != "SUCCESS") || e.ErrorCode != "" || e.Error_ != "" |
| | } |
| |
|
| | func (e *RespErr) Error() string { |
| | switch v := e.ResCode.(type) { |
| | case int, int64, int32: |
| | if v != 0 { |
| | return fmt.Sprintf("res_code: %d ,res_msg: %s", v, e.ResMessage) |
| | } |
| | case string: |
| | if e.ResCode != "" { |
| | return fmt.Sprintf("res_code: %s ,res_msg: %s", e.ResCode, e.ResMessage) |
| | } |
| | } |
| |
|
| | if e.Code != "" && e.Code != "SUCCESS" { |
| | if e.Msg != "" { |
| | return fmt.Sprintf("code: %s ,msg: %s", e.Code, e.Msg) |
| | } |
| | if e.Message != "" { |
| | return fmt.Sprintf("code: %s ,msg: %s", e.Code, e.Message) |
| | } |
| | return "code: " + e.Code |
| | } |
| |
|
| | if e.ErrorCode != "" { |
| | return fmt.Sprintf("err_code: %s ,err_msg: %s", e.ErrorCode, e.ErrorMsg) |
| | } |
| |
|
| | if e.Error_ != "" { |
| | return fmt.Sprintf("error: %s ,message: %s", e.ErrorCode, e.Message) |
| | } |
| | return "" |
| | } |
| |
|
| | |
| | type LoginParam struct { |
| | |
| | RsaUsername string |
| | RsaPassword string |
| |
|
| | |
| | jRsaKey string |
| |
|
| | |
| | Lt string |
| | ReqId string |
| |
|
| | |
| | ParamId string |
| |
|
| | |
| | CaptchaToken string |
| | } |
| |
|
| | |
| | type EncryptConfResp struct { |
| | Result int `json:"result"` |
| | Data struct { |
| | UpSmsOn string `json:"upSmsOn"` |
| | Pre string `json:"pre"` |
| | PreDomain string `json:"preDomain"` |
| | PubKey string `json:"pubKey"` |
| | } `json:"data"` |
| | } |
| |
|
| | type LoginResp struct { |
| | Msg string `json:"msg"` |
| | Result int `json:"result"` |
| | ToUrl string `json:"toUrl"` |
| | } |
| |
|
| | |
| | type UserSessionResp struct { |
| | ResCode int `json:"res_code"` |
| | ResMessage string `json:"res_message"` |
| |
|
| | LoginName string `json:"loginName"` |
| |
|
| | KeepAlive int `json:"keepAlive"` |
| | GetFileDiffSpan int `json:"getFileDiffSpan"` |
| | GetUserInfoSpan int `json:"getUserInfoSpan"` |
| |
|
| | |
| | SessionKey string `json:"sessionKey"` |
| | SessionSecret string `json:"sessionSecret"` |
| | |
| | FamilySessionKey string `json:"familySessionKey"` |
| | FamilySessionSecret string `json:"familySessionSecret"` |
| | } |
| |
|
| | |
| | type AppSessionResp struct { |
| | UserSessionResp |
| |
|
| | IsSaveName string `json:"isSaveName"` |
| |
|
| | |
| | AccessToken string `json:"accessToken"` |
| | |
| | RefreshToken string `json:"refreshToken"` |
| | } |
| |
|
| | |
| | type FamilyInfoListResp struct { |
| | FamilyInfoResp []FamilyInfoResp `json:"familyInfoResp"` |
| | } |
| | type FamilyInfoResp struct { |
| | Count int `json:"count"` |
| | CreateTime string `json:"createTime"` |
| | FamilyID int64 `json:"familyId"` |
| | RemarkName string `json:"remarkName"` |
| | Type int `json:"type"` |
| | UseFlag int `json:"useFlag"` |
| | UserRole int `json:"userRole"` |
| | } |
| |
|
| | |
| | |
| | type Cloud189File struct { |
| | ID String `json:"id"` |
| | Name string `json:"name"` |
| | Size int64 `json:"size"` |
| | Md5 string `json:"md5"` |
| |
|
| | LastOpTime Time `json:"lastOpTime"` |
| | CreateDate Time `json:"createDate"` |
| | Icon struct { |
| | |
| | SmallUrl string `json:"smallUrl"` |
| | LargeUrl string `json:"largeUrl"` |
| |
|
| | |
| | Max600 string `json:"max600"` |
| | MediumURL string `json:"mediumUrl"` |
| | } `json:"icon"` |
| |
|
| | |
| | |
| | |
| | |
| | |
| | } |
| |
|
| | func (c *Cloud189File) CreateTime() time.Time { |
| | return time.Time(c.CreateDate) |
| | } |
| |
|
| | func (c *Cloud189File) GetHash() utils.HashInfo { |
| | return utils.NewHashInfo(utils.MD5, c.Md5) |
| | } |
| |
|
| | func (c *Cloud189File) GetSize() int64 { return c.Size } |
| | func (c *Cloud189File) GetName() string { return c.Name } |
| | func (c *Cloud189File) ModTime() time.Time { return time.Time(c.LastOpTime) } |
| | func (c *Cloud189File) IsDir() bool { return false } |
| | func (c *Cloud189File) GetID() string { return string(c.ID) } |
| | func (c *Cloud189File) GetPath() string { return "" } |
| | func (c *Cloud189File) Thumb() string { return c.Icon.SmallUrl } |
| |
|
| | |
| | type Cloud189Folder struct { |
| | ID String `json:"id"` |
| | ParentID int64 `json:"parentId"` |
| | Name string `json:"name"` |
| |
|
| | LastOpTime Time `json:"lastOpTime"` |
| | CreateDate Time `json:"createDate"` |
| |
|
| | |
| | |
| | |
| | |
| | |
| | } |
| |
|
| | func (c *Cloud189Folder) CreateTime() time.Time { |
| | return time.Time(c.CreateDate) |
| | } |
| |
|
| | func (c *Cloud189Folder) GetHash() utils.HashInfo { |
| | return utils.HashInfo{} |
| | } |
| |
|
| | func (c *Cloud189Folder) GetSize() int64 { return 0 } |
| | func (c *Cloud189Folder) GetName() string { return c.Name } |
| | func (c *Cloud189Folder) ModTime() time.Time { return time.Time(c.LastOpTime) } |
| | func (c *Cloud189Folder) IsDir() bool { return true } |
| | func (c *Cloud189Folder) GetID() string { return string(c.ID) } |
| | func (c *Cloud189Folder) GetPath() string { return "" } |
| |
|
| | type Cloud189FilesResp struct { |
| | |
| | |
| | FileListAO struct { |
| | Count int `json:"count"` |
| | FileList []Cloud189File `json:"fileList"` |
| | FolderList []Cloud189Folder `json:"folderList"` |
| | } `json:"fileListAO"` |
| | } |
| |
|
| | |
| | type BatchTaskInfo struct { |
| | |
| | FileId string `json:"fileId"` |
| | |
| | FileName string `json:"fileName"` |
| | |
| | IsFolder int `json:"isFolder"` |
| | |
| | SrcParentId string `json:"srcParentId,omitempty"` |
| |
|
| | |
| | |
| | DealWay int `json:"dealWay,omitempty"` |
| | IsConflict int `json:"isConflict,omitempty"` |
| | } |
| |
|
| | |
| | type InitMultiUploadResp struct { |
| | |
| | Data struct { |
| | UploadType int `json:"uploadType"` |
| | UploadHost string `json:"uploadHost"` |
| | UploadFileID string `json:"uploadFileId"` |
| | FileDataExists int `json:"fileDataExists"` |
| | } `json:"data"` |
| | } |
| | type UploadUrlsResp struct { |
| | Code string `json:"code"` |
| | Data map[string]UploadUrlsData `json:"uploadUrls"` |
| | } |
| | type UploadUrlsData struct { |
| | RequestURL string `json:"requestURL"` |
| | RequestHeader string `json:"requestHeader"` |
| | } |
| |
|
| | type UploadUrlInfo struct { |
| | PartNumber int |
| | Headers map[string]string |
| | UploadUrlsData |
| | } |
| |
|
| | type UploadProgress struct { |
| | UploadInfo InitMultiUploadResp |
| | UploadParts []string |
| | } |
| |
|
| | |
| | type CreateUploadFileResp struct { |
| | |
| | UploadFileId int64 `json:"uploadFileId"` |
| | |
| | FileUploadUrl string `json:"fileUploadUrl"` |
| | |
| | FileCommitUrl string `json:"fileCommitUrl"` |
| | |
| | FileDataExists int `json:"fileDataExists"` |
| | } |
| |
|
| | type GetUploadFileStatusResp struct { |
| | CreateUploadFileResp |
| |
|
| | |
| | DataSize int64 `json:"dataSize"` |
| | Size int64 `json:"size"` |
| | } |
| |
|
| | func (r *GetUploadFileStatusResp) GetSize() int64 { |
| | return r.DataSize + r.Size |
| | } |
| |
|
| | type CommitMultiUploadFileResp struct { |
| | File struct { |
| | UserFileID String `json:"userFileId"` |
| | FileName string `json:"fileName"` |
| | FileSize int64 `json:"fileSize"` |
| | FileMd5 string `json:"fileMd5"` |
| | CreateDate Time `json:"createDate"` |
| | } `json:"file"` |
| | } |
| |
|
| | func (f *CommitMultiUploadFileResp) toFile() *Cloud189File { |
| | return &Cloud189File{ |
| | ID: f.File.UserFileID, |
| | Name: f.File.FileName, |
| | Size: f.File.FileSize, |
| | Md5: f.File.FileMd5, |
| | LastOpTime: f.File.CreateDate, |
| | CreateDate: f.File.CreateDate, |
| | } |
| | } |
| |
|
| | type OldCommitUploadFileResp struct { |
| | XMLName xml.Name `xml:"file"` |
| | ID String `xml:"id"` |
| | Name string `xml:"name"` |
| | Size int64 `xml:"size"` |
| | Md5 string `xml:"md5"` |
| | CreateDate Time `xml:"createDate"` |
| | } |
| |
|
| | func (f *OldCommitUploadFileResp) toFile() *Cloud189File { |
| | return &Cloud189File{ |
| | ID: f.ID, |
| | Name: f.Name, |
| | Size: f.Size, |
| | Md5: f.Md5, |
| | CreateDate: f.CreateDate, |
| | LastOpTime: f.CreateDate, |
| | } |
| | } |
| |
|
| | type CreateBatchTaskResp struct { |
| | TaskID string `json:"taskId"` |
| | } |
| |
|
| | type BatchTaskStateResp struct { |
| | FailedCount int `json:"failedCount"` |
| | Process int `json:"process"` |
| | SkipCount int `json:"skipCount"` |
| | SubTaskCount int `json:"subTaskCount"` |
| | SuccessedCount int `json:"successedCount"` |
| | SuccessedFileIDList []int64 `json:"successedFileIdList"` |
| | TaskID string `json:"taskId"` |
| | TaskStatus int `json:"taskStatus"` |
| | } |
| |
|
| | type BatchTaskConflictTaskInfoResp struct { |
| | SessionKey string `json:"sessionKey"` |
| | TargetFolderID int `json:"targetFolderId"` |
| | TaskID string `json:"taskId"` |
| | TaskInfos []BatchTaskInfo |
| | TaskType int `json:"taskType"` |
| | } |
| |
|
| | |
| | type Params map[string]string |
| |
|
| | func (p Params) Set(k, v string) { |
| | p[k] = v |
| | } |
| |
|
| | func (p Params) Encode() string { |
| | if p == nil { |
| | return "" |
| | } |
| | var buf strings.Builder |
| | keys := make([]string, 0, len(p)) |
| | for k := range p { |
| | keys = append(keys, k) |
| | } |
| | sort.Strings(keys) |
| | for i := range keys { |
| | if buf.Len() > 0 { |
| | buf.WriteByte('&') |
| | } |
| | buf.WriteString(keys[i]) |
| | buf.WriteByte('=') |
| | buf.WriteString(p[keys[i]]) |
| | } |
| | return buf.String() |
| | } |
| |
|