Skip to content

Commit

Permalink
♻️:: 메서드 명 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyoil2 committed Dec 5, 2023
1 parent 0b01795 commit 61120c9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public class QueryCommentService {
public FeedAndCommentsResponse queryComment(Long feedId) {
Feed feed = feedFacade.currentFeed(feedId);

String currentUserId = userFacade.getUser();
String studentId = userFacade.getStudentId();

boolean isLiked = likeRepository.existsByFeedAndStudentId(feed, currentUserId);
boolean isLiked = likeRepository.existsByFeedAndStudentId(feed, studentId);

FeedListResponse feedResponse = new FeedListResponse(feed,isLiked);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
import com.example.asterbackend.domain.user.feed.presentation.dto.response.FeedListResponse;
import com.example.asterbackend.domain.user.feed.repository.FeedRepository;
import com.example.asterbackend.domain.user.feed.repository.LikeRepository;
import com.example.asterbackend.domain.user.user.entity.User;
import com.example.asterbackend.domain.user.user.facade.UserFacade;
import com.example.asterbackend.domain.user.user.repository.UserRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

@Service
Expand All @@ -24,13 +21,13 @@ public class QueryFeedListService {

public List<FeedListResponse> queryFeedList() {

String currentUserId = userFacade.getUser();
String studentId = userFacade.getStudentId();

List<Feed> allFeeds = feedRepository.findAll();

return allFeeds.stream()
.map(feed -> {
boolean isLiked = likeRepository.existsByFeedAndStudentId(feed, currentUserId);
boolean isLiked = likeRepository.existsByFeedAndStudentId(feed, studentId);
return new FeedListResponse(feed, isLiked);
})
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

import java.util.Optional;

@Component
@RequiredArgsConstructor
public class UserFacade {
Expand All @@ -32,7 +30,7 @@ public User getCurrentUser() {
.orElseThrow(() -> UserNotFoundException.EXCEPTION);
}

public String getUser() {
public String getStudentId() {
return SecurityContextHolder.getContext().getAuthentication().getName();

}
Expand Down

0 comments on commit 61120c9

Please sign in to comment.