Files
2026-07-27 19:31:43 +08:00

37 lines
795 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package template
import "litepan/internal/domain"
type listData struct {
Items []fileEntry `json:"items"`
}
type fileEntry struct {
ID string `json:"id"`
Name string `json:"name"`
Size int64 `json:"size"`
IsDir bool `json:"is_dir"`
}
func (e fileEntry) toDomain() domain.FileItem {
return domain.FileItem{
ID: e.ID,
Name: e.Name,
Size: e.Size,
IsDir: e.IsDir,
}
}
func mapAPIError(code int, msg string) error {
switch code {
case 401:
return domain.Errorf(domain.CodeAuthExpired, "平台认证失败:%s", msg)
case 429:
return domain.Errorf(domain.CodeRateLimited, "平台接口限流:%s", msg)
case 404:
return domain.Errf(domain.CodeNotFound)
default:
return domain.Errorf(domain.CodeDriverError, "平台 API 错误(%d):%s", code, msg)
}
}