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

type LocalPreSketchList struct {
	ctx  *gin.Context
	req  *http_model.LocalPreSketchListRequest
	resp *http_model.CommonResponse
}

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

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

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

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

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

func newLocalPreSketchListHandler(ctx *gin.Context) *LocalPreSketchList {
	return &LocalPreSketchList{
		ctx:  ctx,
		req:  http_model.NewLocalPreSketchListRequest(),
		resp: http_model.NewLocalPreSketchListResponse(),
	}
}
