package handler

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"youngee_b_api/model/http_model"
	"youngee_b_api/service"
)

func WrapEnterpriseListHandler(ctx *gin.Context) {
	handler := newEnterpriseListHandler(ctx)
	baseRun(handler)
}

func newEnterpriseListHandler(ctx *gin.Context) *EnterpriseListHandler {
	return &EnterpriseListHandler{
		req:  http_model.NewEnterpriseListRequest(),
		resp: http_model.NewEnterpriseListResponse(),
		ctx:  ctx,
	}
}

type EnterpriseListHandler struct {
	req  *http_model.EnterpriseListRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

func (h *EnterpriseListHandler) getRequest() interface{} {
	return h.req
}
func (h *EnterpriseListHandler) getContext() *gin.Context {
	return h.ctx
}
func (h *EnterpriseListHandler) getResponse() interface{} {
	return h.resp
}
func (h *EnterpriseListHandler) run() {
	enterpriseListData, err := service.Cooperate.GetEnterpriseInfoBySupplierId(h.ctx, h.req)
	if err != nil {
		h.resp.Message = "查询失败"
		h.resp.Data = err
		fmt.Println(err)
	}
	h.resp.Message = "成功查询商家合作信息"
	h.resp.Data = enterpriseListData
}
func (h *EnterpriseListHandler) checkParam() error {
	return nil
}
