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

type RefuseproTaskCoop struct {
	ctx  *gin.Context
	req  *http_model.RefuseproTaskCoopRequest
	resp *http_model.CommonResponse
}

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

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

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

func (c RefuseproTaskCoop) run() {
	data := http_model.RefuseproTaskCoopRequest{}
	data = *c.req
	//auth := middleware.GetSessionAuth(c.ctx)
	//enterpriseID := auth.EnterpriseID
	res, err := service.Task.RefuseCoop(c.ctx, data)
	if err != nil {
		logrus.Errorf("[RefuseproTaskCoop] call RefuseproTaskCoop err:%+v\n", err)
		util.HandlerPackErrorResp(c.resp, consts.ErrorParamCheck, "")
		logrus.Info("RefuseproTaskCoop fail,req:%+v", c.req)
		return
	}
	c.resp.Message = "成功拒绝种草任务"
	c.resp.Data = res
	c.resp.Status = consts.ErrorSuccess
}

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

func newRefuseproTaskCoopHandler(ctx *gin.Context) *RefuseproTaskCoop {
	return &RefuseproTaskCoop{
		ctx:  ctx,
		req:  http_model.NewRefuseproTaskCoopRequest(),
		resp: http_model.NewRefuseproTaskCoopResponse(),
	}
}
