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 WrapLocalRejectLinkHandler(ctx *gin.Context) {
	handler := newLocalRejectLinkHandler(ctx)
	baseRun(handler)
}

func newLocalRejectLinkHandler(ctx *gin.Context) *LocalRejectLinkHandler {
	return &LocalRejectLinkHandler{
		req:  http_model.NewLocalRejectLinkRequest(),
		resp: http_model.NewLocalRejectLinkResponse(),
		ctx:  ctx,
	}
}

type LocalRejectLinkHandler struct {
	req  *http_model.LocalRejectLinkRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

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

func (h *LocalRejectLinkHandler) run() {
	data := http_model.LocalRejectLinkRequest{}
	data = *h.req
	res, err := service.Link.LocalRejectLink(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 *LocalRejectLinkHandler) checkParam() error {
	return nil
}
