Skip to content
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

Merged
merged 24 commits into from
Jan 3, 2025
Merged

J01 2 be 북마크 작업 #2

merged 24 commits into from
Jan 3, 2025

Conversation

SSUHYUNKIM
Copy link
Contributor

@SSUHYUNKIM SSUHYUNKIM commented Dec 22, 2024

작업 내용

  • 북마크 작업

테스트

Repository

  • 작업중

Service

image

Controller

  • 회원가입이 안돼서 작업 불가능

기타 사항 (참고 자료, 문의 사항 등)

  • 저희 build.gradle 혹시 config에 추가하는 건가요?

@SSUHYUNKIM SSUHYUNKIM added ✔︎pull requests pull requests 코드 체크 요청 ✨feature 구현, 개선 사항 관련 부분 👨🏻‍💻backend 백엔드 작업 labels Dec 22, 2024
@SSUHYUNKIM SSUHYUNKIM requested a review from kmw2378 December 22, 2024 14:01
@SSUHYUNKIM SSUHYUNKIM self-assigned this Dec 22, 2024
Copy link
Contributor

@kmw2378 kmw2378 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다!

@SSUHYUNKIM SSUHYUNKIM requested a review from kmw2378 December 22, 2024 14:44
Copy link
Contributor

@kmw2378 kmw2378 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다!

Comment on lines +34 to +35
@RequestParam(required = false, defaultValue = "component") String type,
@RequestParam(required = false, defaultValue = "createdAt") String sortType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

파라미터가 2개 이상이면 별도 DTO를 사용하는게 어떨까요?

Comment on lines +132 to +163
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);
}
Copy link
Contributor

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;
Copy link
Contributor

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

컴포넌트, 디자인 시스템 북마크를 하나로 처리하려 하니 전반적으로 코드 가독성과 확장성이 부족한 것 같아요 ㅜㅜ
차라리 별도 테이블로 분리한다면 로직들이 더 단순해질 것 같습니다!

참고로, 컴포넌트 검색, 상세 페이지에서 북마크 여부를 확인하는데 북마크 테이블이 분리된다면 이 기능에서도 성능 향상이 있을 것 같습니다.

@SSUHYUNKIM SSUHYUNKIM merged commit 191aae1 into develop Jan 3, 2025
@@ -0,0 +1,8 @@
package ject.componote.domain.bookmark.dto.request;

import com.google.firebase.database.annotations.NotNull;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

잘못 참조된 import 문 수정했습니다

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👨🏻‍💻backend 백엔드 작업 ✨feature 구현, 개선 사항 관련 부분 ✔︎pull requests pull requests 코드 체크 요청
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants