Skip to content

Commit

Permalink
Merge pull request #403 from Namo-log/feature/402
Browse files Browse the repository at this point in the history
[Feature/402] 모임 목록 조회시에 기록 존재 여부 필드 -> 기록or활동 존재 여부로 변경
  • Loading branch information
hosunglee222 authored Nov 1, 2024
2 parents a67c7e3 + 91005bb commit 23d7d57
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,18 @@ private MeetingScheduleResponseConverter() {
throw new IllegalStateException("Util Class");
}

public static List<MeetingScheduleResponse.GetMeetingScheduleSummaryDto> toGetMeetingScheduleSummaryDtos(
List<ScheduleSummaryQuery> 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())
.startDate(schedule.getStartDate())
.imageUrl(schedule.getImageUrl())
.participantCount(schedule.getParticipantCount())
.participantNicknames(schedule.getParticipantNicknames())
.hasDiary(schedule.isHasDiary())
.hasRecord(hasRecord)
.build();

}

public static List<MeetingScheduleResponse.GetMonthlyMembersScheduleDto> toGetMonthlyMembersScheduleDtos(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -46,7 +48,11 @@ public Long createMeetingSchedule(MeetingScheduleRequest.PostMeetingScheduleDto

@Transactional(readOnly = true)
public List<MeetingScheduleResponse.GetMeetingScheduleSummaryDto> getMeetingSchedules(SecurityUserDetails member) {
return toGetMeetingScheduleSummaryDtos(scheduleManageService.getMeetingScheduleSummaries(member.getUserId()));
List<ScheduleSummaryQuery> schedules = scheduleManageService.getMeetingScheduleSummaries(member.getUserId());

return schedules.stream()
.map(schedule -> toGetMeetingScheduleSummaryDto(schedule, schedule.isHasDiary() || (schedule.getActivityId() != null))) // 기록 또는 활동의 존재 여부
.collect(Collectors.toList());
}

@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, "카테고리를 찾을 수 없습니다."),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public class ScheduleSummaryQuery {
private Integer participantCount;
private String participantNicknames;
private boolean hasDiary;
private Long activityId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,19 @@ public interface ParticipantRepository extends JpaRepository<Participant, Long>
List<Participant> 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<ScheduleSummaryQuery> findScheduleSummaryByMemberAndScheduleType(Long memberId, int scheduleType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,35 +50,29 @@ public List<Participant> readParticipantsByIdsAndScheduleId(List<Long> participa
return participantRepository.findParticipantByIdAndScheduleId(participantIds, scheduleId);
}

@Transactional(readOnly = true)
public List<ScheduleSummaryQuery> 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<Participant> readParticipantsWithScheduleAndCategoryByPeriod(Long memberId, Boolean isShared,
LocalDateTime startDate, LocalDateTime endDate) {
return participantRepository.findParticipantsWithScheduleAndCategoryByPeriod(memberId, isShared, startDate,
endDate);
}

@Transactional(readOnly = true)
public List<ScheduleParticipantQuery> readParticipantsWithUserAndScheduleByPeriod(List<Long> memberIds,
LocalDateTime startDate, LocalDateTime endDate) {
return participantRepository.findParticipantsWithUserAndScheduleByPeriod(memberIds, startDate, endDate);
}

@Transactional(readOnly = true)
public List<Participant> readParticipantsByScheduleIdAndScheduleType(Long scheduleId, ScheduleType type) {
return participantRepository.findParticipantsByScheduleIdAndStatusAndType(scheduleId, type.getValue());
}
Expand All @@ -93,42 +87,42 @@ public void deleteByIdIn(List<Long> Ids) {
participantRepository.deleteByIdIn(Ids);
}

@Transactional(readOnly = true)

public Optional<Participant> readMemberParticipant(Long memberId, Long scheduleId) {
return participantRepository.findParticipantByMemberIdAndScheduleId(memberId, scheduleId);
}

@Transactional(readOnly = true)

public Optional<Participant> readAnonymousParticipant(Long anonymousId, Long scheduleId) {
return participantRepository.findParticipantByAnonymousIdAndScheduleId(anonymousId, scheduleId);
}

@Transactional(readOnly = true)

public Optional<Participant> readFirstParticipantByScheduleId(Long scheduleId){
return participantRepository.findFirstParticipantByScheduleIdOrderByNickname(scheduleId);
}

@Transactional(readOnly = true)

public List<Participant> readParticipantsForDiary(Long memberId, Pageable pageable) {
return participantRepository.findAllByMemberIdAndHasDiary(memberId, pageable);
}

@Transactional(readOnly = true)

public List<Participant> readParticipantHasDiaryByScheduleName(Long memberId, Pageable pageable, String keyword) {
return participantRepository.findAllByScheduleTitleAndHasDiary(memberId, keyword, pageable);
}

@Transactional(readOnly = true)

public List<Participant> readParticipantHasDiaryByDiaryContent(Long memberId, Pageable pageable, String keyword) {
return participantRepository.findAllByDiaryContentAndHasDiary(memberId, keyword, pageable);
}

@Transactional(readOnly = true)

public List<Participant> readParticipantHasDiaryByMember(Long memberId, Pageable pageable, String keyword) {
return participantRepository.findAllByMemberAndHasDiary(memberId, keyword, pageable);
}

@Transactional(readOnly = true)

public List<Participant> readParticipantHasDiaryByDateRange(Long memberId, LocalDateTime startDate,
LocalDateTime endDate) {
return participantRepository.findAllByDateRangeAndHasDiary(memberId, startDate, endDate);
Expand Down

0 comments on commit 23d7d57

Please sign in to comment.