-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Hey-Porori/feat/myPostList
내 게시물 목록보기, 북마크 목록 보기, 북마크 삭제 API 및 많은 수정
- Loading branch information
Showing
22 changed files
with
372 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
.../java/porori/backend/community/config/exception/bookmark/NotFoundBookmarkIdException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package porori.backend.community.config.exception.bookmark; | ||
|
||
import static porori.backend.community.config.exception.bookmark.BookmarkExceptionList.NOT_FOUND_BOOKMARKID_ERROR; | ||
|
||
public class NotFoundBookmarkIdException extends BookmarkException { | ||
public NotFoundBookmarkIdException(){ | ||
super(NOT_FOUND_BOOKMARKID_ERROR.getErrorCode(), NOT_FOUND_BOOKMARKID_ERROR.getHttpStatus(), NOT_FOUND_BOOKMARKID_ERROR.getMessage()); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/porori/backend/community/config/exception/bookmark/NotMyBookmarkException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package porori.backend.community.config.exception.bookmark; | ||
|
||
import static porori.backend.community.config.exception.bookmark.BookmarkExceptionList.NOT_MY_BOOKMARK_ERROR; | ||
|
||
public class NotMyBookmarkException extends BookmarkException{ | ||
public NotMyBookmarkException(){ | ||
super(NOT_MY_BOOKMARK_ERROR.getErrorCode(), NOT_MY_BOOKMARK_ERROR.getHttpStatus(), NOT_MY_BOOKMARK_ERROR.getMessage()); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/porori/backend/community/config/exception/post/NotMyPostException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package porori.backend.community.config.exception.post; | ||
|
||
import static porori.backend.community.config.exception.post.PostExceptionList.NOT_MY_POST_ERROR; | ||
|
||
public class NotMyPostException extends PostException{ | ||
public NotMyPostException(){ | ||
super(NOT_MY_POST_ERROR.getErrorCode(), NOT_MY_POST_ERROR.getHttpStatus(), NOT_MY_POST_ERROR.getMessage()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/porori/backend/community/dto/BookmarkResDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package porori.backend.community.dto; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import porori.backend.community.domain.Bookmark; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@NoArgsConstructor | ||
|
||
public class BookmarkResDto { | ||
@Getter | ||
public static class BookmarkIdRes { | ||
private Long bookmarkId; | ||
|
||
@Builder | ||
public BookmarkIdRes(Long bookmarkId) { | ||
this.bookmarkId = bookmarkId; | ||
} | ||
} | ||
|
||
@Getter | ||
@Builder | ||
public static class BookmarkPreviewListRes { | ||
//페이징 처리 | ||
//제목, 내용, 위치, 북마크 수 , 댓글 수, 게시글 작성 시간, 1번 이미지 | ||
int totalPage; | ||
List<BookmarkPreview> previewList; | ||
|
||
} | ||
|
||
@Getter | ||
public static class BookmarkPreview { | ||
private Long bookmarkId; | ||
private Long postId; | ||
private String title; | ||
private String content; | ||
private String image; | ||
private String location; | ||
private Long bookmarkCnt; | ||
private Long commentCnt; | ||
private LocalDateTime createdAt; | ||
|
||
@Builder | ||
public BookmarkPreview(Bookmark bookmark, Long bookmarkCnt, Long commentCnt){ | ||
this.bookmarkId = bookmark.getBookmarkId(); | ||
this.postId = bookmark.getPostId().getPostId(); | ||
this.title = bookmark.getPostId().getTitle(); | ||
this.content = bookmark.getPostId().getContent(); | ||
this.image = bookmark.getPostId().getImageList() | ||
.stream() | ||
.findFirst() | ||
.map(image -> image.getImageName()) | ||
.orElse(null); | ||
this.location = bookmark.getPostId().getLocation(); | ||
this.bookmarkCnt = bookmarkCnt; | ||
this.commentCnt = commentCnt; | ||
this.createdAt = bookmark.getPostId().getCreatedAt(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/porori/backend/community/repository/BookmarkRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
package porori.backend.community.repository; | ||
|
||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import porori.backend.community.domain.Bookmark; | ||
import porori.backend.community.domain.Post; | ||
|
||
import java.util.Optional; | ||
|
||
public interface BookmarkRepository extends JpaRepository<Bookmark, Long> { | ||
Optional<Bookmark> findByPostIdAndUserId(Post post, Long userId); | ||
|
||
Long countByPostId(Post postId); | ||
|
||
Page<Bookmark> findAllByUserIdOrderByBookmarkIdDesc(Long userId, Pageable pageable); | ||
Optional<Bookmark> findByBookmarkId(Long bookmarkId); | ||
} |
Oops, something went wrong.