Merge branch 'test' of http://gitlab.fjmaimaimai.com/allied-creation/performance into test
正在显示
1 个修改的文件
包含
42 行增加
和
38 行删除
@@ -278,51 +278,55 @@ func (srv SyncDataUserService) importUser(param *command.ImportUserCommand) erro | @@ -278,51 +278,55 @@ func (srv SyncDataUserService) importUser(param *command.ImportUserCommand) erro | ||
278 | editUserIds = append(editUserIds, param.EditUsers[i].Id) | 278 | editUserIds = append(editUserIds, param.EditUsers[i].Id) |
279 | editUserMap[param.EditUsers[i].Id] = param.EditUsers[i] | 279 | editUserMap[param.EditUsers[i].Id] = param.EditUsers[i] |
280 | } | 280 | } |
281 | - _, editUserList, err := userRepo.Find(map[string]interface{}{ | ||
282 | - "ids": editUserIds, | ||
283 | - }) | ||
284 | - if err != nil { | ||
285 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
286 | - } | ||
287 | nowTime := time.Now() | 281 | nowTime := time.Now() |
288 | - for i := range editUserList { | ||
289 | - mVal, ok := editUserMap[editUserList[i].Id] | ||
290 | - if !ok { | ||
291 | - continue | ||
292 | - } | ||
293 | - editUserList[i].Account = mVal.Phone | ||
294 | - editUserList[i].AdminType = mVal.AdminType | ||
295 | - editUserList[i].AvatarUrl = mVal.Avatar | ||
296 | - editUserList[i].Name = mVal.Name | ||
297 | - editUserList[i].Status = mVal.Status | ||
298 | - editUserList[i].CompanyId = mVal.CompanyId | ||
299 | - editUserList[i].EntryTime = mVal.EntryTime | ||
300 | - editUserList[i].UpdatedAt = nowTime | ||
301 | - _, err = userRepo.Update(editUserList[i]) | 282 | + if len(editUserIds) > 0 { |
283 | + _, editUserList, err := userRepo.Find(map[string]interface{}{ | ||
284 | + "ids": editUserIds, | ||
285 | + }) | ||
302 | if err != nil { | 286 | if err != nil { |
303 | - return err | 287 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
288 | + } | ||
289 | + for i := range editUserList { | ||
290 | + mVal, ok := editUserMap[editUserList[i].Id] | ||
291 | + if !ok { | ||
292 | + continue | ||
293 | + } | ||
294 | + editUserList[i].Account = mVal.Phone | ||
295 | + editUserList[i].AdminType = mVal.AdminType | ||
296 | + editUserList[i].AvatarUrl = mVal.Avatar | ||
297 | + editUserList[i].Name = mVal.Name | ||
298 | + editUserList[i].Status = mVal.Status | ||
299 | + editUserList[i].CompanyId = mVal.CompanyId | ||
300 | + editUserList[i].EntryTime = mVal.EntryTime | ||
301 | + editUserList[i].UpdatedAt = nowTime | ||
302 | + _, err = userRepo.Update(editUserList[i]) | ||
303 | + if err != nil { | ||
304 | + return err | ||
305 | + } | ||
304 | } | 306 | } |
305 | } | 307 | } |
306 | var ( | 308 | var ( |
307 | tempUser domain.User | 309 | tempUser domain.User |
308 | ) | 310 | ) |
309 | - for i := range param.AddUsers { | ||
310 | - tempUser = domain.User{ | ||
311 | - Id: param.AddUsers[i].Id, | ||
312 | - Account: param.AddUsers[i].Phone, | ||
313 | - AvatarUrl: param.AddUsers[i].Avatar, | ||
314 | - CompanyId: param.AddUsers[i].CompanyId, | ||
315 | - AdminType: param.AddUsers[i].AdminType, | ||
316 | - Name: param.AddUsers[i].Name, | ||
317 | - Status: param.AddUsers[i].Status, | ||
318 | - EntryTime: param.AddUsers[i].EntryTime, | ||
319 | - UpdatedAt: nowTime, | ||
320 | - DeletedAt: nil, | ||
321 | - CreatedAt: nowTime, | ||
322 | - } | ||
323 | - _, err := userRepo.Insert(&tempUser) | ||
324 | - if err != nil { | ||
325 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 311 | + if len(param.AddUsers) > 0 { |
312 | + for i := range param.AddUsers { | ||
313 | + tempUser = domain.User{ | ||
314 | + Id: param.AddUsers[i].Id, | ||
315 | + Account: param.AddUsers[i].Phone, | ||
316 | + AvatarUrl: param.AddUsers[i].Avatar, | ||
317 | + CompanyId: param.AddUsers[i].CompanyId, | ||
318 | + AdminType: param.AddUsers[i].AdminType, | ||
319 | + Name: param.AddUsers[i].Name, | ||
320 | + Status: param.AddUsers[i].Status, | ||
321 | + EntryTime: param.AddUsers[i].EntryTime, | ||
322 | + UpdatedAt: nowTime, | ||
323 | + DeletedAt: nil, | ||
324 | + CreatedAt: nowTime, | ||
325 | + } | ||
326 | + _, err := userRepo.Insert(&tempUser) | ||
327 | + if err != nil { | ||
328 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
329 | + } | ||
326 | } | 330 | } |
327 | } | 331 | } |
328 | if err := transactionContext.CommitTransaction(); err != nil { | 332 | if err := transactionContext.CommitTransaction(); err != nil { |
-
请 注册 或 登录 后发表评论