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

func newLocalDataOpinionHandler(ctx *gin.Context) *LocalDataOpinionHandler {
	return &LocalDataOpinionHandler{
		req:  http_model.NewLocalDataOpinionRequest(),
		resp: http_model.NewLocalDataOpinionResponse(),
		ctx:  ctx,
	}
}

type LocalDataOpinionHandler struct {
	req  *http_model.LocalDataOpinionRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

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

func (h *LocalDataOpinionHandler) run() {
	data := http_model.LocalDataOpinionRequest{}
	data = *h.req
	res, err := service.Data.LocalDataOpinion(h.ctx, data)
	if err != nil {
		logrus.Errorf("[LocalDataOpinionHandler] 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 *LocalDataOpinionHandler) checkParam() error {
	return nil
}
