作者 yangfu

用户信息变更修改

... ... @@ -30,18 +30,19 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp
transactionContext.RollbackTransaction()
}()
rsp = &protocol.LoginResponse{}
if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"account": request.Phone}); err != nil {
log.Error(err)
//子账号
if partnerSubAccount, err = PartnerSubAccountRepository.FindOne(map[string]interface{}{"account": request.Phone}); err == nil {
partnerInfo = &domain.PartnerInfo{
Id: partnerSubAccount.PartnerId,
Account: partnerSubAccount.Account,
Password: partnerSubAccount.Password,
}
} else {
if partnerSubAccount, err = PartnerSubAccountRepository.FindOne(map[string]interface{}{"account": request.Phone}); err == nil {
if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": partnerSubAccount.PartnerId}); err != nil {
//子账号
err = protocol.NewErrWithMessage(502, err) //账号不存在
return
}
} else {
if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"account": request.Phone}); err != nil {
//子账号
err = protocol.NewErrWithMessage(502, err) //账号不存在
return
}
}
if !partnerInfo.IsEnable() {
... ...
... ... @@ -113,10 +113,10 @@ func ChangePhone(header *protocol.RequestHeader, request *protocol.ChangePhoneRe
//重置密码
func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswordRequest) (rsp *protocol.ResetPasswordResponse, err error) {
var (
PartnerInfoService = service.NewPartnerInfoService(nil)
partnerInfo *domain.PartnerInfo
transactionContext, _ = factory.CreateTransactionContext(nil)
PartnerInfoDao, _ = factory.CreatePartnerInfoDao(transactionContext)
PartnerInfoService, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext)
)
rsp = &protocol.ResetPasswordResponse{}
if err = transactionContext.StartTransaction(); err != nil {
... ... @@ -133,14 +133,10 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo
err = protocol.NewErrWithMessage(2026)
return
}
if partnerInfo, err = PartnerInfoService.GetPartnerInfo(&query.GetPartnerInfoQuery{Id: int(header.UserId)}); err != nil {
if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": header.UserId}); err != nil {
err = protocol.NewErrWithMessage(502, err) //账号不存在
return
}
//if _, err = auth.CheckSmsCode(partnerInfo.Account, request.Captcha); err != nil {
// log.Error(err)
// return
//}
if err = PartnerInfoDao.Update(map[string]interface{}{
"Id": partnerInfo.Id,
"Password": request.ConfirmPwd,
... ... @@ -154,10 +150,10 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo
//修改密码
func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePasswordRequest) (rsp *protocol.ChangePasswordResponse, err error) {
var (
PartnerInfoService = service.NewPartnerInfoService(nil)
partnerInfo *domain.PartnerInfo
transactionContext, _ = factory.CreateTransactionContext(nil)
PartnerInfoDao, _ = factory.CreatePartnerInfoDao(transactionContext)
PartnerInfoService, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext)
)
if err = transactionContext.StartTransaction(); err != nil {
return nil, err
... ... @@ -178,7 +174,7 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass
err = protocol.NewErrWithMessage(2027)
return
}
if partnerInfo, err = PartnerInfoService.GetPartnerInfo(&query.GetPartnerInfoQuery{Id: int(header.UserId)}); err != nil {
if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": header.UserId}); err != nil {
err = protocol.NewErrWithMessage(502, err) //账号不存在
return
}
... ...
... ... @@ -76,10 +76,18 @@ func (this *UserController) ChangePhone() {
msg = protocol.NewMesage(1012) //验证码不一致
return
}
CacheSms.Delete(request.OldPhone)
} else {
msg = protocol.NewMesage(1013) //验证码不一致
return
}
header := this.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(user.ChangePhone(header, request))
data, err := user.ChangePhone(header, request)
if err == nil {
msg = protocol.NewResponseMessage(0, "修改手机号成功")
return
}
msg = protocol.NewReturnResponse(data, err)
}
//ResetPassword
... ... @@ -107,10 +115,17 @@ func (this *UserController) ResetPassword() {
msg = protocol.NewMesage(1012) //验证码不一致
return
}
CacheSms.Delete(request.Phone)
} else {
msg = protocol.NewMesage(1013) //验证码不一致
return
}
header := this.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(user.ResetPassword(header, request))
data, err := user.ResetPassword(header, request)
if err == nil {
msg = protocol.NewResponseMessage(0, "重置密码成功")
return
}
msg = protocol.NewReturnResponse(data, err)
}
//ChangePassword
... ...
... ... @@ -115,6 +115,8 @@ func NewResponseMessage(code int, err string) *ResponseMessage {
Errno: code,
Errmsg: err,
},
Data: struct {
}{},
}
}
... ...
... ... @@ -11,6 +11,7 @@ var errmessge ErrorMap = map[int]string{
1009: "验证码已失效",
1011: "获取验证码次数超出限制,请联系管理员",
1012: "请输入正确的验证码",
1013: "凭证已失效,请重新操作",
2002: "您还不是正式用户,请联系管理员",
2021: "登录失败,手机号或密码错误",
... ...