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

type PreSketchList struct {
	ctx  *gin.Context
	req  *http_model.PreSketchListRequest
	resp *http_model.CommonResponse
}

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

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

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

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

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

func newPreSketchListHandler(ctx *gin.Context) *PreSketchList {
	return &PreSketchList{
		ctx:  ctx,
		req:  http_model.NewPreSketchListRequest(),
		resp: http_model.NewPreSketchListResponse(),
	}
}
