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

func newGetReviewInfoHandler(ctx *gin.Context) *GetReviewInfoHandler {
	return &GetReviewInfoHandler{
		req:  http_model.NewGetReviewInfoRequest(),
		resp: http_model.NewGetReviewInfoResponse(),
		ctx:  ctx,
	}
}

type GetReviewInfoHandler struct {
	req  *http_model.GetReviewInfoRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

func (h *GetReviewInfoHandler) getRequest() interface{} {
	return h.req
}

func (h *GetReviewInfoHandler) getContext() *gin.Context {
	return h.ctx
}
func (h *GetReviewInfoHandler) getResponse() interface{} {
	return h.resp
}
func (h *GetReviewInfoHandler) run() {
	data, err := service.Enterprise.GetEnterpriseReviewInfo(h.ctx, h.req)
	if err != nil {
		logrus.Errorf("[GetEnterpriseReviewInfo] call SetSession err:%+v\n", err)
		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, err.Error())
		log.Info("GetEnterpriseReviewInfo fail,req:%+v", h.req)
		h.resp.Message = err.Error()
		h.resp.Status = 40000
		return
	}
	h.resp.Data = data
	h.resp.Status = 20000
	h.resp.Message = "ok"
}

func (h *GetReviewInfoHandler) checkParam() error {
	return nil
}
