exchange_su_money.go 720 字节
package command

import (
	"fmt"

	"github.com/astaxie/beego/validation"
)

type ExchangeSuMoneyCommand struct {
	// 兑换人UID
	Uid int64 `json:"uid" valid:"Required"`
	// 素币值
	SuMoney float64 `json:"suMoney" valid:"Required"`
	// 操作人UID
	Operator int64 `json:"operator,omitempty"`
	// 兑换描述
	ExchangeDescription string `json:"exchangeDescription" valid:"Required"`
}

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