-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
J01 2 be 북마크 작업 #2
The head ref may contain hidden characters: "J01-2-be-\uBD81\uB9C8\uD06C-\uC791\uC5C5"
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다!
src/main/java/ject/componote/domain/bookmark/api/BookmarkController.java
Outdated
Show resolved
Hide resolved
src/main/java/ject/componote/domain/bookmark/application/BookmarkService.java
Outdated
Show resolved
Hide resolved
src/main/java/ject/componote/domain/bookmark/application/BookmarkService.java
Outdated
Show resolved
Hide resolved
src/main/java/ject/componote/domain/bookmark/application/BookmarkService.java
Outdated
Show resolved
Hide resolved
src/main/java/ject/componote/domain/bookmark/domain/BookmarkRepository.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다!
@RequestParam(required = false, defaultValue = "component") String type, | ||
@RequestParam(required = false, defaultValue = "createdAt") String sortType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
파라미터가 2개 이상이면 별도 DTO를 사용하는게 어떨까요?
private Pageable applySort(Pageable pageable, String type, String sortType) { | ||
Sort sort; | ||
|
||
if ("createdAt".equals(sortType)) { | ||
sort = Sort.by(Sort.Order.desc("createdAt")); | ||
} | ||
else if ("name".equals(sortType) && "component".equals(type)) { | ||
sort = Sort.by(Sort.Order.asc("summary.title")) | ||
.and(Sort.by(Sort.Order.desc("createdAt"))); | ||
} else if ("viewCount".equals(sortType) && "component".equals(type)) { | ||
sort = Sort.by(Sort.Order.desc("summary.viewCount")) | ||
.and(Sort.by(Sort.Order.desc("createdAt"))); | ||
} else if ("commentCount".equals(sortType) && "component".equals(type)) { | ||
sort = Sort.by(Sort.Order.desc("commentCount")) | ||
.and(Sort.by(Sort.Order.desc("createdAt"))); | ||
} | ||
|
||
else if ("name".equals(sortType) && "designSystem".equals(type)) { | ||
sort = Sort.by(Sort.Order.asc("summary.name")) | ||
.and(Sort.by(Sort.Order.desc("createdAt"))); | ||
} else if ("viewCount".equals(sortType) && "designSystem".equals(type)) { | ||
sort = Sort.by(Sort.Order.desc("summary.viewCount")) | ||
.and(Sort.by(Sort.Order.desc("createdAt"))); | ||
} else if ("recommendCount".equals(sortType) && "designSystem".equals(type)) { | ||
sort = Sort.by(Sort.Order.desc("summary.recommendCount")) | ||
.and(Sort.by(Sort.Order.desc("createdAt"))); | ||
} else { | ||
sort = Sort.by(Sort.Order.desc("createdAt")); | ||
} | ||
|
||
return PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
컨트롤러에서 Pageable을 전달받을 때 이 과정이 다 처리가 되는데 별도로 메서드로 처리하는 이유가 있을까요?
|
||
private Bookmark(final Long memberId, final Long componentId) { | ||
@Column(name = "type", nullable = false) | ||
private String type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type은 열거체로 관리하는게 어떨까요?
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class BookmarkService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
컴포넌트, 디자인 시스템 북마크를 하나로 처리하려 하니 전반적으로 코드 가독성과 확장성이 부족한 것 같아요 ㅜㅜ
차라리 별도 테이블로 분리한다면 로직들이 더 단순해질 것 같습니다!
참고로, 컴포넌트 검색, 상세 페이지에서 북마크 여부를 확인하는데 북마크 테이블이 분리된다면 이 기능에서도 성능 향상이 있을 것 같습니다.
@@ -0,0 +1,8 @@ | |||
package ject.componote.domain.bookmark.dto.request; | |||
|
|||
import com.google.firebase.database.annotations.NotNull; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
잘못 참조된 import
문 수정했습니다
작업 내용
테스트
Repository
Service
Controller
기타 사항 (참고 자료, 문의 사항 등)