|
@@ -5,6 +5,7 @@ import ( |
|
@@ -5,6 +5,7 @@ import ( |
5
|
"oppmg/common/log"
|
5
|
"oppmg/common/log"
|
6
|
"oppmg/models"
|
6
|
"oppmg/models"
|
7
|
"oppmg/protocol"
|
7
|
"oppmg/protocol"
|
|
|
8
|
+ "oppmg/services/ucenter"
|
8
|
"oppmg/storage/redisdata"
|
9
|
"oppmg/storage/redisdata"
|
9
|
"oppmg/utils"
|
10
|
"oppmg/utils"
|
10
|
"strings"
|
11
|
"strings"
|
|
@@ -44,10 +45,16 @@ func UserAdd(param protocol.RequestUserAdd) error { |
|
@@ -44,10 +45,16 @@ func UserAdd(param protocol.RequestUserAdd) error { |
44
|
userId int64
|
45
|
userId int64
|
45
|
userCompanyid int64
|
46
|
userCompanyid int64
|
46
|
)
|
47
|
)
|
|
|
48
|
+ resp, err := ucenter.RequestUCenterAddUser(param.Name, param.Phone, "")
|
|
|
49
|
+ if err != nil {
|
|
|
50
|
+ log.Error("用户数据提交用户中心失败:%s", err)
|
|
|
51
|
+ return protocol.NewErrWithMessage("1")
|
|
|
52
|
+ }
|
47
|
o := orm.NewOrm()
|
53
|
o := orm.NewOrm()
|
48
|
o.Begin()
|
54
|
o.Begin()
|
49
|
//添加用户
|
55
|
//添加用户
|
50
|
- userId, err = addNewUser(param.Name, param.Phone, o)
|
56
|
+ userId, err = addNewUser(resp.Data.Nickname, resp.Data.Phone,
|
|
|
57
|
+ resp.Data.Id, resp.Data.Avatar, resp.Data.Accid, resp.Data.CustomerAccount, o)
|
51
|
if err != nil {
|
58
|
if err != nil {
|
52
|
o.Rollback()
|
59
|
o.Rollback()
|
53
|
log.Error("addNewUser err:%s", err)
|
60
|
log.Error("addNewUser err:%s", err)
|
|
@@ -99,7 +106,6 @@ func validCompanyRole(companyid int64, roleid []int64) error { |
|
@@ -99,7 +106,6 @@ func validCompanyRole(companyid int64, roleid []int64) error { |
99
|
log.Error(e.Error())
|
106
|
log.Error(e.Error())
|
100
|
return protocol.NewErrWithMessage("10031")
|
107
|
return protocol.NewErrWithMessage("10031")
|
101
|
}
|
108
|
}
|
102
|
-
|
|
|
103
|
}
|
109
|
}
|
104
|
return nil
|
110
|
return nil
|
105
|
}
|
111
|
}
|
|
@@ -164,44 +170,9 @@ func existCompanyUser(companyid int64, phone string) error { |
|
@@ -164,44 +170,9 @@ func existCompanyUser(companyid int64, phone string) error { |
164
|
return nil
|
170
|
return nil
|
165
|
}
|
171
|
}
|
166
|
|
172
|
|
167
|
-//registUser 注册用户
|
|
|
168
|
-// func registUser(userIn *models.User, companyid int64, o orm.Ormer) error {
|
|
|
169
|
-// var (
|
|
|
170
|
-// err error
|
|
|
171
|
-// usrData *models.User
|
|
|
172
|
-// )
|
|
|
173
|
-// usrData, err = models.GetUserByPhone(userIn.Phone)
|
|
|
174
|
-// if err != nil && err != orm.ErrNoRows {
|
|
|
175
|
-// return err
|
|
|
176
|
-// }
|
|
|
177
|
-// if err == orm.ErrNoRows {
|
|
|
178
|
-// //用户不存在 添加用户
|
|
|
179
|
-// _, err := models.AddUser(userIn, o)
|
|
|
180
|
-// if err != nil {
|
|
|
181
|
-// return err
|
|
|
182
|
-// }
|
|
|
183
|
-// }
|
|
|
184
|
-// if err == nil {
|
|
|
185
|
-// // 用户存在,更新用户
|
|
|
186
|
-// usrData.NickName = userIn.NickName
|
|
|
187
|
-// err = models.UpdateUserById(usrData, []string{"NickName"}, o)
|
|
|
188
|
-// if err != nil {
|
|
|
189
|
-// return err
|
|
|
190
|
-// }
|
|
|
191
|
-// }
|
|
|
192
|
-// musercompany := &models.UserCompany{
|
|
|
193
|
-// CompanyId: companyid,
|
|
|
194
|
-// UserId: userIn.Id,
|
|
|
195
|
-// }
|
|
|
196
|
-
|
|
|
197
|
-// _, err = models.AddUserCompany(musercompany, o)
|
|
|
198
|
-// if err != nil {
|
|
|
199
|
-// return err
|
|
|
200
|
-// }
|
|
|
201
|
-// return nil
|
|
|
202
|
-// }
|
|
|
203
|
-
|
|
|
204
|
-func addNewUser(name string, phone string, o orm.Ormer) (userid int64, err error) {
|
173
|
+// /resp.Data.Avatar, resp.Data.Accid, resp.Data.CustomerAccount
|
|
|
174
|
+func addNewUser(name string, phone string, ucenterId int64, avatar string, accid int64, customerAccout int64,
|
|
|
175
|
+ o orm.Ormer) (userid int64, err error) {
|
205
|
var (
|
176
|
var (
|
206
|
usrData *models.User
|
177
|
usrData *models.User
|
207
|
)
|
178
|
)
|
|
@@ -212,8 +183,11 @@ func addNewUser(name string, phone string, o orm.Ormer) (userid int64, err error |
|
@@ -212,8 +183,11 @@ func addNewUser(name string, phone string, o orm.Ormer) (userid int64, err error |
212
|
if err == orm.ErrNoRows {
|
183
|
if err == orm.ErrNoRows {
|
213
|
//用户不存在 添加用户
|
184
|
//用户不存在 添加用户
|
214
|
usrData = &models.User{
|
185
|
usrData = &models.User{
|
215
|
- Phone: phone,
|
|
|
216
|
- NickName: name,
|
186
|
+ Phone: phone,
|
|
|
187
|
+ NickName: name,
|
|
|
188
|
+ Icon: avatar,
|
|
|
189
|
+ Accid: accid,
|
|
|
190
|
+ CsAccount: customerAccout,
|
217
|
}
|
191
|
}
|
218
|
_, err := models.AddUser(usrData, o)
|
192
|
_, err := models.AddUser(usrData, o)
|
219
|
if err != nil {
|
193
|
if err != nil {
|