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

type LocalTasksketchlist struct {
	ctx  *gin.Context
	req  *http_model.LocalTasksketchlistRequest
	resp *http_model.CommonResponse
}

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

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

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

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

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

func newLocalTasksketchlistHandler(ctx *gin.Context) *LocalTasksketchlist {
	return &LocalTasksketchlist{
		ctx:  ctx,
		req:  http_model.NewLocalTasksketchlistRequest(),
		resp: http_model.NewLocalTasksketchlistResponse(),
	}
}
