Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
refactor UpdateUserService.java
Browse files Browse the repository at this point in the history
Arrays.asList -> List.of 변경
doOnNext 메서드로 사이드 이펙트 처리
  • Loading branch information
ori0o0p committed Mar 20, 2024
1 parent ece1cbb commit 3a601a8
Showing 1 changed file with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,12 @@ private void setDocumentForUpdateUserClub(DefaultDocument document, String reque
@Override
public Mono<Void> updateUser(EditUserRequest request) {
return getUserPort.currentUser()
.flatMap(user -> {
user.update(request.name(), request.detail());
return saveUserPort.save(user);
})
.doOnNext(user -> user.update(request.name(), request.detail()))
.flatMap(saveUserPort::save)
.flatMap(user -> getDocumentPort.getDocumentById(user.getDocumentId())
.flatMap(document -> {
setDocumentForUpdateUser(document, user);

return saveDocumentPort.save(document)
.then(createRevision(document));
}));
.doOnNext(document -> setDocumentForUpdateUser(document, user))
.flatMap(document -> saveDocumentPort.save(document)
.then(createRevision(document))));
}

private void setDocumentForUpdateUser(DefaultDocument document, User user) {
Expand All @@ -87,11 +82,11 @@ private void setDocumentForUpdateUser(DefaultDocument document, User user) {

private List<List<String>> createNewGroups(User user) {
List<List<String>> newGroups = new ArrayList<>();
newGroups.add(Arrays.asList("학생", user.getDetail().getGen() + "기", user.getName()));
newGroups.add(Arrays.asList("전공", user.getDetail().getMajor().getMajor()));
newGroups.add(List.of("학생", user.getDetail().getGen() + "기", user.getName()));
newGroups.add(List.of("전공", user.getDetail().getMajor().getMajor()));

if (!user.getDetail().getClub().isBlank()) {
newGroups.add(Arrays.asList("동아리", user.getDetail().getClub()));
newGroups.add(List.of("동아리", user.getDetail().getClub()));
}

return newGroups;
Expand Down

0 comments on commit 3a601a8

Please sign in to comment.