Skip to content

Commit

Permalink
[refactor] : 다중 업데이트 성능 개선을 위한 Bulk update 방식으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
dudxo committed Oct 24, 2024
1 parent bf9f77a commit e71e62f
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/main/java/com/dnd/gongmuin/auth/service/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import java.time.Duration;
import java.util.Date;
import java.util.List;
import java.util.Objects;

import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dnd.gongmuin.answer.domain.Answer;
import com.dnd.gongmuin.answer.repository.AnswerRepository;
import com.dnd.gongmuin.auth.dto.request.AdditionalInfoRequest;
import com.dnd.gongmuin.auth.dto.request.TempSignInRequest;
Expand All @@ -32,7 +30,6 @@
import com.dnd.gongmuin.member.repository.MemberRepository;
import com.dnd.gongmuin.notification.repository.NotificationRepository;
import com.dnd.gongmuin.post_interaction.repository.InteractionRepository;
import com.dnd.gongmuin.question_post.domain.QuestionPost;
import com.dnd.gongmuin.question_post.repository.QuestionPostRepository;
import com.dnd.gongmuin.redis.util.RedisUtil;
import com.dnd.gongmuin.security.jwt.util.CookieUtil;
Expand Down Expand Up @@ -249,12 +246,8 @@ private void replaceWithAnonymous(Member member) {
Member anonymous = memberRepository.findByRole(ANONYMOUS)
.orElseThrow(() -> new NotFoundException(MemberErrorCode.NOT_FOUND_MEMBER));

List<QuestionPost> posts = questionPostRepository.findAllByMember(member);
posts.forEach(post -> post.updateMember(anonymous));

List<Answer> answers = answerRepository.findAllByMember(member);
answers.forEach(answer -> answer.updateMember(anonymous));

questionPostRepository.updateQuestionPosts(member.getId(), anonymous);
answerRepository.updateAnswers(member.getId(), anonymous);
}

}

0 comments on commit e71e62f

Please sign in to comment.