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

func newSpecialProjectListHandler(ctx *gin.Context) *SpecialProjectListHandler {
	return &SpecialProjectListHandler{
		req:  http_model.NewSpecialProjectListRequest(),
		resp: http_model.NewSpecialProjectListResponse(),
		ctx:  ctx,
	}
}

type SpecialProjectListHandler struct {
	req  *http_model.SpecialProjectListRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

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

func (h *SpecialProjectListHandler) getContext() *gin.Context {
	return h.ctx
}

func (h *SpecialProjectListHandler) getResponse() interface{} {
	return h.resp
}

func (h *SpecialProjectListHandler) run() {
	condition := pack.HttpSpecialProjectRequestToCondition(h.req)
	data, err := service.SProject.GetSpecialProjectList(h.ctx, h.req.SupplierId, h.req.PageSize, h.req.PageNum, condition)
	if err != nil {
		logrus.WithContext(h.ctx).Errorf("[FullProjectListHandler] error GetFullProjectList, err:%+v", err)
		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, consts.DefaultToast)
		return
	}
	h.resp.Status = 20000
	h.resp.Data = data
}

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