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

func newPreLinkListHandler(ctx *gin.Context) *PreLinkListHandler {
	return &PreLinkListHandler{
		req:  http_model.NewPreLinkListRequest(),
		resp: http_model.NewPreLinkListResponse(),
		ctx:  ctx,
	}
}

type PreLinkListHandler struct {
	req  *http_model.PreLinkListRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

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

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