Skip to content

Commit

Permalink
feat: 전체 게시글 목록 조회 기능 구현
Browse files Browse the repository at this point in the history
* feat: 전체 게시글 목록 조회 기능 구현

* test: 전체 게시글 목록 조회 컨트롤러 테스트 구현

* test: HOT_POST_LIKES_THRESHOLD 5로 수정 및 테스트 코드 수정

* docs: API 문서 최신화

* chore: 안쓰는 의존성 제거

* fix: 사용하지 않는 파일 관련 어노테이션 삭제
  • Loading branch information
jjuny0310 authored Nov 3, 2023
1 parent beb5c78 commit 20355ef
Show file tree
Hide file tree
Showing 15 changed files with 483 additions and 367 deletions.
7 changes: 0 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,6 @@ dependencies {
// Spring Cloud AWS
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'

// Spring Boot Batch
implementation 'org.springframework.boot:spring-boot-starter-batch'
implementation 'org.springframework.boot:spring-boot-starter-quartz'

// apache tika(파일 분석 라이브러리)
implementation 'org.apache.tika:tika-parsers:1.28'

runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'
compileOnly 'org.projectlombok:lombok'
Expand Down
3 changes: 3 additions & 0 deletions src/docs/asciidoc/post.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
== 익명 게시판

=== 전체 게시글 목록 조회(Offset)
operation::post/find-all-posts-by-offset[snippets='http-request,http-response,cookie,request-parameters,response-fields']

=== 게시글 목록 조회(Cursor)
operation::post/find-posts-by-cursor[snippets='http-request,http-response,cookie,request-parameters,response-fields']

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ public class PostController {

private final PostService postService;

@GetMapping("/all/offset")
public EnvelopeResponse<GetPostOffsetResDto> findAllPostsByOffset(@Valid @ModelAttribute BasePageRequest basePageRequest) {
return EnvelopeResponse.<GetPostOffsetResDto>builder()
.data(postService.findAllPostsByOffset(basePageRequest))
.build();
}

@GetMapping("/cursor")
public EnvelopeResponse<GetPostCursorResDto> findPostsByCursor(@Valid @ModelAttribute GetPostCursorReqDto getPostCursorReqDto) {
return EnvelopeResponse.<GetPostCursorResDto>builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface PostRepository extends JpaRepository<Post, Long>, PostCustomRepository {
boolean existsByIdAndMemberId(Long id, Long memberId);

@Query("SELECT p FROM post p JOIN FETCH p.member WHERE p.id = :id")
Optional<Post> findByIdWithMember(@Param("id") Long id);
Expand Down Expand Up @@ -48,4 +46,8 @@ public interface PostRepository extends JpaRepository<Post, Long>, PostCustomRep
@Query("select p from post p " +
"where p.member = :member ")
Page<Post> findMyPostsByMemberAndPageable(@Param("member") Member member, PageRequest pageRequest);

@EntityGraph(attributePaths = {"board", "member", "likes"})
@Query(value = "select p from post p ")
Page<Post> findAllWithPageable(Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -362,4 +362,13 @@ public GetPostOffsetResDto searchHotPostsByOffset(GetPostHotSearchOffsetReqDto g
Page<HotPost> hotPosts = hotPostRepository.searchHotPostsByKeywordAndPageable(keyword, pageRequest);
return GetPostOffsetResDto.ofHotPosts(hotPosts);
}

@Transactional(readOnly = true)
public GetPostOffsetResDto findAllPostsByOffset(BasePageRequest basePageRequest) {
PageRequest pageRequest = basePageRequest.toPageRequest();

Page<Post> posts = postRepository.findAllWithPageable(pageRequest);
return GetPostOffsetResDto.ofPosts(posts);

}
}

This file was deleted.

This file was deleted.

17 changes: 0 additions & 17 deletions src/main/java/com/ssafy/ssafsound/global/validator/CheckImage.java

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 20355ef

Please sign in to comment.