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

func newLocalRejectDataHandler(ctx *gin.Context) *LocalRejectDataHandler {
	return &LocalRejectDataHandler{
		req:  http_model.NewLocalRejectDataRequest(),
		resp: http_model.NewLocalRejectDataResponse(),
		ctx:  ctx,
	}
}

type LocalRejectDataHandler struct {
	req  *http_model.LocalRejectDataRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

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

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