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

[Feature/#213] 모집글 작성 알림 구현 및 리팩토링 #218

Merged
merged 5 commits into from
Aug 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor: 알림 기능 리팩토링
- NotificationRepositoryCustom.java
- 사용자별 알림 목록 단순 조회 로직에서 엔티티를 직접 레포지토리에서 조회하고 있으므로 DTO 를 활용하여 조회하도록 리턴값 수정
- findNotificationByMemberUsername() 메서드 리턴값 수정

- NotificationRepositoryCustomImpl.java
- 사용자별 알림 목록 단순 조회 로직에서 엔티티를 직접 레포지토리에서 조회하고 있으므로 DTO 를 활용하도록 로직 수정
- findNotificationByMemberUsername() 메서드 로직 수정
runtime-zer0 committed Aug 4, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit b0632b6017f00f71592bf93c5c84a6957b48f5ba
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package sumcoda.boardbuddy.repository.notification;

import sumcoda.boardbuddy.entity.Notification;
import sumcoda.boardbuddy.dto.NotificationResponse;

import java.util.List;

public interface NotificationRepositoryCustom {

List<Notification> findNotificationByMemberUsername(String username);
List< NotificationResponse.NotificationDTO> findNotificationByMemberUsername(String username);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package sumcoda.boardbuddy.repository.notification;

import com.querydsl.core.types.Projections;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import sumcoda.boardbuddy.entity.Notification;
import sumcoda.boardbuddy.dto.NotificationResponse;

import java.util.List;

@@ -22,8 +23,10 @@ public class NotificationRepositoryCustomImpl implements NotificationRepositoryC
* @return 최신순으로 정렬된 알림 내역
**/
@Override
public List<Notification> findNotificationByMemberUsername(String username) {
return jpaQueryFactory.selectFrom(notification)
public List< NotificationResponse.NotificationDTO> findNotificationByMemberUsername(String username) {
return jpaQueryFactory.select(Projections.fields(NotificationResponse.NotificationDTO.class,
notification.message,
notification.createdAt))
.join(notification.member, member)
.where(member.username.eq(username))
.orderBy(notification.createdAt.desc())