package UsageTotal

import (
	"net/http"

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

	"wechat-api/internal/logic/UsageTotal"
	"wechat-api/internal/svc"
	"wechat-api/internal/types"
)

// swagger:route post /usage_total/list UsageTotal GetUsageTotalList
//
// Get usage total list | 获取Wx列表
//
// Get usage total list | 获取Wx列表
//
// Parameters:
//  + name: body
//    require: true
//    in: body
//    type: UsageTotalListReq
//
// Responses:
//  200: UsageTotalListResp

func GetUsageTotalListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var req types.UsageTotalListReq
		if err := httpx.Parse(r, &req, true); err != nil {
			httpx.ErrorCtx(r.Context(), w, err)
			return
		}

		l := UsageTotal.NewGetUsageTotalListLogic(r.Context(), svcCtx)
		resp, err := l.GetUsageTotalList(&req)
		if err != nil {
			httpx.ErrorCtx(r.Context(), w, err)
		} else {
			httpx.OkJsonCtx(r.Context(), w, resp)
		}
	}
}
