package category

import (
	"net/http"

	"github.com/zeromicro/go-zero/rest/httpx"

	"wechat-api/internal/logic/category"
	"wechat-api/internal/svc"
)

// swagger:route post /api/category/list category GetApiCategoryList
//
// Get category list | 获取 category 列表
//
// Get category list | 获取 category 列表
//
// Responses:
//  200: CategoryListResp

func GetApiCategoryListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		l := category.NewGetApiCategoryListLogic(r.Context(), svcCtx)
		resp, err := l.GetApiCategoryList()
		if err != nil {
			httpx.ErrorCtx(r.Context(), w, err)
		} else {
			httpx.OkJsonCtx(r.Context(), w, resp)
		}
	}
}
