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

func newGetContactInfoHandler(ctx *gin.Context) *GetContactInfoHandler {
	return &GetContactInfoHandler{
		req:  http_model.NewGetContactInfoRequest(),
		resp: http_model.NewGetContactInfoResponse(),
		ctx:  ctx,
	}
}

type GetContactInfoHandler struct {
	req  *http_model.GetContactInfoRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

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