Skip to content

Commit

Permalink
Feat: isProgress 값 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
rrosiee committed Oct 24, 2024
1 parent 664aa28 commit 0d1ab7f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public ResponseEntity<CulturalEventDetailListDto> getCulturalEventList(
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "10") int size,
@RequestParam(required = false) String ordering,
@RequestParam(required = false) Boolean isProgress,
@RequestParam(required = false) Boolean isOpened,
@RequestParam(required = false) Long recommendCriteria,
@RequestParam(required = false) Double latitude,
@RequestParam(required = false) Double longitude,
@RequestParam(required = false) List<CategoryTitle> categories,
Expand All @@ -68,7 +70,7 @@ public ResponseEntity<CulturalEventDetailListDto> getCulturalEventList(

// Get Cultural Event List Dto
List<CulturalEvent> culturalEventList = culturalEventService
.getCulturalEventList(page, size, categories, ordering, isOpened, latitude, longitude, keyword);
.getCulturalEventList(page, size, categories, ordering, isProgress, isOpened, latitude, longitude, keyword);
List<CulturalEventListDto> culturalEventResponseDtoList = culturalEventMapper
.culturalEventToCulturalEventListDtos(culturalEventList);
culturalEventResponseDtoList.forEach(dto -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.List;

public interface CulturalEventRepositoryCustom {
List<CulturalEvent> getCulturalEventList(int page, int size, List<CategoryTitle> categories, String ordering, Boolean isOpened, Double latitude, Double longitude, String keyword);
List<CulturalEvent> getCulturalEventList(int page, int size, List<CategoryTitle> categories, String ordering, Boolean isProgress, Boolean isOpened, Double latitude, Double longitude, String keyword);

List<CulturalEvent> getCulturalEventSearchList(int page, int size, String keyword);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class CulturalEventRepositoryImpl implements CulturalEventRepositoryCusto
private final MemberJwtService memberJwtService;

@Override
public List<CulturalEvent> getCulturalEventList(int page, int size, List<CategoryTitle> categories, String ordering, Boolean isOpened, Double latitude, Double longitude, String keyword) {
public List<CulturalEvent> getCulturalEventList(int page, int size, List<CategoryTitle> categories, String ordering, Boolean isProgress, Boolean isOpened, Double latitude, Double longitude, String keyword) {
// 현재 시간
LocalDateTime now = LocalDateTime.now();
ZonedDateTime zonedDateTime = now.atZone(ZoneId.systemDefault());
Expand Down Expand Up @@ -69,6 +69,20 @@ public List<CulturalEvent> getCulturalEventList(int page, int size, List<Categor
}
}

// isProgress 있을 경우
if (isProgress != null) {
Date nowDate = new Date(); // 현재 시간을 한 번 가져옵니다.

if (isProgress) {
// 공연이 진행 중인 경우 (시작일이 현재 시간 이전이고 종료일이 현재 시간 이후일 때)
culturalEventJPAQuery.where(culturalEvent.startDate.before(nowDate).and(culturalEvent.endDate.after(nowDate)));
} else {
// 공연이 끝난 경우 (시작일이 현재 시간 이전일 때)
culturalEventJPAQuery.where(culturalEvent.startDate.after(nowDate));
}
}


// isOpened 있을 경우
if (isOpened != null) {
if (isOpened) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public class CulturalEventService {
private final CulturalEventVisitRepository culturalEventVisitRepository;
private final NotificationService notificationService;

public List<CulturalEvent> getCulturalEventList(int page, int size, List<CategoryTitle> categories, String ordering, Boolean isOpened, Double latitude, Double longitude, String keyword) {
return culturalEventRepository.getCulturalEventList(page, size, categories, ordering, isOpened, latitude, longitude, keyword);
public List<CulturalEvent> getCulturalEventList(int page, int size, List<CategoryTitle> categories, String ordering, Boolean isProgress, Boolean isOpened, Double latitude, Double longitude, String keyword) {
return culturalEventRepository.getCulturalEventList(page, size, categories, ordering, isProgress, isOpened, latitude, longitude, keyword);
}

public List<CulturalEvent> getCulturalEventSearchList(int page, int size, String keyword) {
Expand Down Expand Up @@ -71,7 +71,7 @@ public void unLike(Long id) {
CulturalEvent culturalEvent = getCulturalEvent(id);
Optional<CulturalEventLike> culturalEventLikeOptional = culturalEvent.findMemberLike(member);

if (culturalEventLikeOptional.isEmpty()) {
if (!culturalEventLikeOptional.isPresent()) {
return;
}

Expand Down

0 comments on commit 0d1ab7f

Please sign in to comment.