作者 yangfu

增加 短信验证码验证手机号

分红合约分页修改
... ... @@ -8,15 +8,22 @@ import (
type SendSmsCodeCommand struct {
Phone string `json:"phone" valid:"Required"`
// 0:无 1:需要账号存在于账号系统内,才能发送验证码
Flag int `json:"flag"`
// [1:登录][2:修改密码][3:找回密码][4:注册][5:修改手机号]
Action int `json:"action"`
}
func (orgAddCommand *SendSmsCodeCommand) Valid(validation *validation.Validation) {
func (cmd *SendSmsCodeCommand) Valid(validation *validation.Validation) {
}
func (orgAddCommand *SendSmsCodeCommand) ValidateCommand() error {
func (cmd *SendSmsCodeCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(orgAddCommand)
b, err := valid.Valid(cmd)
if cmd.Action == 1 || cmd.Action == 2 || cmd.Action == 3 {
cmd.Flag = 1
}
if err != nil {
return err
}
... ...
... ... @@ -171,6 +171,18 @@ func (svr AuthService) AuthLoginQrcodeBinding(bindingCmd *command.QrcodeBindingC
//SendSmsCaptcha 发送验证码短信
func (svr AuthService) SendSmsCaptcha(smsCodeCommand *command.SendSmsCodeCommand) error {
if err := smsCodeCommand.ValidateCommand(); err != nil {
return application.ThrowError(application.ARG_ERROR, err.Error())
}
if smsCodeCommand.Flag == 1 {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
userBase, err := creationUserGateway.AuthUserBaseInfo(allied_creation_user.ReqAuthUserBase{
Account: smsCodeCommand.Phone,
})
if err != nil || userBase.UserInfo.Phone != smsCodeCommand.Phone {
return application.ThrowError(application.TRANSACTION_ERROR, "输入的手机号不是平台用户,请重新输入")
}
}
smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
err := smsServeGateway.SendSms(smsCodeCommand.Phone)
if err != nil {
... ...
... ... @@ -11,7 +11,7 @@ type SearchDividendContractsCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 查询偏离量
PageNumber int `json:"pageIndex" valid:"Required"`
PageNumber int `json:"pageNumber" valid:"Required"`
// 查询限制
PageSize int `json:"pageSize" valid:"Required"`
//审核状态
... ...
... ... @@ -8,6 +8,8 @@ import (
type SendSmsCodeCommand struct {
Phone string `json:"phone" valid:"Required"`
// 0:无 1:需要账号存在于账号系统内,才能发送验证码
Flag int `json:"flag"`
}
func (orgAddCommand *SendSmsCodeCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -19,6 +19,15 @@ type UserService struct {
//SendSmsCaptcha 发送验证码短信
func (srv UserService) SendSmsCaptcha(smsCodeCommand *command.SendSmsCodeCommand) error {
if smsCodeCommand.Flag == 1 {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
userBase, err := creationUserGateway.AuthUserBaseInfo(allied_creation_user.ReqAuthUserBase{
Account: smsCodeCommand.Phone,
})
if err != nil || userBase.UserInfo.Phone != smsCodeCommand.Phone {
return application.ThrowError(application.TRANSACTION_ERROR, "输入的手机号不是平台用户,请重新输入")
}
}
smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
err := smsServeGateway.SendSms(smsCodeCommand.Phone)
if err != nil {
... ...