Skip to content

Commit

Permalink
추가적인 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
JONG-KYEONG committed Nov 29, 2023
1 parent 7882a13 commit aeb866c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.project.Glog.domain.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
Expand All @@ -26,7 +27,7 @@ public interface PostRepository extends JpaRepository<Post,Long> {
@Query("SELECT p FROM Post p ORDER BY p.likesCount DESC")
List<Post> findAllByOrderByLikesDesc();

Page<Post> findAll(Pageable pageable);
Page<Post> findByisPrivate(boolean isPrivate, Pageable pageable);

@Query(value = "SELECT * FROM post ORDER BY RAND() LIMIT 8", nativeQuery = true)
List<Post> findPostsByRandom();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private User registerNewUser(OAuth2UserRequest oAuth2UserRequest, OAuth2UserInfo
user.setProviderId(oAuth2UserInfo.getId());
user.setNickname(oAuth2UserInfo.getName());
user.setEmail(oAuth2UserInfo.getEmail());
user.setImageUrl(oAuth2UserInfo.getImageUrl());
user.setImageUrl("https://elasticbeanstalk-us-east-1-064991853848.s3.amazonaws.com/profile/defaultImages.jpg");

if (registrationId.equalsIgnoreCase(AuthProvider.github.toString())) {
user.setGithubID(oAuth2UserInfo.getName());
Expand All @@ -90,7 +90,6 @@ private User updateExistingUser(User existingUser, OAuth2UserInfo oAuth2UserInfo
String registrationId = oAuth2UserRequest.getClientRegistration().getRegistrationId();

existingUser.setNickname(oAuth2UserInfo.getName());
existingUser.setImageUrl(oAuth2UserInfo.getImageUrl());
if (registrationId.equalsIgnoreCase(AuthProvider.github.toString())) {
existingUser.setGithubID(oAuth2UserInfo.getName());
existingUser.setGithubToken(token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public String registerBlog(UserPrincipal userPrincipal, UserCreateRequest userCr
blog.setBlogName(userCreateRequest.getBlogName());
blog.setBlogUrl(userCreateRequest.getBlogUrl());
user.setNickname(userCreateRequest.getNickname());
user.setImageUrl("https://elasticbeanstalk-us-east-1-064991853848.s3.amazonaws.com/profile/defaultImages.jpg");
// user.setImageUrl("https://elasticbeanstalk-us-east-1-064991853848.s3.amazonaws.com/profile/defaultImages.jpg");

Guestbook guestBook = new Guestbook();
guestBook.setBlog(blog);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,16 @@ public PostPreviewResponse getCollect(int page) {
public PostPreviewDtos getPreviews(String kind, int page) {
if (!kind.equals("randoms")) {
PageRequest pageRequest = null;

if (kind.equals("recent")) {
pageRequest = PageRequest.of(page, 8, Sort.by("id").descending());
} else if (kind.equals("likes")) {
pageRequest = PageRequest.of(page, 8, Sort.by("likesCount").descending());
} else if (kind.equals("views")) {
pageRequest = PageRequest.of(page, 8, Sort.by("viewsCount").descending());
}
Page<Post> postsByPagination = postRepository.findAll(pageRequest);

Page<Post> postsByPagination = postRepository.findByisPrivate(false,pageRequest);
return new PostPreviewDtos(postsByPagination.getContent(), postsByPagination.getTotalPages());
} else if (kind.equals("randoms")) {
List<Post> posts = postRepository.findPostsByRandom();
Expand Down

0 comments on commit aeb866c

Please sign in to comment.