...
|
...
|
@@ -30,6 +30,29 @@ func (userService *UserService) ConvertUserStatus(convertUserStatusCommand *comm |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
var userRepository domain.UserRepository
|
|
|
if value, err := factory.CreateUserRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
userRepository = value
|
|
|
}
|
|
|
user, err := userRepository.FindOne(map[string]interface{}{"userId": convertUserStatusCommand.UserId})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if user == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(convertUserStatusCommand.UserId)))
|
|
|
}
|
|
|
if err := user.CovertUserStatus(convertUserStatusCommand.Status); err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
if _, err := userRepository.Save(user); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
@@ -60,8 +83,8 @@ func (userService *UserService) CreateUser(createUserCommand *command.CreateUser |
|
|
PartnerInfo: createUserCommand.PartnerInfo,
|
|
|
AccessPartners: createUserCommand.AccessPartners,
|
|
|
}
|
|
|
var addUserService service.AddUserService
|
|
|
if value, err := factory.CreateAddUserService(map[string]interface{}{
|
|
|
var addUserService service.UserCreateService
|
|
|
if value, err := factory.CreateUserCreateService(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -69,7 +92,7 @@ func (userService *UserService) CreateUser(createUserCommand *command.CreateUser |
|
|
addUserService = value
|
|
|
}
|
|
|
|
|
|
if user, err := addUserService.AddUser(newUser); err != nil {
|
|
|
if user, err := addUserService.CreateUser(0, newUser); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
...
|
...
|
@@ -207,6 +230,29 @@ func (userService *UserService) SetPermission(setPermissionCommand *command.SetP |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
var userRepository domain.UserRepository
|
|
|
if value, err := factory.CreateUserRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
userRepository = value
|
|
|
}
|
|
|
user, err := userRepository.FindOne(map[string]interface{}{"userId": setPermissionCommand.UserId})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if user == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(setPermissionCommand.UserId)))
|
|
|
}
|
|
|
if err := user.SetPermission(setPermissionCommand.Permissons); err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
if _, err := userRepository.Save(user); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
|