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

type LocalTaskLinklist struct {
	ctx  *gin.Context
	req  *http_model.LocalTaskLinklistRequest
	resp *http_model.CommonResponse
}

func (c LocalTaskLinklist) getContext() *gin.Context {
	return c.ctx
}

func (c LocalTaskLinklist) getResponse() interface{} {
	return c.resp
}

func (c LocalTaskLinklist) getRequest() interface{} {
	return c.req
}

func (c LocalTaskLinklist) run() {
	data := http_model.LocalTaskLinklistRequest{}
	data = *c.req
	res, err := service.LocalTask.GetLocalTaskLinklist(c.ctx, data)
	if err != nil {
		logrus.Errorf("[GetLocalTaskLinklist] call GetLocalTaskLinklist err:%+v\n", err)
		util.HandlerPackErrorResp(c.resp, consts.ErrorParamCheck, "")
		logrus.Info("GetLocalTaskLinklist fail,req:%+v", c.req)
		return
	}
	c.resp.Message = "成功查询链接待审列表"
	c.resp.Data = res
	c.resp.Status = consts.ErrorSuccess
}

func (c LocalTaskLinklist) checkParam() error {
	return nil
}

func newLocalTaskLinklistHandler(ctx *gin.Context) *LocalTaskLinklist {
	return &LocalTaskLinklist{
		ctx:  ctx,
		req:  http_model.NewLocalTaskLinklistRequest(),
		resp: http_model.NewLocalTaskLinklistResponse(),
	}
}
