package handler

import (
	"net/http"

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

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

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