Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/main/java/io/spring/application/user/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.crypto.password.PasswordEncoder;
Expand All @@ -17,6 +19,8 @@
@Service
@Validated
public class UserService {
private static final Logger log = LoggerFactory.getLogger(UserService.class);

private UserRepository userRepository;
private String defaultImage;
private PasswordEncoder passwordEncoder;
Expand All @@ -32,6 +36,7 @@ public UserService(
}

public User createUser(@Valid RegisterParam registerParam) {
log.info("Entering createUser() with username={}", registerParam.getUsername());
User user =
new User(
registerParam.getEmail(),
Expand All @@ -40,11 +45,13 @@ public User createUser(@Valid RegisterParam registerParam) {
"",
defaultImage);
userRepository.save(user);
log.info("Exiting createUser()");
return user;
}

public void updateUser(@Valid UpdateUserCommand command) {
User user = command.getTargetUser();
log.info("Entering updateUser() with userId={}", user.getId());
UpdateUserParam updateUserParam = command.getParam();
user.update(
updateUserParam.getEmail(),
Expand All @@ -53,6 +60,7 @@ public void updateUser(@Valid UpdateUserCommand command) {
updateUserParam.getBio(),
updateUserParam.getImage());
userRepository.save(user);
log.info("Exiting updateUser()");
}
}

Expand Down
Loading