mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 06:47:20 +08:00
30 lines
576 B
Go
30 lines
576 B
Go
package api
|
|
|
|
import "fmt"
|
|
|
|
type Category struct {
|
|
Slug string `json:"slug"`
|
|
Name string `json:"name"`
|
|
Order int `json:"order"`
|
|
}
|
|
|
|
type Categories []*Category
|
|
|
|
// Categories 返回所有分类
|
|
func (r *API) Categories() (*Categories, error) {
|
|
resp, err := r.client.R().SetResult(&Response{}).Get("/categories")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if !resp.IsSuccess() {
|
|
return nil, fmt.Errorf("failed to get categories: %s", resp.String())
|
|
}
|
|
|
|
categories, err := getResponseData[Categories](resp)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return categories, nil
|
|
}
|