package handler

import (
	"net/http"

	"github.com/zeromicro/go-zero/rest/httpx"
	"jyBXCore/api/internal/logic"
	"jyBXCore/api/internal/svc"
	"jyBXCore/api/internal/types"
)

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

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