package handler

import (
	"github.com/gin-gonic/gin"
	"github.com/sirupsen/logrus"
	"youngee_b_api/consts"
	"youngee_b_api/model/http_model"
	"youngee_b_api/service"
	"youngee_b_api/util"
)

func WrapLocalPreDataListHandler(ctx *gin.Context) {
	handler := newLocalPreDataListHandler(ctx)
	baseRun(handler)
}

func newLocalPreDataListHandler(ctx *gin.Context) *LocalPreDataListHandler {
	return &LocalPreDataListHandler{
		req:  http_model.NewLocalPreDataListRequest(),
		resp: http_model.NewLocalPreDataListResponse(),
		ctx:  ctx,
	}
}

type LocalPreDataListHandler struct {
	req  *http_model.LocalPreDataListRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

func (h LocalPreDataListHandler) getRequest() interface{} {
	return h.req
}
func (h LocalPreDataListHandler) getContext() *gin.Context {
	return h.ctx
}
func (h LocalPreDataListHandler) getResponse() interface{} {
	return h.resp
}
func (h LocalPreDataListHandler) run() {
	data := http_model.LocalPreDataListRequest{}
	data = *h.req
	res, err := service.LocalTask.GetLocalPreDataList(h.ctx, data)
	if err != nil {
		logrus.Errorf("[GetLocalPreDataList] call GetLocalPreDataList err:%+v\n", err)
		util.HandlerPackErrorResp(h.resp, consts.ErrorParamCheck, "")
		logrus.Info("GetLocalPreDataList fail,req:%+v", h.req)
		return
	}
	h.resp.Message = "成功查询数据待传列表"
	h.resp.Data = res
	h.resp.Status = consts.ErrorSuccess
}

func (h LocalPreDataListHandler) checkParam() error {
	return nil
}
