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

type GetLocallifeTalent struct {
	ctx  *gin.Context
	req  *http_model.GetLocallifeTalentRequest
	resp *http_model.CommonResponse
}

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

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

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

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

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

func newGetLocallifeTalentHandler(ctx *gin.Context) *GetLocallifeTalent {
	return &GetLocallifeTalent{
		ctx:  ctx,
		req:  http_model.NewGetLocallifeTalentRequest(),
		resp: http_model.NewGetLocallifeTalentResponse(),
	}
}
