package handler

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

func WrapUpdateSupplierInvoiceHandler(ctx *gin.Context) {
	handler := newUpdateSupplierInvoiceHandler(ctx)
	baseRun(handler)
}

func newUpdateSupplierInvoiceHandler(ctx *gin.Context) *UpdateSupplierInvoiceHandler {
	return &UpdateSupplierInvoiceHandler{
		req:  http_model.NewUpdateSupplierInvoiceRequest(),
		resp: http_model.NewUpdateSupplierInvoiceResponse(),
		ctx:  ctx,
	}
}

type UpdateSupplierInvoiceHandler struct {
	req  *http_model.UpdateSupplierInvoiceRequest
	resp *http_model.CommonResponse
	ctx  *gin.Context
}

func (h *UpdateSupplierInvoiceHandler) getRequest() interface{} {
	return h.req
}
func (h *UpdateSupplierInvoiceHandler) getContext() *gin.Context {
	return h.ctx
}
func (h *UpdateSupplierInvoiceHandler) getResponse() interface{} {
	return h.resp
}
func (h *UpdateSupplierInvoiceHandler) run() {
	err := service.Supplier.UpdateSupplierInvoice(h.ctx, h.req)
	if err != nil {
		h.resp.Data = err.Error()
		h.resp.Message = "更新失败"
	}
	h.resp.Message = "更新成功"
}

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