Skip to content

Commit

Permalink
[#6] refactor: 메서드명 수정 및 스트림 필터 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
sss4920 committed Oct 9, 2024
1 parent 33114f3 commit 9b462fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;
import java.util.Optional;

import dev.office.networkoffice.gathering.domain.GatheringStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

Expand All @@ -13,8 +14,8 @@ public interface GatheringRepository extends JpaRepository<Gathering, Long> {
@Query("""
SELECT g
FROM Gathering g
WHERE g.placeInfo.si = :si AND g.placeInfo.dong = :dong AND g.placeInfo.gu = :gu""")
List<Gathering> findDetailAddressBySiAndDongAndGu(String si, String dong, String gu);
WHERE g.placeInfo.si = :si AND g.placeInfo.dong = :dong AND g.placeInfo.gu = :gu AND g.gatheringStatus = :status""")
List<Gathering> findGatheringsByPlaceInfoAndStatus(String si, String dong, String gu, GatheringStatus gatheringStatus);

Optional<Gathering> findByHostIdAndId(Long hostId, Long gatheringId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,14 @@ private Gathering createGatheringByRequest(GatheringDto dto, User host) {
// 모임 정보 시동구 조회
@Transactional(readOnly = true)
public GatheringListResponseDto getGatheringByPlace(String si, String dong, String gu) {
// TODO: 분리
List<GatheringResponseDto> gatherings = gatheringRepository.findDetailAddressBySiAndDongAndGu(si, dong, gu)
List<GatheringResponseDto> gatherings = gatheringRepository.findGatheringsByPlaceInfoAndStatus(si, dong, gu, GatheringStatus.IN_PROGRESS)
.stream()
.filter(this::isGatheringInProgress)
.map(GatheringResponseDto::from)
.toList();

return GatheringListResponseDto.from(gatherings);
}

private boolean isGatheringInProgress(Gathering gathering) {
return gathering.getGatheringStatus()
.equals(GatheringStatus.IN_PROGRESS);
}

// 모임 수정
@Transactional
public GatheringResponseDto modifyGatheringInfoByHost(Long hostId, Long gatheringId, GatheringDto modifyDto) {
Expand Down

0 comments on commit 9b462fb

Please sign in to comment.