-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into J01-2-be-북마크-작업
- Loading branch information
Showing
143 changed files
with
3,697 additions
and
235 deletions.
There are no files selected for viewing
4 changes: 0 additions & 4 deletions
4
src/main/java/ject/componote/domain/announcement/api/FAQController.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
src/main/java/ject/componote/domain/announcement/api/NoticeController.java
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
src/main/java/ject/componote/domain/announcement/domain/FAQRepository.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
src/main/java/ject/componote/domain/announcement/error/FAQException.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
src/main/java/ject/componote/domain/announcement/error/NoticeException.java
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
src/main/java/ject/componote/domain/announcement/model/Description.java
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
src/main/java/ject/componote/domain/announcement/model/Title.java
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
src/main/java/ject/componote/domain/announcement/model/converter/DescriptionConverter.java
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
src/main/java/ject/componote/domain/announcement/model/converter/TitleConverter.java
This file was deleted.
Oops, something went wrong.
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
8 changes: 8 additions & 0 deletions
8
src/main/java/ject/componote/domain/bookmark/dao/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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package ject.componote.domain.bookmark.dao; | ||
|
||
import ject.componote.domain.bookmark.domain.Bookmark; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface BookmarkRepository extends JpaRepository<Bookmark, Long> { | ||
boolean existsByComponentIdAndMemberId(final Long componentId, final Long memberId); | ||
} |
103 changes: 101 additions & 2 deletions
103
src/main/java/ject/componote/domain/comment/api/CommentController.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,12 +1,111 @@ | ||
package ject.componote.domain.comment.api; | ||
|
||
import jakarta.validation.Valid; | ||
import ject.componote.domain.auth.model.AuthPrincipal; | ||
import ject.componote.domain.auth.model.Authenticated; | ||
import ject.componote.domain.auth.model.User; | ||
import ject.componote.domain.comment.application.CommentService; | ||
import ject.componote.domain.comment.dto.create.request.CommentCreateRequest; | ||
import ject.componote.domain.comment.dto.create.response.CommentCreateResponse; | ||
import ject.componote.domain.comment.dto.find.response.CommentFindByComponentResponse; | ||
import ject.componote.domain.comment.dto.find.response.CommentFindByMemberResponse; | ||
import ject.componote.domain.comment.dto.update.request.CommentUpdateRequest; | ||
import ject.componote.domain.common.dto.response.PageResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.web.PageableDefault; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequestMapping("/comments") | ||
@RequiredArgsConstructor | ||
@RestController | ||
public class CommentController { | ||
private static final int DEFAULT_MEMBER_COMMENT_PAGE_SIZE = 8; | ||
private static final int DEFAULT_COMPONENT_COMMENT_PAGE_SIZE = 5; | ||
private static final int DEFAULT_REPLY_PAGE_SIZE = 5; | ||
|
||
private final CommentService commentService; | ||
|
||
@PostMapping("/comments") | ||
@User | ||
public ResponseEntity<?> create( | ||
@Authenticated final AuthPrincipal authPrincipal, | ||
@RequestBody @Valid final CommentCreateRequest commentCreateRequest | ||
) { | ||
final CommentCreateResponse commentCreateResponse = commentService.create(authPrincipal, commentCreateRequest); | ||
return ResponseEntity.ok(commentCreateResponse); | ||
} | ||
|
||
@GetMapping("/members/comments") | ||
@User | ||
public ResponseEntity<PageResponse<CommentFindByMemberResponse>> getCommentsByMemberId( | ||
@Authenticated final AuthPrincipal authPrincipal, | ||
@PageableDefault(size = DEFAULT_MEMBER_COMMENT_PAGE_SIZE) final Pageable pageable | ||
) { | ||
final PageResponse<CommentFindByMemberResponse> pageResponse = commentService.getCommentsByMemberId(authPrincipal, pageable); | ||
return ResponseEntity.ok(pageResponse); | ||
} | ||
|
||
@GetMapping("/components/{componentId}/comments") | ||
public ResponseEntity<PageResponse<CommentFindByComponentResponse>> getCommentsByComponentId( | ||
@Authenticated final AuthPrincipal authPrincipal, | ||
@PathVariable("componentId") final Long componentId, | ||
@PageableDefault(size = DEFAULT_COMPONENT_COMMENT_PAGE_SIZE) final Pageable pageable | ||
) { | ||
final PageResponse<CommentFindByComponentResponse> pageResponse = commentService.getCommentsByComponentId(authPrincipal, componentId, pageable); | ||
return ResponseEntity.ok(pageResponse); | ||
} | ||
|
||
@GetMapping("/comments/{parentId}/replies") | ||
public ResponseEntity<?> getRepliesByCommentId( | ||
@Authenticated final AuthPrincipal authPrincipal, | ||
@PathVariable("parentId") final Long parentId, | ||
@PageableDefault(size = DEFAULT_REPLY_PAGE_SIZE) final Pageable pageable | ||
) { | ||
final PageResponse<?> pageResponse = commentService.getRepliesByComponentId(authPrincipal, parentId, pageable); | ||
return ResponseEntity.ok(pageResponse); | ||
} | ||
|
||
@PutMapping("/comments/{commentId}") | ||
@User | ||
public ResponseEntity<Void> update(@Authenticated final AuthPrincipal authPrincipal, | ||
@PathVariable("commentId") final Long commentId, | ||
@RequestBody @Valid final CommentUpdateRequest commentUpdateRequest) { | ||
commentService.update(authPrincipal, commentId, commentUpdateRequest); | ||
return ResponseEntity.noContent() | ||
.build(); | ||
} | ||
|
||
@PostMapping("/comments/{commentId}/likes") | ||
@User | ||
public ResponseEntity<Void> likeComment(@Authenticated final AuthPrincipal authPrincipal, | ||
@PathVariable("commentId") final Long commentId) { | ||
commentService.likeComment(authPrincipal, commentId); | ||
return ResponseEntity.noContent() | ||
.build(); | ||
} | ||
|
||
@DeleteMapping("/comments/{commentId}/likes") | ||
@User | ||
public ResponseEntity<Void> unlikeComment(@Authenticated final AuthPrincipal authPrincipal, | ||
@PathVariable("commentId") final Long commentId) { | ||
commentService.unlikeComment(authPrincipal, commentId); | ||
return ResponseEntity.noContent() | ||
.build(); | ||
} | ||
|
||
@DeleteMapping("/comments/{commentId}") | ||
@User | ||
public ResponseEntity<Void> delete(@Authenticated final AuthPrincipal authPrincipal, | ||
@PathVariable("commentId") final Long commentId) { | ||
commentService.delete(authPrincipal, commentId); | ||
return ResponseEntity.noContent() | ||
.build(); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/ject/componote/domain/comment/application/CommentCreationStrategy.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,49 @@ | ||
package ject.componote.domain.comment.application; | ||
|
||
import ject.componote.domain.comment.domain.Comment; | ||
import ject.componote.domain.comment.dto.create.request.CommentCreateRequest; | ||
import ject.componote.domain.comment.error.InvalidCommentCreateStrategyException; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.Arrays; | ||
import java.util.function.Predicate; | ||
|
||
@RequiredArgsConstructor | ||
public enum CommentCreationStrategy { | ||
GENERAL_WITHOUT_IMAGE( | ||
request -> request.parentId() == null && request.imageObjectKey() == null, | ||
(request, memberId) -> | ||
Comment.createWithoutImage(request.componentId(), memberId, request.content()) | ||
), | ||
GENERAL_WITH_IMAGE( | ||
request -> request.parentId() == null && request.imageObjectKey() != null, | ||
(request, memberId) -> | ||
Comment.createWithImage(request.componentId(), memberId, request.content(), request.imageObjectKey()) | ||
), | ||
REPLY_WITHOUT_IMAGE( | ||
request -> request.parentId() != null && request.imageObjectKey() == null, | ||
(request, memberId) -> | ||
Comment.createReplyWithoutImage(request.componentId(), memberId, request.parentId(), request.content()) | ||
), | ||
REPLY_WITH_IMAGE( | ||
request -> request.parentId() != null && request.imageObjectKey() != null, | ||
(request, memberId) -> | ||
Comment.createReplyWithImage(request.componentId(), memberId, request.parentId(), request.content(), request.imageObjectKey()) | ||
); | ||
|
||
private final Predicate<CommentCreateRequest> condition; | ||
private final CommentCreationFunction creationFunction; | ||
|
||
public static Comment createBy(final CommentCreateRequest request, final Long memberId) { | ||
return Arrays.stream(values()) | ||
.filter(type -> type.condition.test(request)) | ||
.findFirst() | ||
.orElseThrow(InvalidCommentCreateStrategyException::new) | ||
.creationFunction.create(request, memberId); | ||
} | ||
|
||
@FunctionalInterface | ||
private interface CommentCreationFunction { | ||
Comment create(final CommentCreateRequest request, final Long memberId); | ||
} | ||
} |
Oops, something went wrong.