create_customer_value.go
620 字节
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type CreateCustomerValueCommand struct {
// 公司ID
CompanyId int64 `json:"companyId" valid:"Required"`
// 客户价值名称
CustomerValueName string `json:"customerValueName" valid:"Required"`
}
func (createCustomerValueCommand *CreateCustomerValueCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(createCustomerValueCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}