update_order.go 900 字节
package command

import (
	"fmt"

	"github.com/beego/beego/v2/core/validation"
)

type UpdateOrderCommand struct {
	// 订单id
	OrderId int64 `json:"orderId" valid:"Required"`
	// 发货地址
	BuyerName string `json:"buyerName"`
	// 订单商品总数
	OrderNum int `json:"orderNum"`
	// 订单总价
	TotalPrice float64 `json:"totalPrice"`
	// 收货地址
	ShippingAddress string `json:"shippingAddress,omitempty"`
}

func (updateOrderCommand *UpdateOrderCommand) Valid(validation *validation.Validation) {
	//validation.SetError("CustomValid", "未实现的自定义认证")
}

func (updateOrderCommand *UpdateOrderCommand) ValidateCommand() error {
	valid := validation.Validation{}
	b, err := valid.Valid(updateOrderCommand)
	if err != nil {
		return err
	}
	if !b {
		for _, validErr := range valid.Errors {
			return fmt.Errorf("%s  %s", validErr.Key, validErr.Message)
		}
	}
	return nil
}