package sop_task

import (
	"net/http"

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

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

// swagger:route post /sop_task/copy sop_task SopTaskCopy
//
// task start | SopTask 复制
//
// task start | SopTask 复制
//
// Parameters:
//  + name: body
//    require: true
//    in: body
//    type: CopyReq
//
// Responses:
//  200: BaseMsgResp

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

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