operation_su_money.go
826 字节
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type OperationSuMoneyCommand struct {
Uid int64 `json:"uid" valid:"Required"` // 素币拥有者UID
OperationType int `json:"operationType" valid:"Required"` // 操作类型(1增加,2扣除)
SuMoney float64 `json:"suMoney" valid:"Required"` // 素币值
Operator int64 `json:"operator,omitempty"` // 操作人UID
OperationDescription string `json:"operationDescription" valid:"Required"` // 理由描述
}
func (operationSuMoneyCommand *OperationSuMoneyCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(operationSuMoneyCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}