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

func newGetAccountInfoHandler(ctx *gin.Context) *GetAccountInfoHandler {
	return &GetAccountInfoHandler{
		req:  http_model.NewGetAccountInfoRequest(),
		resp: http_model.NewGetAccountInfoResponse(),
		ctx:  ctx,
	}
}

type GetAccountInfoHandler struct {
	req  *http_model.GetAccountInfoRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

func (h *GetAccountInfoHandler) getRequest() interface{} {
	return h.req
}
func (h *GetAccountInfoHandler) getContext() *gin.Context {
	return h.ctx
}
func (h *GetAccountInfoHandler) getResponse() interface{} {
	return h.resp
}
func (h *GetAccountInfoHandler) run() {
	data, err := service.Enterprise.GetEnterpriseAccountInfo(h.ctx, h.req)
	if err != nil {
		logrus.Errorf("[GetEnterpriseAccountInfo] call SetSession err:%+v\n", err)
		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, err.Error())
		log.Info("GetEnterpriseAccountInfo 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 *GetAccountInfoHandler) checkParam() error {
	return nil
}
