package handler

import (
	"jyBXBase/api/internal/types"
	"net/http"

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

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

		l := logic.NewLabelActionLogic(r.Context(), svcCtx)
		resp, err := l.LabelAction(&req)
		if err != nil {
			httpx.Error(w, err)
		} else {
			httpx.OkJson(w, resp)
		}
	}
}
