package handler

import (
	"youngee_b_api/consts"
	"youngee_b_api/model/http_model"
	"youngee_b_api/service"
	"youngee_b_api/util"

	"github.com/gin-gonic/gin"
	"github.com/sirupsen/logrus"
	log "github.com/sirupsen/logrus"
)

// WrapGetSketchRecordListHandler

func WrapGetSketchRecordListHandler(ctx *gin.Context) {
	handler := newGetSketchRecordListHandler(ctx)
	baseRun(handler)
}

func newGetSketchRecordListHandler(ctx *gin.Context) *GetSketchRecordListHandler {
	return &GetSketchRecordListHandler{
		req:  http_model.NewGetSketchRecordListRequest(),
		resp: http_model.NewGetSketchRecordListResponse(),
		ctx:  ctx,
	}
}

type GetSketchRecordListHandler struct {
	req  *http_model.GetSketchRecordListRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

func (h *GetSketchRecordListHandler) getRequest() interface{} {
	return h.req
}
func (h *GetSketchRecordListHandler) getContext() *gin.Context {
	return h.ctx
}
func (h *GetSketchRecordListHandler) getResponse() interface{} {
	return h.resp
}
func (h *GetSketchRecordListHandler) run() {
	data := *&http_model.GetSketchRecordListRequest{}
	data = *h.req
	res, err := service.Sketch.GetSketchRecordList(h.ctx, data)
	if err != nil {
		// 数据库查询失败，返回5001
		logrus.Errorf("[GetSketchRecordListHandler] call GetByID err:%+v\n", err)
		util.HandlerPackErrorResp(h.resp, consts.ErrorParamCheck, "")
		log.Info("GetProduct fail,req:%+v", h.req)
		return
	}
	h.resp.Data = res
	h.resp.Status = consts.ErrorSuccess
}
func (h *GetSketchRecordListHandler) checkParam() error {
	return nil
}
