package handler

import (
	"github.com/gin-gonic/gin"
	"github.com/sirupsen/logrus"
	log "github.com/sirupsen/logrus"
	"youngee_b_api/consts"
	"youngee_b_api/model/http_model"
	"youngee_b_api/service"
	"youngee_b_api/util"
)

func WrapDeleteProjectHandler(ctx *gin.Context) {
	handler := newDeleteProjectHandler(ctx)
	baseRun(handler)
}

func newDeleteProjectHandler(ctx *gin.Context) *DeleteProjectHandler {
	return &DeleteProjectHandler{
		req:  http_model.NewDeleteProjectRequest(),
		resp: http_model.NewDeleteProjectResponse(),
		ctx:  ctx,
	}
}

type DeleteProjectHandler struct {
	req  *http_model.DeleteProjectRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

func (h *DeleteProjectHandler) getRequest() interface{} {
	return h.req
}
func (h *DeleteProjectHandler) getContext() *gin.Context {
	return h.ctx
}
func (h *DeleteProjectHandler) getResponse() interface{} {
	return h.resp
}
func (h *DeleteProjectHandler) run() {
	data := http_model.DeleteProjectRequest{}
	data = *h.req
	//auth := middleware.GetSessionAuth(h.ctx)
	//enterpriseID := auth.EnterpriseID
	res, err := service.Project.Delete(h.ctx, data.ProjectID)
	if err != nil {
		logrus.Errorf("[DeleteProjectHandler] call Show err:%+v\n", err)
		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
		log.Info("DeleteProject fail,req:%+v", h.req)
		return
	}
	//h.resp.Message = "成功删除项目"
	h.resp.Data = res
}
func (h *DeleteProjectHandler) checkParam() error {
	return nil
}
