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

type GetProjectTalent struct {
	ctx  *gin.Context
	req  *http_model.GetProjectTalentRequest
	resp *http_model.CommonResponse
}

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

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

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

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

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

func newGetProjectTalentHandler(ctx *gin.Context) *GetProjectTalent {
	return &GetProjectTalent{
		ctx:  ctx,
		req:  http_model.NewGetProjectTalentRequest(),
		resp: http_model.NewGetProjectTalentResponse(),
	}
}
