package handler

import (
	"youngee_b_api/consts"
	"youngee_b_api/model/http_model"
	"youngee_b_api/service"
	"youngee_b_api/util"

	"github.com/gin-gonic/gin"
	"github.com/sirupsen/logrus"
	log "github.com/sirupsen/logrus"
)

func WrapRejectLinkHandler(ctx *gin.Context) {
	handler := newRejectLinkHandler(ctx)
	baseRun(handler)
}

func newRejectLinkHandler(ctx *gin.Context) *RejectLinkHandler {
	return &RejectLinkHandler{
		req:  http_model.NewRejectLinkRequest(),
		resp: http_model.NewRejectLinkResponse(),
		ctx:  ctx,
	}
}

type RejectLinkHandler struct {
	req  *http_model.RejectLinkRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

func (h *RejectLinkHandler) getRequest() interface{} {
	return h.req
}
func (h *RejectLinkHandler) getContext() *gin.Context {
	return h.ctx
}
func (h *RejectLinkHandler) getResponse() interface{} {
	return h.resp
}

func (h *RejectLinkHandler) run() {
	data := http_model.RejectLinkRequest{}
	data = *h.req
	res, err := service.Link.RejectLink(h.ctx, data)
	if err != nil {
		logrus.Errorf("[ReviseOpinionHandler] call Create err:%+v\n", err)
		util.HandlerPackErrorResp(h.resp, consts.ErrorParamCheck, "")
		log.Info("CreateProject fail,req:%+v", h.req)
		return
	}
	h.resp.Message = "成功拒绝链接"
	h.resp.Data = res
	h.resp.Status = consts.ErrorSuccess
}

func (h *RejectLinkHandler) checkParam() error {
	return nil
}
