package handler

import (
	"github.com/gin-gonic/gin"
	"github.com/sirupsen/logrus"
	"youngee_b_api/consts"
	"youngee_b_api/model/http_model"
	"youngee_b_api/pack"
	"youngee_b_api/service"
	"youngee_b_api/util"
)

func WrapFullListHandler(ctx *gin.Context) {
	handler := newFullListHandler(ctx)
	baseRun(handler)
}

func newFullListHandler(ctx *gin.Context) *FullListHandler {
	return &FullListHandler{
		req:  http_model.NewFullListRequest(),
		resp: http_model.NewFullListResponse(),
		ctx:  ctx,
	}
}

type FullListHandler struct {
	req  *http_model.FullListRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

func (h *FullListHandler) getRequest() interface{} {
	return h.req
}
func (h *FullListHandler) getContext() *gin.Context {
	return h.ctx
}
func (h *FullListHandler) getResponse() interface{} {
	return h.resp
}
func (h *FullListHandler) run() {
	// enterpriseID := middleware.GetSessionAuth(h.ctx).EnterpriseID
	condition := pack.HttpFullLocalLifeListRequestToCondition(h.req)
	data, err := service.LocalLife.GetFullLocalLifeList(h.ctx, h.req.PageSize, h.req.PageNum, h.req.SupplierId, condition)
	if err != nil {
		logrus.WithContext(h.ctx).Errorf("[FullListHandler] error GetFullProjectList, err:%+v", err)
		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, consts.DefaultToast)
		return
	}
	h.resp.Data = data
}
func (h *FullListHandler) checkParam() error {
	return nil
}
