package handler

import (
	"youngee_b_api/consts"
	"youngee_b_api/model/http_model"
	"youngee_b_api/service"
	"youngee_b_api/util"

	"github.com/gin-gonic/gin"
	"github.com/sirupsen/logrus"
	log "github.com/sirupsen/logrus"
)

func WrapPaySumHandler(ctx *gin.Context) {
	handler := newPaySumHandler(ctx)
	baseRun(handler)
}

func newPaySumHandler(ctx *gin.Context) *PaySumHandler {
	return &PaySumHandler{
		req:  http_model.NewPaySumRequest(),
		resp: http_model.NewPaySumResponse(),
		ctx:  ctx,
	}
}

type PaySumHandler struct {
	req  *http_model.PaySumRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

func (h *PaySumHandler) getRequest() interface{} {
	return h.req
}
func (h *PaySumHandler) getContext() *gin.Context {
	return h.ctx
}
func (h *PaySumHandler) getResponse() interface{} {
	return h.resp
}
func (h *PaySumHandler) run() {
	data := http_model.PaySumRequest{}
	data = *h.req
	//auth := middleware.GetSessionAuth(h.ctx)
	//enterpriseID := auth.EnterpriseID
	res, err := service.Pay.GetPaysum(h.ctx, data)
	if err != nil {
		// 数据库查询失败，返回5001
		logrus.Errorf("[FindAllProductHandler] call FindAll err:%+v\n", err)
		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
		log.Info("FindAllProduct fail,req:%+v", h.req)
		return
	}
	// h.resp.Message = "查询成功"
	h.resp.Data = res
}
func (h *PaySumHandler) checkParam() error {
	return nil
}
