login.go 892 字节
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"`
	SessionMode   int    `json:"sessionMode"`
	DeviceType    string `json:"-"`
	LoginPlatform string `json:"-"` //登录平台
}

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
}