package handler

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

func WrapCreateSupplierWithdrawHandler(ctx *gin.Context) {
	handler := newCreateSupplierWithdrawHandler(ctx)
	baseRun(handler)
}

func newCreateSupplierWithdrawHandler(ctx *gin.Context) *CreateSupplierWithdrawHandler {
	return &CreateSupplierWithdrawHandler{
		req:  http_model.NewCreateSupplierWithdrawRequest(),
		resp: http_model.NewCreateSupplierWithdrawResponse(),
		ctx:  ctx,
	}
}

type CreateSupplierWithdrawHandler struct {
	req  *http_model.CreateSupplierWithdrawRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

func (h *CreateSupplierWithdrawHandler) getRequest() interface{} {
	return h.req
}
func (h *CreateSupplierWithdrawHandler) getContext() *gin.Context {
	return h.ctx
}
func (h *CreateSupplierWithdrawHandler) getResponse() interface{} {
	return h.resp
}
func (h *CreateSupplierWithdrawHandler) run() {
	err := service.Supplier.CreateSupplierWithdraw(h.ctx, h.req)
	if err != nil {
		h.resp.Status = 40000
		h.resp.Message = err.Error()
		return
	}
	h.resp.Message = "成功添加"
}

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