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

func newLocalAcceptLinkHandler(ctx *gin.Context) *LocalAcceptLinkHandler {
	return &LocalAcceptLinkHandler{
		req:  http_model.NewLocalAcceptLinkRequest(),
		resp: http_model.NewLocalAcceptLinkResponse(),
		ctx:  ctx,
	}
}

type LocalAcceptLinkHandler struct {
	req  *http_model.LocalAcceptLinkRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

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

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