operation_su_money.go
831 字节
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type OperationSuMoneyCommand struct {
// 素币拥有者UID
Uid int64 `json:"uid" valid:"Required"`
// 操作类型(1增加,2扣除)
OperationType int `json:"operationType" valid:"Required"`
// 素币值
SuMoney float64 `json:"suMoney" valid:"Required"`
// 操作人UID
Operator int64 `json:"operator,omitempty"`
// 理由描述
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
}