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

type GetLocalRecruitTime struct {
	ctx  *gin.Context
	req  *http_model.GetLocalRecruitTimeRequest
	resp *http_model.CommonResponse
}

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

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

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

func (c GetLocalRecruitTime) run() {
	data := http_model.GetLocalRecruitTimeRequest{}
	data = *c.req
	res, err := service.LocalTask.GetLocalRecruitTime(c.ctx, data)
	if err != nil {
		logrus.Errorf("[GetLocalRecruitTime] call GetLocalRecruitTime err:%+v\n", err)
		util.HandlerPackErrorResp(c.resp, consts.ErrorParamCheck, "")
		logrus.Info("GetLocalRecruitTime fail,req:%+v", c.req)
		return
	}
	c.resp.Message = "成功查询招募截止时间"
	c.resp.Data = res
	c.resp.Status = consts.ErrorSuccess
}

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

func newGetLocalRecruitTimeHandler(ctx *gin.Context) *GetLocalRecruitTime {
	return &GetLocalRecruitTime{
		ctx:  ctx,
		req:  http_model.NewGetLocalRecruitTimeRequest(),
		resp: http_model.NewGetLocalRecruitTimeResponse(),
	}
}
