Skip to content

Commit

Permalink
Develop backend 작업 사항 반영 (#479)
Browse files Browse the repository at this point in the history
* feat: 해주세요 조회 내림차순 조회

* feat: 찜한 모임 조회 내림차순

* feat: 모임 조회 내림차순

* feat: 알림 조회 내림차순

* test: 테스트 수정

* feat: 모집중인 모임만 조회

* fix: 같은 다락방 참여자에게만 모임 생성 알림이 전송되도록 수정

* fix: 부모 댓글 조회 오타 수정

* chore: 배포 서버 설정

* fix: 다락방 멤버의 멤버아이디를 가져오도록 변경

---------

Co-authored-by: MingyeomKim <[email protected]>
  • Loading branch information
ay-eonii and Mingyum-Kim authored Aug 22, 2024
1 parent 3b13c8a commit 3a8a47f
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public interface ChamyoRepository extends JpaRepository<Chamyo, Long> {

boolean existsByMoimIdAndDarakbangMemberId(Long moimId, Long darakbangMemberId);

List<Chamyo> findAllByDarakbangMemberId(Long darakbangMemberId);
List<Chamyo> findAllByDarakbangMemberIdOrderByIdDesc(Long darakbangMemberId);

void deleteAllByMoimId(Long moimId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public interface CommentRepository extends JpaRepository<Comment, Long> {

@Query("SELECT c.darakbangMember.memberId FROM Comment c WHERE c.parentId = :parentId")
@Query("SELECT c.darakbangMember.memberId FROM Comment c WHERE c.id = :parentId")
Long findMemberIdByParentId(@Param("parentId") long parentId);

List<Comment> findAllByMoimIdOrderByCreatedAt(long id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ public interface MoimRepository extends JpaRepository<Moim, Long> {
@Modifying
int updateMoimStatusById(@Param("id") Long moimId, @Param("status") MoimStatus status);

List<Moim> findAllByDarakbangId(Long darakbangId);

boolean existsByIdAndDarakbangId(Long moimId, Long darakbangId);
@Query("""
SELECT m From Moim m
WHERE m.darakbangId = :darakbangId AND m.moimStatus = 'MOIMING'
ORDER BY m.id DESC
""")
List<Moim> findAllByDarakbangIdOrderByIdDesc(@Param("darakbangId") Long darakbangId);
}
16 changes: 12 additions & 4 deletions backend/src/main/java/mouda/backend/moim/service/MoimService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Stream;

import org.springframework.beans.factory.annotation.Value;
Expand All @@ -22,6 +23,7 @@
import mouda.backend.comment.exception.CommentException;
import mouda.backend.comment.repository.CommentRepository;
import mouda.backend.darakbangmember.domain.DarakbangMember;
import mouda.backend.darakbangmember.repository.repository.DarakbangMemberRepository;
import mouda.backend.moim.domain.FilterType;
import mouda.backend.moim.domain.Moim;
import mouda.backend.moim.domain.MoimStatus;
Expand All @@ -44,6 +46,7 @@
@RequiredArgsConstructor
public class MoimService {

private final DarakbangMemberRepository darakbangMemberRepository;
@Value("${url.base}")
private String baseUrl;

Expand Down Expand Up @@ -72,13 +75,17 @@ public Moim createMoim(Long darakbangId, DarakbangMember darakbangMember, MoimCr
.targetUrl(baseUrl + String.format(moimUrl, darakbangId, moim.getId()))
.build();

notificationService.notifyToAllExceptMember(notification, darakbangMember.getMemberId(), darakbangId);
List<Long> darakbangMembersExceptMe = darakbangMemberRepository.findAllByDarakbangId(darakbangId).stream()
.filter(member -> !Objects.equals(member.getId(), darakbangMember.getId()))
.map(DarakbangMember::getMemberId)
.toList();
notificationService.notifyToMembers(notification, darakbangMembersExceptMe, darakbangId);
return moim;
}

@Transactional(readOnly = true)
public MoimFindAllResponses findAllMoim(Long darakbangId, DarakbangMember darakbangMember) {
List<Moim> moims = moimRepository.findAllByDarakbangId(darakbangId);
List<Moim> moims = moimRepository.findAllByDarakbangIdOrderByIdDesc(darakbangId);
return new MoimFindAllResponses(
moims.stream()
.map(moim -> {
Expand Down Expand Up @@ -301,7 +308,8 @@ private void validateCanEditMoim(Moim moim, DarakbangMember darakbangMember) {
}

public MoimFindAllResponses findAllMyMoim(DarakbangMember darakbangMember, FilterType filter) {
Stream<Chamyo> chamyoStream = chamyoRepository.findAllByDarakbangMemberId(darakbangMember.getId()).stream();
Stream<Chamyo> chamyoStream = chamyoRepository.findAllByDarakbangMemberIdOrderByIdDesc(darakbangMember.getId())
.stream();

if (filter == FilterType.PAST) {
chamyoStream = chamyoStream.filter(chamyo -> chamyo.getMoim().isPastMoim());
Expand All @@ -324,7 +332,7 @@ public MoimFindAllResponses findAllMyMoim(DarakbangMember darakbangMember, Filte
}

public MoimFindAllResponses findZzimedMoim(DarakbangMember darakbangMember) {
List<Zzim> zzims = zzimRepository.findAllByDarakbangMemberId(darakbangMember.getId());
List<Zzim> zzims = zzimRepository.findAllByDarakbangMemberIdOrderByIdDesc(darakbangMember.getId());

List<MoimFindAllResponse> responses = zzims.stream()
.map(zzim -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

public interface MemberNotificationRepository extends JpaRepository<MemberNotification, Long> {

List<MemberNotification> findAllByMemberIdAndDarakbangId(Long memberId, Long darakbangId);
List<MemberNotification> findAllByMemberIdAndDarakbangIdOrderByIdDesc(Long memberId, Long darakbangId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private List<List<String>> chunkFcmTokensForMulticast(List<String> tokens) {
}

public NotificationFindAllResponses findAllMyNotifications(Member member, Long darakbangId) {
List<NotificationFindAllResponse> responses = memberNotificationRepository.findAllByMemberIdAndDarakbangId(
List<NotificationFindAllResponse> responses = memberNotificationRepository.findAllByMemberIdAndDarakbangIdOrderByIdDesc(
member.getId(), darakbangId)
.stream()
.map(MemberNotification::getMoudaNotification)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@

public interface PleaseRepository extends JpaRepository<Please, Long> {

List<Please> findAllByDarakbangId(Long darakbangId);

boolean existsByIdAndDarakbangId(Long pleaseId, Long darakbangId);
List<Please> findAllByDarakbangIdOrderByIdDesc(Long darakbangId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void deletePlease(Long darakbangId, Long pleaseId, DarakbangMember darakb
}

public PleaseFindAllResponses findAllPlease(Long darakbangId, DarakbangMember darakbangMember) {
List<Please> pleases = pleaseRepository.findAllByDarakbangId(darakbangId);
List<Please> pleases = pleaseRepository.findAllByDarakbangIdOrderByIdDesc(darakbangId);

return new PleaseFindAllResponses(
pleases.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ public interface ZzimRepository extends JpaRepository<Zzim, Long> {

void deleteAllByMoimId(Long moimId);

List<Zzim> findAllByDarakbangMemberId(Long darakbangMemberId);
List<Zzim> findAllByDarakbangMemberIdOrderByIdDesc(Long darakbangMemberId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ void findAllMyNotifications() {
assertThat(responses).satisfies(res -> {
assertThat(res).hasSize(2);
assertThat(res).extracting(NotificationFindAllResponse::message)
.containsExactly(type1.createMessage("테스트모임"), type2.createMessage("상돌"));
.containsExactly(type2.createMessage("상돌"), type1.createMessage("테스트모임"));
assertThat(res).extracting(NotificationFindAllResponse::type)
.containsExactly(type1.toString(), type2.toString());
.containsExactly(type2.toString(), type1.toString());
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ void findAllPlease() {

PleaseFindAllResponses pleaseFindAllResponses = pleaseService.findAllPlease(
darakbang.getId(), darakbangHogee);
assertThat(pleaseFindAllResponses.pleases().get(0).isInterested()).isTrue();
assertThat(pleaseFindAllResponses.pleases().get(1).isInterested()).isFalse();
assertThat(pleaseFindAllResponses.pleases()).extracting("isInterested").containsExactly(false, true);
}
}
}

0 comments on commit 3a8a47f

Please sign in to comment.