create_cash_pool.go 1.1 KB
package command

import (
	"fmt"

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

// 创建现金池
type CreateCashPoolCommand struct {
	//CashPoolId int64 `json:"cashPoolId" valid:"Required"` // 现金池ID
	CompanyId int64 `json:"companyId" valid:"Required"`  // 公司ID
	Cash float64 `json:"cash" valid:"Required"` // 投入的现金值
	ExchangedCash float64 `json:"exchangedCash,omitempty"`  // 现金池已兑换现金值
	UnExchangeCash float64 `json:"unExchangeCash,omitempty"` // 现金池未兑换现金值
	ExchangedSuMoney float64 `json:"exchangedSuMoney,omitempty"`  // 现金池已兑换素币值
	UnExchangeSuMoney float64 `json:"unExchangeSuMoney,omitempty"`  // 现金池未兑换素币值
	Operator int64 `json:"operator,omitempty"`	// 操作人UID
}

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
}