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

func newRejectDataHandler(ctx *gin.Context) *RejectDataHandler {
	return &RejectDataHandler{
		req:  http_model.NewRejectDataRequest(),
		resp: http_model.NewRejectDataResponse(),
		ctx:  ctx,
	}
}

type RejectDataHandler struct {
	req  *http_model.RejectDataRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

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

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