create_cash_pool.go 594 字节
package command

import (
	"fmt"

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

// 创建现金池
type CreateCashPoolCommand struct {
	CompanyId int64 `json:"companyId" valid:"Required"`  // 公司ID
	Cash float64 `json:"cash" valid:"Required"` // 投入的现金值
}

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