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

type RefuselocalTaskCoop struct {
	ctx  *gin.Context
	req  *http_model.RefuselocalTaskCoopRequest
	resp *http_model.CommonResponse
}

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

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

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

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

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

func newRefuselocalTaskCoopHandler(ctx *gin.Context) *RefuselocalTaskCoop {
	return &RefuselocalTaskCoop{
		ctx:  ctx,
		req:  http_model.NewRefuselocalTaskCoopRequest(),
		resp: http_model.NewRefuselocalTaskCoopResponse(),
	}
}
