|
@@ -8,6 +8,8 @@ import ( |
|
@@ -8,6 +8,8 @@ import ( |
8
|
"oppmg/protocol"
|
8
|
"oppmg/protocol"
|
9
|
)
|
9
|
)
|
10
|
|
10
|
|
|
|
11
|
+// 请求统一用户中心的接口
|
|
|
12
|
+
|
11
|
//RequestUCenterLogin 调用用户中心进行账号密码登录
|
13
|
//RequestUCenterLogin 调用用户中心进行账号密码登录
|
12
|
func RequestUCenterLogin(account, password string) (*ResponseLogin, error) {
|
14
|
func RequestUCenterLogin(account, password string) (*ResponseLogin, error) {
|
13
|
var uclientReturn ResponseLogin
|
15
|
var uclientReturn ResponseLogin
|
|
@@ -19,7 +21,7 @@ func RequestUCenterLogin(account, password string) (*ResponseLogin, error) { |
|
@@ -19,7 +21,7 @@ func RequestUCenterLogin(account, password string) (*ResponseLogin, error) { |
19
|
uclient := NewUCenterClient()
|
21
|
uclient := NewUCenterClient()
|
20
|
btBody, err := uclient.Call(param)
|
22
|
btBody, err := uclient.Call(param)
|
21
|
if err != nil {
|
23
|
if err != nil {
|
22
|
- log.Error("统一用户中心请求失败 err:%s", err)
|
24
|
+ log.Error("向统一用户中心发送请求失败 err:%s", err)
|
23
|
return nil, protocol.NewErrWithMessage("1")
|
25
|
return nil, protocol.NewErrWithMessage("1")
|
24
|
}
|
26
|
}
|
25
|
err = json.Unmarshal(btBody, &uclientReturn)
|
27
|
err = json.Unmarshal(btBody, &uclientReturn)
|
|
@@ -27,7 +29,7 @@ func RequestUCenterLogin(account, password string) (*ResponseLogin, error) { |
|
@@ -27,7 +29,7 @@ func RequestUCenterLogin(account, password string) (*ResponseLogin, error) { |
27
|
log.Error("解析统一用户中心响应失败 err:%s", err)
|
29
|
log.Error("解析统一用户中心响应失败 err:%s", err)
|
28
|
return nil, protocol.NewErrWithMessage("1")
|
30
|
return nil, protocol.NewErrWithMessage("1")
|
29
|
}
|
31
|
}
|
30
|
- if !(uclientReturn.Code == ResponseCode0) {
|
32
|
+ if !(uclientReturn.Code == ResponseCodeOk) {
|
31
|
return nil, protocol.NewErrWithMessage("10052")
|
33
|
return nil, protocol.NewErrWithMessage("10052")
|
32
|
}
|
34
|
}
|
33
|
return &uclientReturn, nil
|
35
|
return &uclientReturn, nil
|
|
@@ -44,7 +46,7 @@ func RequestUCenterLoginBySecret(secret string) (*ResponseLogin, error) { |
|
@@ -44,7 +46,7 @@ func RequestUCenterLoginBySecret(secret string) (*ResponseLogin, error) { |
44
|
uclient := NewUCenterClient()
|
46
|
uclient := NewUCenterClient()
|
45
|
btBody, err := uclient.Call(param)
|
47
|
btBody, err := uclient.Call(param)
|
46
|
if err != nil {
|
48
|
if err != nil {
|
47
|
- log.Error("统一用户中心请求失败 err:%s", err)
|
49
|
+ log.Error("向统一用户中心发送请求失败 err:%s", err)
|
48
|
return nil, protocol.NewErrWithMessage("1")
|
50
|
return nil, protocol.NewErrWithMessage("1")
|
49
|
}
|
51
|
}
|
50
|
err = json.Unmarshal(btBody, &uclientReturn)
|
52
|
err = json.Unmarshal(btBody, &uclientReturn)
|
|
@@ -52,7 +54,7 @@ func RequestUCenterLoginBySecret(secret string) (*ResponseLogin, error) { |
|
@@ -52,7 +54,7 @@ func RequestUCenterLoginBySecret(secret string) (*ResponseLogin, error) { |
52
|
log.Error("解析统一用户中心响应失败 err:%s", err)
|
54
|
log.Error("解析统一用户中心响应失败 err:%s", err)
|
53
|
return nil, protocol.NewErrWithMessage("1")
|
55
|
return nil, protocol.NewErrWithMessage("1")
|
54
|
}
|
56
|
}
|
55
|
- if !(uclientReturn.Code == ResponseCode0) {
|
57
|
+ if !(uclientReturn.Code == ResponseCodeOk) {
|
56
|
return &uclientReturn, protocol.NewErrWithMessage("1")
|
58
|
return &uclientReturn, protocol.NewErrWithMessage("1")
|
57
|
}
|
59
|
}
|
58
|
return &uclientReturn, nil
|
60
|
return &uclientReturn, nil
|
|
@@ -75,7 +77,7 @@ func RequestUCenterAddUser(phone string, nickname string, avatar string) (*Respo |
|
@@ -75,7 +77,7 @@ func RequestUCenterAddUser(phone string, nickname string, avatar string) (*Respo |
75
|
uclient := NewUCenterClient()
|
77
|
uclient := NewUCenterClient()
|
76
|
btBody, err := uclient.Call(param)
|
78
|
btBody, err := uclient.Call(param)
|
77
|
if err != nil {
|
79
|
if err != nil {
|
78
|
- log.Error("统一用户中心请求失败 err:%s", err)
|
80
|
+ log.Error("向统一用户中心发送请求失败 err:%s", err)
|
79
|
return nil, protocol.NewErrWithMessage("1")
|
81
|
return nil, protocol.NewErrWithMessage("1")
|
80
|
}
|
82
|
}
|
81
|
err = json.Unmarshal(btBody, &ucenterReturn)
|
83
|
err = json.Unmarshal(btBody, &ucenterReturn)
|
|
@@ -83,7 +85,7 @@ func RequestUCenterAddUser(phone string, nickname string, avatar string) (*Respo |
|
@@ -83,7 +85,7 @@ func RequestUCenterAddUser(phone string, nickname string, avatar string) (*Respo |
83
|
log.Error("解析统一用户中心响应失败 err:%s", err)
|
85
|
log.Error("解析统一用户中心响应失败 err:%s", err)
|
84
|
return nil, protocol.NewErrWithMessage("1")
|
86
|
return nil, protocol.NewErrWithMessage("1")
|
85
|
}
|
87
|
}
|
86
|
- if !(ucenterReturn.Code == ResponseCode0) {
|
88
|
+ if !(ucenterReturn.Code == ResponseCodeOk) {
|
87
|
return nil, protocol.NewErrWithMessage("10052")
|
89
|
return nil, protocol.NewErrWithMessage("10052")
|
88
|
}
|
90
|
}
|
89
|
return &ucenterReturn, nil
|
91
|
return &ucenterReturn, nil
|
|
@@ -100,7 +102,7 @@ func RequestUCenterSmsCode(phone string) error { |
|
@@ -100,7 +102,7 @@ func RequestUCenterSmsCode(phone string) error { |
100
|
uclient := NewUCenterClient()
|
102
|
uclient := NewUCenterClient()
|
101
|
btBody, err := uclient.Call(param)
|
103
|
btBody, err := uclient.Call(param)
|
102
|
if err != nil {
|
104
|
if err != nil {
|
103
|
- log.Error("统一用户中心请求失败 err:%s", err)
|
105
|
+ log.Error("向统一用户中心发送请求失败 err:%s", err)
|
104
|
return protocol.NewErrWithMessage("1")
|
106
|
return protocol.NewErrWithMessage("1")
|
105
|
}
|
107
|
}
|
106
|
var ucenterReturn CommResponse
|
108
|
var ucenterReturn CommResponse
|
|
@@ -109,7 +111,7 @@ func RequestUCenterSmsCode(phone string) error { |
|
@@ -109,7 +111,7 @@ func RequestUCenterSmsCode(phone string) error { |
109
|
log.Error("解析统一用户中心响应失败 err:%s", err)
|
111
|
log.Error("解析统一用户中心响应失败 err:%s", err)
|
110
|
return protocol.NewErrWithMessage("1")
|
112
|
return protocol.NewErrWithMessage("1")
|
111
|
}
|
113
|
}
|
112
|
- if !(ucenterReturn.Code == ResponseCode0) {
|
114
|
+ if !(ucenterReturn.Code == ResponseCodeOk) {
|
113
|
return protocol.NewErrWithMessage("10052")
|
115
|
return protocol.NewErrWithMessage("10052")
|
114
|
}
|
116
|
}
|
115
|
return nil
|
117
|
return nil
|
|
@@ -125,7 +127,7 @@ func RequestUCenterLoginSms(phone string, captcha string) (*ResponseLoginSms, er |
|
@@ -125,7 +127,7 @@ func RequestUCenterLoginSms(phone string, captcha string) (*ResponseLoginSms, er |
125
|
uclient := NewUCenterClient()
|
127
|
uclient := NewUCenterClient()
|
126
|
btBody, err := uclient.Call(param)
|
128
|
btBody, err := uclient.Call(param)
|
127
|
if err != nil {
|
129
|
if err != nil {
|
128
|
- log.Error("统一用户中心请求失败 err:%s", err)
|
130
|
+ log.Error("向统一用户中心发送请求失败 err:%s", err)
|
129
|
return nil, protocol.NewErrWithMessage("1")
|
131
|
return nil, protocol.NewErrWithMessage("1")
|
130
|
}
|
132
|
}
|
131
|
var ucenterReturn ResponseLoginSms
|
133
|
var ucenterReturn ResponseLoginSms
|
|
@@ -134,7 +136,7 @@ func RequestUCenterLoginSms(phone string, captcha string) (*ResponseLoginSms, er |
|
@@ -134,7 +136,7 @@ func RequestUCenterLoginSms(phone string, captcha string) (*ResponseLoginSms, er |
134
|
log.Error("解析统一用户中心响应失败 err:%s", err)
|
136
|
log.Error("解析统一用户中心响应失败 err:%s", err)
|
135
|
return nil, protocol.NewErrWithMessage("1")
|
137
|
return nil, protocol.NewErrWithMessage("1")
|
136
|
}
|
138
|
}
|
137
|
- if !(ucenterReturn.Code == ResponseCode0) {
|
139
|
+ if !(ucenterReturn.Code == ResponseCodeOk) {
|
138
|
return &ucenterReturn, protocol.NewErrWithMessage("10052")
|
140
|
return &ucenterReturn, protocol.NewErrWithMessage("10052")
|
139
|
}
|
141
|
}
|
140
|
return &ucenterReturn, nil
|
142
|
return &ucenterReturn, nil
|
|
@@ -148,7 +150,7 @@ func RequestUCenterSmsCodeCheck(phone string, captcha string) (*ResponseSmsCodeC |
|
@@ -148,7 +150,7 @@ func RequestUCenterSmsCodeCheck(phone string, captcha string) (*ResponseSmsCodeC |
148
|
uclient := NewUCenterClient()
|
150
|
uclient := NewUCenterClient()
|
149
|
btBody, err := uclient.Call(param)
|
151
|
btBody, err := uclient.Call(param)
|
150
|
if err != nil {
|
152
|
if err != nil {
|
151
|
- log.Error("统一用户中心请求失败 err:%s", err)
|
153
|
+ log.Error("向统一用户中心发送请求失败 err:%s", err)
|
152
|
return nil, protocol.NewErrWithMessage("1")
|
154
|
return nil, protocol.NewErrWithMessage("1")
|
153
|
}
|
155
|
}
|
154
|
var ucenterReturn ResponseSmsCodeCheck
|
156
|
var ucenterReturn ResponseSmsCodeCheck
|
|
@@ -157,7 +159,7 @@ func RequestUCenterSmsCodeCheck(phone string, captcha string) (*ResponseSmsCodeC |
|
@@ -157,7 +159,7 @@ func RequestUCenterSmsCodeCheck(phone string, captcha string) (*ResponseSmsCodeC |
157
|
log.Error("解析统一用户中心响应失败 err:%s", err)
|
159
|
log.Error("解析统一用户中心响应失败 err:%s", err)
|
158
|
return nil, protocol.NewErrWithMessage("1")
|
160
|
return nil, protocol.NewErrWithMessage("1")
|
159
|
}
|
161
|
}
|
160
|
- if !(ucenterReturn.Code == ResponseCode0) {
|
162
|
+ if !(ucenterReturn.Code == ResponseCodeOk) {
|
161
|
return &ucenterReturn, protocol.NewErrWithMessage("10026")
|
163
|
return &ucenterReturn, protocol.NewErrWithMessage("10026")
|
162
|
}
|
164
|
}
|
163
|
return &ucenterReturn, nil
|
165
|
return &ucenterReturn, nil
|
|
@@ -173,7 +175,7 @@ func RequestUCenterRestPassword(phone, newPwd, confirmPwd, certificate string) e |
|
@@ -173,7 +175,7 @@ func RequestUCenterRestPassword(phone, newPwd, confirmPwd, certificate string) e |
173
|
uclient := NewUCenterClient()
|
175
|
uclient := NewUCenterClient()
|
174
|
btBody, err := uclient.Call(param)
|
176
|
btBody, err := uclient.Call(param)
|
175
|
if err != nil {
|
177
|
if err != nil {
|
176
|
- log.Error("统一用户中心请求失败 err:%s", err)
|
178
|
+ log.Error("向统一用户中心发送请求失败 err:%s", err)
|
177
|
return protocol.NewErrWithMessage("1")
|
179
|
return protocol.NewErrWithMessage("1")
|
178
|
}
|
180
|
}
|
179
|
var ucenterReturn CommResponse
|
181
|
var ucenterReturn CommResponse
|
|
@@ -182,7 +184,7 @@ func RequestUCenterRestPassword(phone, newPwd, confirmPwd, certificate string) e |
|
@@ -182,7 +184,7 @@ func RequestUCenterRestPassword(phone, newPwd, confirmPwd, certificate string) e |
182
|
log.Error("解析统一用户中心响应失败 err:%s", err)
|
184
|
log.Error("解析统一用户中心响应失败 err:%s", err)
|
183
|
return protocol.NewErrWithMessage("1")
|
185
|
return protocol.NewErrWithMessage("1")
|
184
|
}
|
186
|
}
|
185
|
- if !(ucenterReturn.Code == ResponseCode0) {
|
187
|
+ if !(ucenterReturn.Code == ResponseCodeOk) {
|
186
|
return protocol.NewErrWithMessage("10052")
|
188
|
return protocol.NewErrWithMessage("10052")
|
187
|
}
|
189
|
}
|
188
|
|
190
|
|