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

type GetLocalTaskList struct {
	ctx  *gin.Context
	req  *http_model.GetLocalTaskListRequest
	resp *http_model.CommonResponse
}

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

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

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

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

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

func newGetLocalTaskListHandler(ctx *gin.Context) *GetLocalTaskList {
	return &GetLocalTaskList{
		ctx:  ctx,
		req:  http_model.NewGetLocalTaskListRequest(),
		resp: http_model.NewGetLocalTaskListResponse(),
	}
}
