login.go 752 字节
package command

import (
	"fmt"

	"github.com/beego/beego/v2/core/validation"
)

type LoginCommand struct {
	Phone     string `json:"phone"  valid:"Required"`
	GrantType string `json:"grantType"  valid:"Required"` //登录方式(signInPassword 密码登录、signInCaptcha 验证码登录)
	Password  string `json:"password"`
	Captcha   string `json:"captcha"`
}

func (orgAddCommand *LoginCommand) Valid(validation *validation.Validation) {

}

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