input_cash.go 658 字节
package command

import (
	"fmt"

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

type InputCashPooCommand struct {
	Cash float64 `json:"cash" valid:"Required"` 						// 投入的现金值
	Operator int64 `json:"operator,omitempty"`							// 操作人UID
	InputDescription string `json:"inputDescription" valid:"Required"` 	// 投入描述
}

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