login_sms.go 731 字节
package command

import (
	"fmt"

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

type LoginSmsCommand struct {
	Phone       string `json:"phone"  valid:"Required"`
	Code        string `json:"code"  valid:"Required"` //登录方式(signInPassword 密码登录、signInCaptcha 验证码登录)
	SessionMode int    `json:"sessionMode"`
	DeviceType  string `json:"-"`
}

func (cmd *LoginSmsCommand) Valid(validation *validation.Validation) {

}

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