作者 yangfu

统一用户中心修改

@@ -29,7 +29,7 @@ type ModulePermission struct { @@ -29,7 +29,7 @@ type ModulePermission struct {
29 Menus []*ModulePermission `json:"-"` //子模块权限 29 Menus []*ModulePermission `json:"-"` //子模块权限
30 } 30 }
31 31
32 -/*UCenterGetUser */ 32 +/*获取用户信息 UCenterGetUser */
33 type UCenterGetUserRequest struct { 33 type UCenterGetUserRequest struct {
34 } 34 }
35 type UCenterGetUserResponse struct { 35 type UCenterGetUserResponse struct {
@@ -41,3 +41,13 @@ type UCenterGetUserResponse struct { @@ -41,3 +41,13 @@ type UCenterGetUserResponse struct {
41 Accid string `json:"accid"` 41 Accid string `json:"accid"`
42 CustomerAccount string `json:"customerAccount"` 42 CustomerAccount string `json:"customerAccount"`
43 } 43 }
  44 +
  45 +/*修改用户信息 UCenterPutUser */
  46 +type UCenterPutUserRequest struct {
  47 + Phone string `json:"phone"`
  48 + PassWord string `json:"password"`
  49 + NickName string `json:"nickname"`
  50 + Avatar string `json:"avatar"`
  51 +}
  52 +type UCenterPutUserResponse struct {
  53 +}
@@ -11,7 +11,7 @@ var nsV1 *beego.Namespace @@ -11,7 +11,7 @@ var nsV1 *beego.Namespace
11 11
12 func init() { 12 func init() {
13 nsV1 := beego.NewNamespace("v1", 13 nsV1 := beego.NewNamespace("v1",
14 - beego.NSNamespace("ucenter", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.UcenterController{})), 14 + beego.NSNamespace("ucenter", beego.NSInclude(&v1.UcenterController{})),
15 beego.NSNamespace("auth", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.AuthController{})), 15 beego.NSNamespace("auth", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.AuthController{})),
16 beego.NSNamespace("upload", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.UploadController{})), 16 beego.NSNamespace("upload", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.UploadController{})),
17 beego.NSNamespace("version", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.VersionController{})), 17 beego.NSNamespace("version", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.VersionController{})),
@@ -46,6 +46,7 @@ func RequestUserCenter(method string, httpMethod, request interface{}, rsponse i @@ -46,6 +46,7 @@ func RequestUserCenter(method string, httpMethod, request interface{}, rsponse i
46 return 46 return
47 } 47 }
48 if err = json.Unmarshal(data, rsponse); err != nil { 48 if err = json.Unmarshal(data, rsponse); err != nil {
  49 + log.Debug(method, "response:", string(data))
49 log.Error(err) 50 log.Error(err)
50 return 51 return
51 } 52 }
1 package user 1 package user
2 2
3 import ( 3 import (
  4 + "fmt"
4 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" 5 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
5 "net/http" 6 "net/http"
6 "opp/internal/repository" 7 "opp/internal/repository"
@@ -106,10 +107,10 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass @@ -106,10 +107,10 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass
106 log.Error(err) 107 log.Error(err)
107 return 108 return
108 } 109 }
109 - if !strings.EqualFold(request.OldPwd, user.Passwd) {  
110 - err = protocol.NewErrWithMessage(2028)  
111 - return  
112 - } 110 + //if !strings.EqualFold(request.OldPwd, user.Passwd) {
  111 + // err = protocol.NewErrWithMessage(2028)
  112 + // return
  113 + //}
113 114
114 //new 115 //new
115 var message protocol.Message 116 var message protocol.Message
@@ -126,17 +127,20 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass @@ -126,17 +127,20 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass
126 return 127 return
127 } 128 }
128 if loginResponse.Id != user.UserCenterId { 129 if loginResponse.Id != user.UserCenterId {
  130 + log.Error(fmt.Sprintf("用户中心uid不一致 input:%v want:%v", loginResponse.Id, user.UserCenterId))
129 err = protocol.NewErrWithMessage(1) 131 err = protocol.NewErrWithMessage(1)
130 return 132 return
131 } 133 }
132 - 134 + log.Debug(fmt.Sprintf("修改密码 simnum:%v ucenter_id:%v pwd:%v", user.Phone, user.UserCenterId, request.NewPwd))
133 //修改密码 135 //修改密码
134 - if _, err = agg.RequestUserCenter(protocol.MethodGetUser, http.MethodPut, nil, &message); err != nil {  
135 - 136 + if _, err = agg.RequestUserCenter(fmt.Sprintf("%v%v", protocol.MethodGetUser, loginResponse.Id), http.MethodPut, &protocol.UCenterPutUserRequest{
  137 + PassWord: request.NewPwd,
  138 + }, &message); err != nil {
  139 + log.Error(err)
  140 + return
136 } 141 }
137 } 142 }
138 -  
139 - err = utils.UpdateTableByMap(&models.User{Id: user.Id}, map[string]interface{}{"Passwd": request.NewPwd}) 143 + //err = utils.UpdateTableByMap(&models.User{Id: user.Id}, map[string]interface{}{"Passwd": request.NewPwd})
140 return 144 return
141 } 145 }
142 146