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

func newLocalAcceptDataHandler(ctx *gin.Context) *LocalAcceptDataHandler {
	return &LocalAcceptDataHandler{
		req:  http_model.NewLocalAcceptDataRequest(),
		resp: http_model.NewLocalAcceptDataResponse(),
		ctx:  ctx,
	}
}

type LocalAcceptDataHandler struct {
	req  *http_model.LocalAcceptDataRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

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

func (h *LocalAcceptDataHandler) run() {
	data := http_model.LocalAcceptDataRequest{}
	data = *h.req
	res, err := service.Data.LocalAcceptData(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 *LocalAcceptDataHandler) checkParam() error {
	return nil
}
