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

func newLocalPreLinkListHandler(ctx *gin.Context) *LocalPreLinkListHandler {
	return &LocalPreLinkListHandler{
		req:  http_model.NewLocalPreLinkListRequest(),
		resp: http_model.NewLocalPreLinkListResponse(),
		ctx:  ctx,
	}
}

type LocalPreLinkListHandler struct {
	req  *http_model.LocalPreLinkListRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

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

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