...
|
...
|
@@ -278,51 +278,55 @@ func (srv SyncDataUserService) importUser(param *command.ImportUserCommand) erro |
|
|
editUserIds = append(editUserIds, param.EditUsers[i].Id)
|
|
|
editUserMap[param.EditUsers[i].Id] = param.EditUsers[i]
|
|
|
}
|
|
|
_, editUserList, err := userRepo.Find(map[string]interface{}{
|
|
|
"ids": editUserIds,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
nowTime := time.Now()
|
|
|
for i := range editUserList {
|
|
|
mVal, ok := editUserMap[editUserList[i].Id]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
editUserList[i].Account = mVal.Phone
|
|
|
editUserList[i].AdminType = mVal.AdminType
|
|
|
editUserList[i].AvatarUrl = mVal.Avatar
|
|
|
editUserList[i].Name = mVal.Name
|
|
|
editUserList[i].Status = mVal.Status
|
|
|
editUserList[i].CompanyId = mVal.CompanyId
|
|
|
editUserList[i].EntryTime = mVal.EntryTime
|
|
|
editUserList[i].UpdatedAt = nowTime
|
|
|
_, err = userRepo.Update(editUserList[i])
|
|
|
if len(editUserIds) > 0 {
|
|
|
_, editUserList, err := userRepo.Find(map[string]interface{}{
|
|
|
"ids": editUserIds,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return err
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
for i := range editUserList {
|
|
|
mVal, ok := editUserMap[editUserList[i].Id]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
editUserList[i].Account = mVal.Phone
|
|
|
editUserList[i].AdminType = mVal.AdminType
|
|
|
editUserList[i].AvatarUrl = mVal.Avatar
|
|
|
editUserList[i].Name = mVal.Name
|
|
|
editUserList[i].Status = mVal.Status
|
|
|
editUserList[i].CompanyId = mVal.CompanyId
|
|
|
editUserList[i].EntryTime = mVal.EntryTime
|
|
|
editUserList[i].UpdatedAt = nowTime
|
|
|
_, err = userRepo.Update(editUserList[i])
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
var (
|
|
|
tempUser domain.User
|
|
|
)
|
|
|
for i := range param.AddUsers {
|
|
|
tempUser = domain.User{
|
|
|
Id: param.AddUsers[i].Id,
|
|
|
Account: param.AddUsers[i].Phone,
|
|
|
AvatarUrl: param.AddUsers[i].Avatar,
|
|
|
CompanyId: param.AddUsers[i].CompanyId,
|
|
|
AdminType: param.AddUsers[i].AdminType,
|
|
|
Name: param.AddUsers[i].Name,
|
|
|
Status: param.AddUsers[i].Status,
|
|
|
EntryTime: param.AddUsers[i].EntryTime,
|
|
|
UpdatedAt: nowTime,
|
|
|
DeletedAt: nil,
|
|
|
CreatedAt: nowTime,
|
|
|
}
|
|
|
_, err := userRepo.Insert(&tempUser)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
if len(param.AddUsers) > 0 {
|
|
|
for i := range param.AddUsers {
|
|
|
tempUser = domain.User{
|
|
|
Id: param.AddUsers[i].Id,
|
|
|
Account: param.AddUsers[i].Phone,
|
|
|
AvatarUrl: param.AddUsers[i].Avatar,
|
|
|
CompanyId: param.AddUsers[i].CompanyId,
|
|
|
AdminType: param.AddUsers[i].AdminType,
|
|
|
Name: param.AddUsers[i].Name,
|
|
|
Status: param.AddUsers[i].Status,
|
|
|
EntryTime: param.AddUsers[i].EntryTime,
|
|
|
UpdatedAt: nowTime,
|
|
|
DeletedAt: nil,
|
|
|
CreatedAt: nowTime,
|
|
|
}
|
|
|
_, err := userRepo.Insert(&tempUser)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
...
|
...
|
|