作者 yangfu

用户信息变更修改

@@ -30,18 +30,19 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp @@ -30,18 +30,19 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp
30 transactionContext.RollbackTransaction() 30 transactionContext.RollbackTransaction()
31 }() 31 }()
32 rsp = &protocol.LoginResponse{} 32 rsp = &protocol.LoginResponse{}
33 - if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"account": request.Phone}); err != nil {  
34 - log.Error(err)  
35 - //子账号  
36 - if partnerSubAccount, err = PartnerSubAccountRepository.FindOne(map[string]interface{}{"account": request.Phone}); err == nil {  
37 - partnerInfo = &domain.PartnerInfo{  
38 - Id: partnerSubAccount.PartnerId,  
39 - Account: partnerSubAccount.Account,  
40 - Password: partnerSubAccount.Password,  
41 - }  
42 - } else { 33 + if partnerSubAccount, err = PartnerSubAccountRepository.FindOne(map[string]interface{}{"account": request.Phone}); err == nil {
  34 + if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": partnerSubAccount.PartnerId}); err != nil {
  35 + //子账号
43 err = protocol.NewErrWithMessage(502, err) //账号不存在 36 err = protocol.NewErrWithMessage(502, err) //账号不存在
44 return 37 return
  38 +
  39 + }
  40 + } else {
  41 + if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"account": request.Phone}); err != nil {
  42 + //子账号
  43 + err = protocol.NewErrWithMessage(502, err) //账号不存在
  44 + return
  45 +
45 } 46 }
46 } 47 }
47 if !partnerInfo.IsEnable() { 48 if !partnerInfo.IsEnable() {
@@ -113,10 +113,10 @@ func ChangePhone(header *protocol.RequestHeader, request *protocol.ChangePhoneRe @@ -113,10 +113,10 @@ func ChangePhone(header *protocol.RequestHeader, request *protocol.ChangePhoneRe
113 //重置密码 113 //重置密码
114 func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswordRequest) (rsp *protocol.ResetPasswordResponse, err error) { 114 func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswordRequest) (rsp *protocol.ResetPasswordResponse, err error) {
115 var ( 115 var (
116 - PartnerInfoService = service.NewPartnerInfoService(nil)  
117 partnerInfo *domain.PartnerInfo 116 partnerInfo *domain.PartnerInfo
118 transactionContext, _ = factory.CreateTransactionContext(nil) 117 transactionContext, _ = factory.CreateTransactionContext(nil)
119 PartnerInfoDao, _ = factory.CreatePartnerInfoDao(transactionContext) 118 PartnerInfoDao, _ = factory.CreatePartnerInfoDao(transactionContext)
  119 + PartnerInfoService, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext)
120 ) 120 )
121 rsp = &protocol.ResetPasswordResponse{} 121 rsp = &protocol.ResetPasswordResponse{}
122 if err = transactionContext.StartTransaction(); err != nil { 122 if err = transactionContext.StartTransaction(); err != nil {
@@ -133,14 +133,10 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo @@ -133,14 +133,10 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo
133 err = protocol.NewErrWithMessage(2026) 133 err = protocol.NewErrWithMessage(2026)
134 return 134 return
135 } 135 }
136 - if partnerInfo, err = PartnerInfoService.GetPartnerInfo(&query.GetPartnerInfoQuery{Id: int(header.UserId)}); err != nil { 136 + if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": header.UserId}); err != nil {
137 err = protocol.NewErrWithMessage(502, err) //账号不存在 137 err = protocol.NewErrWithMessage(502, err) //账号不存在
138 return 138 return
139 } 139 }
140 - //if _, err = auth.CheckSmsCode(partnerInfo.Account, request.Captcha); err != nil {  
141 - // log.Error(err)  
142 - // return  
143 - //}  
144 if err = PartnerInfoDao.Update(map[string]interface{}{ 140 if err = PartnerInfoDao.Update(map[string]interface{}{
145 "Id": partnerInfo.Id, 141 "Id": partnerInfo.Id,
146 "Password": request.ConfirmPwd, 142 "Password": request.ConfirmPwd,
@@ -154,10 +150,10 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo @@ -154,10 +150,10 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo
154 //修改密码 150 //修改密码
155 func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePasswordRequest) (rsp *protocol.ChangePasswordResponse, err error) { 151 func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePasswordRequest) (rsp *protocol.ChangePasswordResponse, err error) {
156 var ( 152 var (
157 - PartnerInfoService = service.NewPartnerInfoService(nil)  
158 partnerInfo *domain.PartnerInfo 153 partnerInfo *domain.PartnerInfo
159 transactionContext, _ = factory.CreateTransactionContext(nil) 154 transactionContext, _ = factory.CreateTransactionContext(nil)
160 PartnerInfoDao, _ = factory.CreatePartnerInfoDao(transactionContext) 155 PartnerInfoDao, _ = factory.CreatePartnerInfoDao(transactionContext)
  156 + PartnerInfoService, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext)
161 ) 157 )
162 if err = transactionContext.StartTransaction(); err != nil { 158 if err = transactionContext.StartTransaction(); err != nil {
163 return nil, err 159 return nil, err
@@ -178,7 +174,7 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass @@ -178,7 +174,7 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass
178 err = protocol.NewErrWithMessage(2027) 174 err = protocol.NewErrWithMessage(2027)
179 return 175 return
180 } 176 }
181 - if partnerInfo, err = PartnerInfoService.GetPartnerInfo(&query.GetPartnerInfoQuery{Id: int(header.UserId)}); err != nil { 177 + if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": header.UserId}); err != nil {
182 err = protocol.NewErrWithMessage(502, err) //账号不存在 178 err = protocol.NewErrWithMessage(502, err) //账号不存在
183 return 179 return
184 } 180 }
@@ -76,10 +76,18 @@ func (this *UserController) ChangePhone() { @@ -76,10 +76,18 @@ func (this *UserController) ChangePhone() {
76 msg = protocol.NewMesage(1012) //验证码不一致 76 msg = protocol.NewMesage(1012) //验证码不一致
77 return 77 return
78 } 78 }
79 - CacheSms.Delete(request.OldPhone) 79 + } else {
  80 + msg = protocol.NewMesage(1013) //验证码不一致
  81 + return
80 } 82 }
81 header := this.GetRequestHeader(this.Ctx) 83 header := this.GetRequestHeader(this.Ctx)
82 msg = protocol.NewReturnResponse(user.ChangePhone(header, request)) 84 msg = protocol.NewReturnResponse(user.ChangePhone(header, request))
  85 + data, err := user.ChangePhone(header, request)
  86 + if err == nil {
  87 + msg = protocol.NewResponseMessage(0, "修改手机号成功")
  88 + return
  89 + }
  90 + msg = protocol.NewReturnResponse(data, err)
83 } 91 }
84 92
85 //ResetPassword 93 //ResetPassword
@@ -107,10 +115,17 @@ func (this *UserController) ResetPassword() { @@ -107,10 +115,17 @@ func (this *UserController) ResetPassword() {
107 msg = protocol.NewMesage(1012) //验证码不一致 115 msg = protocol.NewMesage(1012) //验证码不一致
108 return 116 return
109 } 117 }
110 - CacheSms.Delete(request.Phone) 118 + } else {
  119 + msg = protocol.NewMesage(1013) //验证码不一致
  120 + return
111 } 121 }
112 header := this.GetRequestHeader(this.Ctx) 122 header := this.GetRequestHeader(this.Ctx)
113 - msg = protocol.NewReturnResponse(user.ResetPassword(header, request)) 123 + data, err := user.ResetPassword(header, request)
  124 + if err == nil {
  125 + msg = protocol.NewResponseMessage(0, "重置密码成功")
  126 + return
  127 + }
  128 + msg = protocol.NewReturnResponse(data, err)
114 } 129 }
115 130
116 //ChangePassword 131 //ChangePassword
@@ -115,6 +115,8 @@ func NewResponseMessage(code int, err string) *ResponseMessage { @@ -115,6 +115,8 @@ func NewResponseMessage(code int, err string) *ResponseMessage {
115 Errno: code, 115 Errno: code,
116 Errmsg: err, 116 Errmsg: err,
117 }, 117 },
  118 + Data: struct {
  119 + }{},
118 } 120 }
119 } 121 }
120 122
@@ -11,6 +11,7 @@ var errmessge ErrorMap = map[int]string{ @@ -11,6 +11,7 @@ var errmessge ErrorMap = map[int]string{
11 1009: "验证码已失效", 11 1009: "验证码已失效",
12 1011: "获取验证码次数超出限制,请联系管理员", 12 1011: "获取验证码次数超出限制,请联系管理员",
13 1012: "请输入正确的验证码", 13 1012: "请输入正确的验证码",
  14 + 1013: "凭证已失效,请重新操作",
14 15
15 2002: "您还不是正式用户,请联系管理员", 16 2002: "您还不是正式用户,请联系管理员",
16 2021: "登录失败,手机号或密码错误", 17 2021: "登录失败,手机号或密码错误",