diff --git a/application/external-api-v2/src/main/java/com/namo/spring/application/external/api/schedule/converter/MeetingScheduleResponseConverter.java b/application/external-api-v2/src/main/java/com/namo/spring/application/external/api/schedule/converter/MeetingScheduleResponseConverter.java index 5371fa3b..bfc1a94e 100644 --- a/application/external-api-v2/src/main/java/com/namo/spring/application/external/api/schedule/converter/MeetingScheduleResponseConverter.java +++ b/application/external-api-v2/src/main/java/com/namo/spring/application/external/api/schedule/converter/MeetingScheduleResponseConverter.java @@ -18,15 +18,9 @@ private MeetingScheduleResponseConverter() { throw new IllegalStateException("Util Class"); } - public static List toGetMeetingScheduleSummaryDtos( - List schedules) { - return schedules.stream() - .map(MeetingScheduleResponseConverter::toGetMeetingScheduleSummaryDto) - .collect(Collectors.toList()); - } public static MeetingScheduleResponse.GetMeetingScheduleSummaryDto toGetMeetingScheduleSummaryDto( - ScheduleSummaryQuery schedule) { + ScheduleSummaryQuery schedule, boolean hasRecord) { return MeetingScheduleResponse.GetMeetingScheduleSummaryDto.builder() .meetingScheduleId(schedule.getMeetingScheduleId()) .title(schedule.getTitle()) @@ -34,9 +28,8 @@ public static MeetingScheduleResponse.GetMeetingScheduleSummaryDto toGetMeetingS .imageUrl(schedule.getImageUrl()) .participantCount(schedule.getParticipantCount()) .participantNicknames(schedule.getParticipantNicknames()) - .hasDiary(schedule.isHasDiary()) + .hasRecord(hasRecord) .build(); - } public static List toGetMonthlyMembersScheduleDtos( diff --git a/application/external-api-v2/src/main/java/com/namo/spring/application/external/api/schedule/dto/MeetingScheduleResponse.java b/application/external-api-v2/src/main/java/com/namo/spring/application/external/api/schedule/dto/MeetingScheduleResponse.java index 28cda18e..2492b8bb 100644 --- a/application/external-api-v2/src/main/java/com/namo/spring/application/external/api/schedule/dto/MeetingScheduleResponse.java +++ b/application/external-api-v2/src/main/java/com/namo/spring/application/external/api/schedule/dto/MeetingScheduleResponse.java @@ -32,8 +32,8 @@ public static class GetMeetingScheduleSummaryDto { private Integer participantCount; @Schema(description = "모임 일정 참여자 이름", example = "뚜뚜, 코코아, 다나, 캐슬, 짱구, 연현, 램프, 반디, 유즈") private String participantNicknames; - @Schema(description = "기록 작성 여부") - private boolean hasDiary; + @Schema(description = "기록/활동 존재 여부") + private boolean hasRecord; } @AllArgsConstructor diff --git a/application/external-api-v2/src/main/java/com/namo/spring/application/external/api/schedule/service/ScheduleManageService.java b/application/external-api-v2/src/main/java/com/namo/spring/application/external/api/schedule/service/ScheduleManageService.java index ef914283..41e964bf 100644 --- a/application/external-api-v2/src/main/java/com/namo/spring/application/external/api/schedule/service/ScheduleManageService.java +++ b/application/external-api-v2/src/main/java/com/namo/spring/application/external/api/schedule/service/ScheduleManageService.java @@ -41,7 +41,6 @@ public class ScheduleManageService { private final ScheduleService scheduleService; private final ParticipantManageService participantManageService; private final ParticipantService participantService; - private final FriendshipService friendshipService; private final CategoryManageService categoryManageService; public Schedule getSchedule(Long scheduleId) { diff --git a/application/external-api-v2/src/main/java/com/namo/spring/application/external/api/schedule/usecase/MeetingScheduleUsecase.java b/application/external-api-v2/src/main/java/com/namo/spring/application/external/api/schedule/usecase/MeetingScheduleUsecase.java index baa062e3..f952b71c 100644 --- a/application/external-api-v2/src/main/java/com/namo/spring/application/external/api/schedule/usecase/MeetingScheduleUsecase.java +++ b/application/external-api-v2/src/main/java/com/namo/spring/application/external/api/schedule/usecase/MeetingScheduleUsecase.java @@ -6,7 +6,9 @@ import java.time.LocalDate; import java.util.List; +import java.util.stream.Collectors; +import com.namo.spring.db.mysql.domains.schedule.dto.ScheduleSummaryQuery; import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -46,7 +48,11 @@ public Long createMeetingSchedule(MeetingScheduleRequest.PostMeetingScheduleDto @Transactional(readOnly = true) public List getMeetingSchedules(SecurityUserDetails member) { - return toGetMeetingScheduleSummaryDtos(scheduleManageService.getMeetingScheduleSummaries(member.getUserId())); + List schedules = scheduleManageService.getMeetingScheduleSummaries(member.getUserId()); + + return schedules.stream() + .map(schedule -> toGetMeetingScheduleSummaryDto(schedule, schedule.isHasDiary() || (schedule.getActivityId() != null))) // 기록 또는 활동의 존재 여부 + .collect(Collectors.toList()); } @Transactional(readOnly = true) diff --git a/core/core-common/src/main/java/com/namo/spring/core/common/code/status/ErrorStatus.java b/core/core-common/src/main/java/com/namo/spring/core/common/code/status/ErrorStatus.java index ec4f5e2e..d6e403c9 100644 --- a/core/core-common/src/main/java/com/namo/spring/core/common/code/status/ErrorStatus.java +++ b/core/core-common/src/main/java/com/namo/spring/core/common/code/status/ErrorStatus.java @@ -113,7 +113,7 @@ public enum ErrorStatus implements BaseErrorCode { NOT_FOUND_SCHEDULE_FAILURE(HttpStatus.NOT_FOUND, "일정을 찾을 수 없습니다. (참여한 일정이 아니거나, 일정 정보가 없습니다)"), - NOT_FOUND_PARTICIPANT_FAILURE(HttpStatus.NOT_FOUND, "일정의 참여자를 찾을 수 없습니다. (모임 스케줄의 경우 초대에 수락하지 않았을 수 있습니다"), + NOT_FOUND_PARTICIPANT_FAILURE(HttpStatus.NOT_FOUND, "일정의 참여자를 찾을 수 없습니다."), NOT_FOUND_CATEGORY_FAILURE(HttpStatus.NOT_FOUND, "카테고리를 찾을 수 없습니다."), diff --git a/storage/db-mysql-v2/src/main/java/com/namo/spring/db/mysql/domains/schedule/dto/ScheduleSummaryQuery.java b/storage/db-mysql-v2/src/main/java/com/namo/spring/db/mysql/domains/schedule/dto/ScheduleSummaryQuery.java index ae57aeca..42be99e8 100644 --- a/storage/db-mysql-v2/src/main/java/com/namo/spring/db/mysql/domains/schedule/dto/ScheduleSummaryQuery.java +++ b/storage/db-mysql-v2/src/main/java/com/namo/spring/db/mysql/domains/schedule/dto/ScheduleSummaryQuery.java @@ -17,4 +17,5 @@ public class ScheduleSummaryQuery { private Integer participantCount; private String participantNicknames; private boolean hasDiary; + private Long activityId; } diff --git a/storage/db-mysql-v2/src/main/java/com/namo/spring/db/mysql/domains/schedule/repository/ParticipantRepository.java b/storage/db-mysql-v2/src/main/java/com/namo/spring/db/mysql/domains/schedule/repository/ParticipantRepository.java index c1613131..70da005a 100644 --- a/storage/db-mysql-v2/src/main/java/com/namo/spring/db/mysql/domains/schedule/repository/ParticipantRepository.java +++ b/storage/db-mysql-v2/src/main/java/com/namo/spring/db/mysql/domains/schedule/repository/ParticipantRepository.java @@ -19,9 +19,19 @@ public interface ParticipantRepository extends JpaRepository List findAllByScheduleId(Long scheduleId); @Query("SELECT new com.namo.spring.db.mysql.domains.schedule.dto.ScheduleSummaryQuery(" + - "s.id, p.customTitle, s.period.startDate, p.customImage, s.participantCount, s.participantNicknames, p.hasDiary) " + - "FROM Participant p JOIN p.schedule s JOIN p.member m " + - "WHERE p.member.id = :memberId " + + "s.id, " + + "p.customTitle, " + + "s.period.startDate, " + + "p.customImage, " + + "s.participantCount, " + + "s.participantNicknames, " + + "p.hasDiary, " + + "a.id) " + + "FROM Participant p " + + "LEFT JOIN Schedule s ON p.schedule = s " + + "LEFT OUTER JOIN Activity a ON a.schedule = s " + + "LEFT JOIN Member m ON p.member = m " + + "WHERE m.id = :memberId " + "AND s.scheduleType = :scheduleType") List findScheduleSummaryByMemberAndScheduleType(Long memberId, int scheduleType); diff --git a/storage/db-mysql-v2/src/main/java/com/namo/spring/db/mysql/domains/schedule/service/ParticipantService.java b/storage/db-mysql-v2/src/main/java/com/namo/spring/db/mysql/domains/schedule/service/ParticipantService.java index a05e1a49..8ab550fa 100644 --- a/storage/db-mysql-v2/src/main/java/com/namo/spring/db/mysql/domains/schedule/service/ParticipantService.java +++ b/storage/db-mysql-v2/src/main/java/com/namo/spring/db/mysql/domains/schedule/service/ParticipantService.java @@ -50,35 +50,29 @@ public List readParticipantsByIdsAndScheduleId(List participa return participantRepository.findParticipantByIdAndScheduleId(participantIds, scheduleId); } - @Transactional(readOnly = true) public List readScheduleParticipantSummaryByScheduleIds(Long memberId) { return participantRepository.findScheduleSummaryByMemberAndScheduleType(memberId, ScheduleType.MEETING.getValue()); } - @Transactional(readOnly = true) public boolean existsByScheduleIdAndMemberId(Long scheduleId, Long memberId) { return participantRepository.existsByScheduleIdAndMemberId(scheduleId, memberId); } - @Transactional(readOnly = true) public boolean existsByScheduleIdAndAnonymousId(Long scheduleId, Long anonymousId) { return participantRepository.existsByScheduleIdAndAnonymousId(scheduleId, anonymousId); } - @Transactional(readOnly = true) public List readParticipantsWithScheduleAndCategoryByPeriod(Long memberId, Boolean isShared, LocalDateTime startDate, LocalDateTime endDate) { return participantRepository.findParticipantsWithScheduleAndCategoryByPeriod(memberId, isShared, startDate, endDate); } - @Transactional(readOnly = true) public List readParticipantsWithUserAndScheduleByPeriod(List memberIds, LocalDateTime startDate, LocalDateTime endDate) { return participantRepository.findParticipantsWithUserAndScheduleByPeriod(memberIds, startDate, endDate); } - @Transactional(readOnly = true) public List readParticipantsByScheduleIdAndScheduleType(Long scheduleId, ScheduleType type) { return participantRepository.findParticipantsByScheduleIdAndStatusAndType(scheduleId, type.getValue()); } @@ -93,42 +87,42 @@ public void deleteByIdIn(List Ids) { participantRepository.deleteByIdIn(Ids); } - @Transactional(readOnly = true) + public Optional readMemberParticipant(Long memberId, Long scheduleId) { return participantRepository.findParticipantByMemberIdAndScheduleId(memberId, scheduleId); } - @Transactional(readOnly = true) + public Optional readAnonymousParticipant(Long anonymousId, Long scheduleId) { return participantRepository.findParticipantByAnonymousIdAndScheduleId(anonymousId, scheduleId); } - @Transactional(readOnly = true) + public Optional readFirstParticipantByScheduleId(Long scheduleId){ return participantRepository.findFirstParticipantByScheduleIdOrderByNickname(scheduleId); } - @Transactional(readOnly = true) + public List readParticipantsForDiary(Long memberId, Pageable pageable) { return participantRepository.findAllByMemberIdAndHasDiary(memberId, pageable); } - @Transactional(readOnly = true) + public List readParticipantHasDiaryByScheduleName(Long memberId, Pageable pageable, String keyword) { return participantRepository.findAllByScheduleTitleAndHasDiary(memberId, keyword, pageable); } - @Transactional(readOnly = true) + public List readParticipantHasDiaryByDiaryContent(Long memberId, Pageable pageable, String keyword) { return participantRepository.findAllByDiaryContentAndHasDiary(memberId, keyword, pageable); } - @Transactional(readOnly = true) + public List readParticipantHasDiaryByMember(Long memberId, Pageable pageable, String keyword) { return participantRepository.findAllByMemberAndHasDiary(memberId, keyword, pageable); } - @Transactional(readOnly = true) + public List readParticipantHasDiaryByDateRange(Long memberId, LocalDateTime startDate, LocalDateTime endDate) { return participantRepository.findAllByDateRangeAndHasDiary(memberId, startDate, endDate);