作者 yangfu

1.登录验证码登录修改

@@ -39,11 +39,11 @@ func (this *AuthController) SmsCode() { @@ -39,11 +39,11 @@ func (this *AuthController) SmsCode() {
39 }() 39 }()
40 var request *protocol.SmsCodeRequest 40 var request *protocol.SmsCodeRequest
41 if err := this.JsonUnmarshal(&request); err != nil { 41 if err := this.JsonUnmarshal(&request); err != nil {
42 - msg = protocol.BadRequestParam(2) 42 + msg = protocol.NewMesage(2)
43 return 43 return
44 } 44 }
45 - if b, m := this.Valid(request); !b {  
46 - msg = m 45 + if b, _ := this.Valid(request); !b {
  46 + msg = protocol.NewResponseMessage(2, "手机号码有误,请重新输入!")
47 return 47 return
48 } 48 }
49 msg = protocol.NewReturnResponse(auth.SmsCode(request)) 49 msg = protocol.NewReturnResponse(auth.SmsCode(request))
@@ -147,6 +147,10 @@ func (this *AuthController) AuthCheckSmsCode() { @@ -147,6 +147,10 @@ func (this *AuthController) AuthCheckSmsCode() {
147 } 147 }
148 header := this.GetRequestHeader(this.Ctx) 148 header := this.GetRequestHeader(this.Ctx)
149 rsp, err := auth.AuthCheckSmsCode(header, request) 149 rsp, err := auth.AuthCheckSmsCode(header, request)
  150 + if err != nil {
  151 + msg = protocol.NewReturnResponse(rsp, err)
  152 + return
  153 + }
150 err = CacheSms.Put(request.Phone, rsp.CaptchaCertificate, 5*time.Minute) 154 err = CacheSms.Put(request.Phone, rsp.CaptchaCertificate, 5*time.Minute)
151 msg = protocol.NewReturnResponse(rsp, err) 155 msg = protocol.NewReturnResponse(rsp, err)
152 } 156 }
@@ -109,6 +109,15 @@ func NewReturnResponse(data interface{}, eRR error) *ResponseMessage { @@ -109,6 +109,15 @@ func NewReturnResponse(data interface{}, eRR error) *ResponseMessage {
109 return NewMesage(1) 109 return NewMesage(1)
110 } 110 }
111 111
  112 +func NewResponseMessage(code int, err string) *ResponseMessage {
  113 + return &ResponseMessage{
  114 + ErrorCode: ErrorCode{
  115 + Errno: code,
  116 + Errmsg: err,
  117 + },
  118 + }
  119 +}
  120 +
112 func BadRequestParam(code int) *ResponseMessage { 121 func BadRequestParam(code int) *ResponseMessage {
113 return NewMesage(code) 122 return NewMesage(code)
114 } 123 }