...
|
...
|
@@ -102,18 +102,25 @@ func (userService *UserService) BatchEnable(batchEnableCommand *command.BatchEna |
|
|
}
|
|
|
|
|
|
for i := 0; i < len(batchEnableCommand.UserIds); i++ {
|
|
|
if user, err := userRepository.FindOne(map[string]interface{}{"userId": batchEnableCommand.UserIds[i]}); err != nil {
|
|
|
var (
|
|
|
user *domain.User
|
|
|
userBase *domain.UserBase
|
|
|
)
|
|
|
user, err = userRepository.FindOne(map[string]interface{}{"userId": batchEnableCommand.UserIds[i]})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if err := user.SetEnableStatus(batchEnableCommand.EnableStatus); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if _, err := userRepository.Save(user); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if _, userBase, err = factory.FastPgUserBase(transactionContext, user.UserBaseId); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if err, _ := event.Fire(domain.UserEnableEvent, map[string]interface{}{"user": user, "userBase": userBase}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if err := user.SetEnableStatus(batchEnableCommand.EnableStatus); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if _, err := userRepository.Save(user); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if err, _ := event.Fire(domain.UserEnableEvent, map[string]interface{}{"user": user}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|