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

type GetGoodsTalent struct {
	ctx  *gin.Context
	req  *http_model.GetGoodsTalentRequest
	resp *http_model.CommonResponse
}

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

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

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

func (c GetGoodsTalent) run() {
	data := http_model.GetGoodsTalentRequest{}
	data = *c.req
	res, err := service.Talent.GetGoodsTalentList(c.ctx, data)
	if err != nil {
		logrus.Errorf("[GetGoodsTalentList] call GetGoodsTalentList err:%+v\n", err)
		util.HandlerPackErrorResp(c.resp, consts.ErrorParamCheck, "")
		logrus.Info("GetGoodsTalentList fail,req:%+v", c.req)
		return
	}
	c.resp.Message = "成功查询带货达人"
	c.resp.Data = res
	c.resp.Status = consts.ErrorSuccess
}

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

func newGetGoodsTalentHandler(ctx *gin.Context) *GetGoodsTalent {
	return &GetGoodsTalent{
		ctx:  ctx,
		req:  http_model.NewGetGoodsTalentRequest(),
		resp: http_model.NewGetGoodsTalentResponse(),
	}
}
