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

func newShowTaskProgressHandler(ctx *gin.Context) *ShowTaskProgressHandler {
	return &ShowTaskProgressHandler{
		req:  http_model.NewShowTaskProgressRequest(),
		resp: http_model.NewShowTaskProgressResponse(),
		ctx:  ctx,
	}
}

type ShowTaskProgressHandler struct {
	req  *http_model.ShowTaskProgressRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

func (h *ShowTaskProgressHandler) getRequest() interface{} {
	return h.req
}
func (h *ShowTaskProgressHandler) getContext() *gin.Context {
	return h.ctx
}
func (h *ShowTaskProgressHandler) getResponse() interface{} {
	return h.resp
}
func (h *ShowTaskProgressHandler) run() {
	// fmt.Println("ShowTaskProgressHandler: ")
	data, err := service.Project.ShowTaskProgress(h.ctx, *h.req)
	if err != nil {
		logrus.WithContext(h.ctx).Errorf("[ProjectTaskListHandler] error GetProjectTaskList, err:%+v", err)
		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, consts.DefaultToast)
		return
	}
	h.resp.Data = data
}
func (h *ShowTaskProgressHandler) checkParam() error {
	return nil
}
