Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release] 수정사항 반영을 위해 배포합니다. #166

Merged
merged 97 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
43cc655
style [#56] 엔터 추가
ch1hyun Jan 16, 2025
8b1da5a
feat [#56] 콘서트 정보 조회 API 구현
ch1hyun Jan 16, 2025
5e3a02e
refactor [#62] 매개변수가 하나인 함수 이름을 from으로 변경
ch1hyun Jan 16, 2025
6400226
refactor [#62] 작성된 예외 처리 클래스로 변경
ch1hyun Jan 16, 2025
ca20c79
hotfix [#69] ArtistResolver에서 같은 객체를 계속 탐색하는 것을 수정
ch1hyun Jan 16, 2025
a6f3164
fix [#76] ArtistResolver의 load 함수에서 target이 리스트 타입인 경우 탐색 가능하도록 수정
ch1hyun Jan 17, 2025
dc27e72
style [#76] print 함수 제거
ch1hyun Jan 17, 2025
e800100
hotfix [#81] ArtistResolver 수동으로 매핑하는 방법으로 변경
ch1hyun Jan 17, 2025
4a6ea57
style [#81] 주석 추가
ch1hyun Jan 17, 2025
732b22d
feat [#78] 임시 페스티벌 생성 API 구현
ch1hyun Jan 17, 2025
d866c78
feat [#57] ArtistFavoriteController 구현
Ivoryeee Jan 17, 2025
d7c8a3c
feat [#57] UserFavoriteFacade 구현
Ivoryeee Jan 17, 2025
894fdfd
feat [#57] ArtistFavoriteService, Repository 구현
Ivoryeee Jan 17, 2025
86b232a
feat [#57] 아티스트 목록 최대 3개만 조회하도록 제한
Ivoryeee Jan 17, 2025
26748e1
refactor [#57] 메서드 of->from 변경
Ivoryeee Jan 17, 2025
58b6857
refactor [#57] 인자로 user이 아닌 userId 불러오도록 변경
Ivoryeee Jan 17, 2025
e07aa1a
style [#57] 필요없는 코드 삭제
Ivoryeee Jan 17, 2025
c391ec4
fix [#57] 메서드 of->from 변경
Ivoryeee Jan 17, 2025
5f73308
feat [#67] 페스티벌 정보 조회 API 구현 (#84)
ch1hyun Jan 18, 2025
3de20b4
feat [#85] 아티스트 검색 API 구현
ch1hyun Jan 18, 2025
722fbc8
refactor [#87] 콘서트 정보 조회 API 변경에 따른 수정
ch1hyun Jan 18, 2025
0d10105
refactor [#89] 함수명을 명확히 수정, 조회 함수에 트랜잭션 readonly = true 추가
ch1hyun Jan 18, 2025
99dd3ed
feat [#89] 아티스트 좋아요 추가 API 구현
ch1hyun Jan 18, 2025
df131d9
refactor [#89] addArtistFavorite에서 artistId 최소값 제거
ch1hyun Jan 18, 2025
2e82b9a
feat [#90] 아티스트 좋아요 삭제 API 구현
ch1hyun Jan 18, 2025
ef6d627
refactor [#90] 좋아요를 누르지 않았을 때 NOT FOUND 응답으로 변경
ch1hyun Jan 18, 2025
86b463a
feat [#91] 콘서트 좋아요 추가 API 구현 (#95)
ch1hyun Jan 18, 2025
0e0150f
feat [#92] 콘서트 좋아요 삭제 API 추가 (#97)
ch1hyun Jan 18, 2025
be1103d
feat [#98] CORS 허용 도메인 추가
ch1hyun Jan 18, 2025
0645753
refactor [#100] DateConvertor static 클래스로 변경
ch1hyun Jan 18, 2025
dd39674
feat [#83] 타임테이블에 등록된 페스티벌, 날짜 조회 (#96)
Ivoryeee Jan 18, 2025
c569d4b
refactor [#105] 날짜 매핑 방법 변경
ch1hyun Jan 18, 2025
0596289
refactor [#105] 날짜 매핑 방법 변경
ch1hyun Jan 18, 2025
cc18958
feat [#107] existsById 반환 값 boolean으로 변경 및 타임테이블 페스티벌 삭제 API 구현
ch1hyun Jan 18, 2025
f17fca6
feat [#109] 공연(콘서트, 페스티벌) 정보 조회 날짜가 지나지 않았는지 검증 추가
ch1hyun Jan 18, 2025
ea8c394
refactor [#109] 공연 좋아요 여부 조회 로직 분리
ch1hyun Jan 18, 2025
adb0d78
refactor [#109] 공연, 아티스트 좋아요 여부 조회 로직 분리
ch1hyun Jan 18, 2025
9b528af
refactor [#109] 공연, 아티스트, 유저 존재 여부 조회 로직 분리
ch1hyun Jan 18, 2025
054bc7d
style [#109] 주석 추가
ch1hyun Jan 18, 2025
e6c17a6
refactor [#109] 엔티티 존재 여부 메소드 분리
ch1hyun Jan 18, 2025
16d149f
fix [#109] 지난 페스티벌을 제외하고 타임테이블에 추가된 페스티벌을 조회하는 기능 추가
ch1hyun Jan 18, 2025
4b4e224
style [#109] 불필요한 import 제거
ch1hyun Jan 18, 2025
162a545
feat [#111] 타임테이블에 페스티벌 추가 API 구현 (#112)
ch1hyun Jan 20, 2025
234cdfb
fix [#114] SpotifyAPIHandler 예외 처리 수정
ch1hyun Jan 20, 2025
167bed3
refactor [#113] 메세지 파일 롬복 어노테이션 사용하도록 변경
ch1hyun Jan 20, 2025
762a682
feat [#113] 파사드 계층 관심 공연 DTO 작성
ch1hyun Jan 20, 2025
61671d7
feat [#113] 공연 타입 상수 파일 작성
ch1hyun Jan 20, 2025
5b29d6b
feat [#113] 작업 중간 저장
ch1hyun Jan 20, 2025
59eafec
feat [#113] 관심 공연 리스트 조회 API 구현
ch1hyun Jan 20, 2025
a06984f
feat [#117] 아티스트 좋아요 추가 API에 아티스트 아이디가 존재하는지 검증하는 로직 추가
ch1hyun Jan 20, 2025
3361de4
feat [#117] ConfetiException 글로벌 핸들러 추가
ch1hyun Jan 20, 2025
578a246
feat [#117] 아티스트 아이디가 잘못되었을 때도 Not Found로 변경
ch1hyun Jan 20, 2025
d9d3a07
fix [#121] 토큰 재발급 로직 추가
ch1hyun Jan 20, 2025
a833bdc
fix [#119] 타임테이블에 페스티벌 추가 시 선택 여부 값 추가
ch1hyun Jan 20, 2025
882cdc8
refactor [#119] ERD 구조 변경에 따른 엔티티 파일 수정
ch1hyun Jan 20, 2025
17fd48b
refactor [#119] 페스티벌 조회 성능 최적화
ch1hyun Jan 20, 2025
4437a1e
refactor [#119] 패치 조인 쿼리 수정
ch1hyun Jan 20, 2025
82affdf
fix [#119] 타임테이블에 페스티벌 추가/삭제 시 선택 여부 값 추가/삭제 및 ERD 수정에 따른 엔티티 변경
ch1hyun Jan 20, 2025
b27f38f
fix [#127] SpotifyAPIHandler 리프레시 토큰 재발급 로직 재구성 및 마지막 발매 일자 가져오는 방법 변경
ch1hyun Jan 21, 2025
7027d80
style [#127] 사용하지 않는 변수 제거
ch1hyun Jan 21, 2025
3b91ccc
feat [#41] PerformanceController, Response 구현
Ivoryeee Jan 20, 2025
4e32780
feat [#41] PerformanceFacade 구현
Ivoryeee Jan 20, 2025
548008f
feat [#41] PerformanceDTO 구현
Ivoryeee Jan 20, 2025
b9e29c2
feat [#41] PerformanceService, Repository 구현
Ivoryeee Jan 20, 2025
e25993a
refactor [#41] 코드리뷰 반영
Ivoryeee Jan 21, 2025
651a519
feat [#126] 커서 정보 담을 DTO 작성
ch1hyun Jan 21, 2025
56885e6
feat [#126] 추가할 페스티벌 응답 Response 작성
ch1hyun Jan 21, 2025
10dcbaf
feat [#126] 커서 베이스 페이징에 사용할 데이터 DTO 생성
ch1hyun Jan 21, 2025
c3e571f
feat [#126] 커서 베이스 페이징 쿼리 작성
ch1hyun Jan 21, 2025
b7658fe
feat [#126] 커서 베이스 페이징 응답 DTO 생성
ch1hyun Jan 21, 2025
7d41bad
feat [#126] 커서 베이스 페이징 데이터 규격 유틸 작성
ch1hyun Jan 21, 2025
a32de3d
feat [#126] 예정된 페스티벌 목록 조회 API 구현
ch1hyun Jan 21, 2025
44855e4
refactor [#126] API 명세서에 따라 사이즈 값을 서버에서 설정하도록 변경
ch1hyun Jan 22, 2025
45a5148
refactor [#126] 커서 대상 페스티벌 조회
ch1hyun Jan 22, 2025
21e58bd
fix [#137] CORS 허용 도메인에 클라이언트 www 도메인 추가
ch1hyun Jan 22, 2025
1c2a63b
feat [#104] 타임테이블에 등록된 시간표 조회 Api 구현 (#132)
Ivoryeee Jan 22, 2025
28bf087
fix [#140] 날짜 값 변경해서 조회
ch1hyun Jan 22, 2025
8c724be
fix [#145] 페스티벌 생성 요청 형식 수정
ch1hyun Jan 22, 2025
f8d00fa
refactor [#143] 콘서트, 페스티벌 필드 값 길이 변경
ch1hyun Jan 22, 2025
1c375da
refactor [#143] 콘서트, 페스티벌 필드 값 nullable 변경
ch1hyun Jan 22, 2025
aef93ee
fix [#143] ERD 변경에 따라 값 수정
ch1hyun Jan 22, 2025
bfb2bce
fix [#143] 기존 DTO를 사용한 Repository 이름을 DTORepository로 수정
ch1hyun Jan 22, 2025
2af1ea0
fix [#143] 누락된 수정사항 반영
ch1hyun Jan 22, 2025
ac77094
feat [#151] CREATED 응답 메세지 추가
ch1hyun Jan 22, 2025
4d95fb5
feat [#151] 페스티벌 생성 API에 Performances 테이블 데이터 추가 구현
ch1hyun Jan 22, 2025
b360549
fix [#153] 콘서트 정보 조회 API에 좋아요 정보가 전달되지 않는 것을 수정
ch1hyun Jan 22, 2025
fdd5749
feat [#144] 타임테이블 시간표 수정 Request 작성
Ivoryeee Jan 22, 2025
88931b4
feat [#144] 타임테이블 시간표 수정 DTO 추가
Ivoryeee Jan 22, 2025
8b231fb
feat [#144] 타임테이블 시간표 수정 facade 추가
Ivoryeee Jan 22, 2025
2d76f65
feat [#144] 타임테이블 시간표 수정 서비스 추가
Ivoryeee Jan 22, 2025
2ea2832
refactor [#144] saveAll 삭제
Ivoryeee Jan 22, 2025
f72c6e0
refactor [#156] 타임테이블 시간표 조회 응답값 userTimetableId로 수정
Ivoryeee Jan 22, 2025
1d0c615
refactor [#159] 스포티파이에 존재하지 않는 아티스트인 경우 404 응답 처리
ch1hyun Jan 23, 2025
12ccd85
fix [#162] 좋아요가 있을 때 409 반환
ch1hyun Jan 23, 2025
474c524
feat [#136] 최신 등록 순 공연 정보 조회 API 구현 (#158)
ch1hyun Jan 23, 2025
8e45b03
fix [#164] 트랜잭션 추가
ch1hyun Jan 23, 2025
5a435d8
Merge branch 'main' into release
ch1hyun Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import org.sopt.confeti.api.performance.dto.request.CreateFestivalRequest;
import org.sopt.confeti.api.performance.dto.response.ConcertDetailResponse;
import org.sopt.confeti.api.performance.dto.response.FestivalDetailResponse;
import org.sopt.confeti.api.performance.dto.response.RecentPerformancesResponse;
import org.sopt.confeti.api.performance.facade.PerformanceFacade;
import org.sopt.confeti.api.performance.facade.dto.request.CreateFestivalDTO;
import org.sopt.confeti.api.performance.facade.dto.response.ConcertDetailDTO;
import org.sopt.confeti.api.performance.facade.dto.response.FestivalDetailDTO;
import org.sopt.confeti.api.performance.dto.response.PerformanceReservationResponse;
import org.sopt.confeti.api.performance.facade.dto.response.PerformanceReservationDTO;
import org.sopt.confeti.api.performance.facade.dto.response.RecentPerformancesDTO;
import org.sopt.confeti.global.common.BaseResponse;
import org.sopt.confeti.global.message.SuccessMessage;
import org.sopt.confeti.global.util.ApiResponseUtil;
Expand Down Expand Up @@ -63,4 +65,12 @@ public ResponseEntity<BaseResponse<?>> getPerformReservationInfo(@RequestHeader(
PerformanceReservationDTO performanceReservationDTO = performanceFacade.getPerformReservationInfo(userId);
return ApiResponseUtil.success(SuccessMessage.SUCCESS, PerformanceReservationResponse.of(performanceReservationDTO, s3FileHandler));
}

@GetMapping("/info")
public ResponseEntity<BaseResponse<?>> getRecentPerformances(
@RequestHeader(name = "Authorization", required = false) Long userId
) {
RecentPerformancesDTO recentPerformances = performanceFacade.getRecentPerformances(userId);
return ApiResponseUtil.success(SuccessMessage.SUCCESS, RecentPerformancesResponse.of(recentPerformances, s3FileHandler));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.sopt.confeti.api.performance.dto.response;

import org.sopt.confeti.api.performance.facade.dto.response.RecentPerformanceDTO;
import org.sopt.confeti.global.util.DateConvertor;
import org.sopt.confeti.global.util.S3FileHandler;

public record RecentPerformanceResponse(
long performanceId,
long typeId,
String type,
String title,
String subtitle,
String performanceAt,
String posterUrl
) {
public static RecentPerformanceResponse of(final RecentPerformanceDTO recentPerformanceDTO, final S3FileHandler s3FileHandler) {
return new RecentPerformanceResponse(
recentPerformanceDTO.performanceId(),
recentPerformanceDTO.typeId(),
recentPerformanceDTO.type().getType(),
recentPerformanceDTO.title(),
recentPerformanceDTO.subtitle(),
DateConvertor.convertToLocalDate(recentPerformanceDTO.performanceAt()),
s3FileHandler.getFileUrl(recentPerformanceDTO.posterPath())
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.sopt.confeti.api.performance.dto.response;

import java.util.List;
import org.sopt.confeti.api.performance.facade.dto.response.RecentPerformancesDTO;
import org.sopt.confeti.global.util.S3FileHandler;

public record RecentPerformancesResponse(
List<RecentPerformanceResponse> performances
) {
public static RecentPerformancesResponse of(final RecentPerformancesDTO recentPerformancesDTO, final S3FileHandler s3FileHandler) {
return new RecentPerformancesResponse(
recentPerformancesDTO.performances().stream()
.map(recentPerformanceDTO -> RecentPerformanceResponse.of(recentPerformanceDTO, s3FileHandler))
.toList()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,51 @@
import java.time.LocalDateTime;
import java.util.List;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.RequiredArgsConstructor;
import org.sopt.confeti.annotation.Facade;
import org.sopt.confeti.api.performance.facade.dto.request.CreateFestivalDTO;
import org.sopt.confeti.api.performance.facade.dto.response.ConcertDetailDTO;
import org.sopt.confeti.api.performance.facade.dto.response.FestivalDetailDTO;
import org.sopt.confeti.api.performance.facade.dto.response.PerformanceReservationDTO;
import org.sopt.confeti.api.performance.facade.dto.response.RecentPerformancesDTO;
import org.sopt.confeti.domain.artistfavorite.ArtistFavorite;
import org.sopt.confeti.domain.artistfavorite.application.ArtistFavoriteService;
import org.sopt.confeti.domain.concert.Concert;
import org.sopt.confeti.domain.concert.application.ConcertService;
import org.sopt.confeti.domain.concertfavorite.application.ConcertFavoriteService;
import org.sopt.confeti.domain.festival.Festival;
import org.sopt.confeti.domain.festival.application.FestivalService;
import org.sopt.confeti.domain.festivalfavorite.application.FestivalFavoriteService;
import org.sopt.confeti.domain.user.application.UserService;
import org.sopt.confeti.domain.view.performance.Performance;
import org.sopt.confeti.domain.view.performance.PerformanceTicketDTO;
import org.sopt.confeti.domain.view.performance.application.PerformanceService;
import org.sopt.confeti.domain.view.performance.application.dto.request.GetPerformanceIdRequest;
import org.sopt.confeti.domain.view.performance.application.dto.response.GetPerformanceIdResponse;
import org.sopt.confeti.global.common.constant.PerformanceType;
import org.sopt.confeti.global.exception.NotFoundException;
import org.sopt.confeti.global.message.ErrorMessage;
import org.sopt.confeti.global.util.S3FileHandler;
import org.sopt.confeti.global.util.artistsearcher.ConfetiArtist;
import org.springframework.transaction.annotation.Transactional;

@Facade
@RequiredArgsConstructor
public class PerformanceFacade {

private static final int RECENT_PERFORMANCES_SIZE = 7;

private final ConcertService concertService;
private final FestivalService festivalService;
private final UserService userService;
private final FestivalFavoriteService festivalFavoriteService;
private final S3FileHandler s3FileHandler;
private final PerformanceService performanceService;
private final ConcertFavoriteService concertFavoriteService;
private final ArtistFavoriteService artistFavoriteService;

@Transactional(readOnly = true)
public ConcertDetailDTO getConcertDetailInfo(final Long userId, final long concertId) {
Expand Down Expand Up @@ -105,4 +119,43 @@ public PerformanceReservationDTO getPerformReservationInfo(final Long userId){
List<PerformanceTicketDTO> performanceReserve=performanceService.getPerformancesReservation();
return PerformanceReservationDTO.from(performanceReserve);
}

@Transactional(readOnly = true)
public RecentPerformancesDTO getRecentPerformances(final Long userId) {
if (userId == null || !hasFavoriteArtists(userId)) {
return getRecentPerformancesWithoutFavorites();
}

return getRecentPerformancesWithFavorites(userId);
}

@Transactional(readOnly = true)
public RecentPerformancesDTO getRecentPerformancesWithFavorites(final long userId) {
List<ArtistFavorite> artistFavorites = artistFavoriteService.getArtistList(userId);

return RecentPerformancesDTO.from(
performanceService.getPerformancesByArtistIds(
artistFavorites.stream()
.map(artistFavorite -> artistFavorite.getArtist().getArtistId())
.toList(),
RECENT_PERFORMANCES_SIZE
)
);
}

@Transactional(readOnly = true)
public RecentPerformancesDTO getRecentPerformancesWithoutFavorites() {
// 최신 콘서트 조회
List<Concert> concerts = concertService.getRecentConcerts(RECENT_PERFORMANCES_SIZE);

// 최신 페스티벌 조회
List<Festival> festivals = festivalService.getRecentFestivals(RECENT_PERFORMANCES_SIZE);

return RecentPerformancesDTO.of(concerts, festivals);
}

@Transactional(readOnly = true)
public boolean hasFavoriteArtists(final long userId) {
return artistFavoriteService.existsByUserId(userId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package org.sopt.confeti.api.performance.facade.dto.response;

import java.time.LocalDateTime;
import org.sopt.confeti.domain.concert.Concert;
import org.sopt.confeti.domain.festival.Festival;
import org.sopt.confeti.domain.view.performance.Performance;
import org.sopt.confeti.global.common.constant.PerformanceType;

public record RecentPerformanceDTO(
long performanceId,
long typeId,
PerformanceType type,
String title,
String subtitle,
LocalDateTime performanceAt,
String posterPath
) {
public static RecentPerformanceDTO of(final Concert concert, final long performanceId) {
return new RecentPerformanceDTO(
performanceId,
concert.getId(),
PerformanceType.CONCERT,
concert.getConcertTitle(),
concert.getConcertSubtitle(),
concert.getConcertStartAt(),
concert.getConcertPosterPath()
);
}

public static RecentPerformanceDTO of(final Festival festival, final long performanceId) {
return new RecentPerformanceDTO(
performanceId,
festival.getId(),
PerformanceType.FESTIVAL,
festival.getFestivalTitle(),
festival.getFestivalSubtitle(),
festival.getFestivalStartAt(),
festival.getFestivalPosterPath()
);
}

public static RecentPerformanceDTO from(final Performance performance) {
return new RecentPerformanceDTO(
performance.getId(),
performance.getTypeId(),
performance.getType(),
performance.getTitle(),
performance.getSubtitle(),
performance.getStartAt(),
performance.getPosterPath()
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.sopt.confeti.api.performance.facade.dto.response;

import java.util.List;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import org.sopt.confeti.domain.concert.Concert;
import org.sopt.confeti.domain.festival.Festival;
import org.sopt.confeti.domain.view.performance.Performance;

public record RecentPerformancesDTO(
List<RecentPerformanceDTO> performances
) {
public static RecentPerformancesDTO of(
List<Concert> concerts,
List<Festival> festivals
) {
return new RecentPerformancesDTO(
Stream.concat(
IntStream.range(0, concerts.size())
.mapToObj(i -> RecentPerformanceDTO.of(concerts.get(i), i)),
IntStream.range(concerts.size(), festivals.size())
.mapToObj(i -> RecentPerformanceDTO.of(festivals.get(i), i))
).toList()
);
}

public static RecentPerformancesDTO from(final List<Performance> performances) {
return new RecentPerformancesDTO(
performances.stream()
.map(RecentPerformanceDTO::from)
.toList()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void addConcertFavorite(final long userId, final long concertId) {
User user = userService.findById(userId);
Concert concert = concertService.findById(concertId);

validateExistConcertFavorite(userId, concertId);
validateNotExistConcertFavorite(userId, concertId);

concertFavoriteService.addFavorite(user, concert);
}
Expand Down Expand Up @@ -152,6 +152,13 @@ protected void validateExistConcertFavorite(final long userId, final long concer
}
}

@Transactional(readOnly = true)
protected void validateNotExistConcertFavorite(final long userId, final long concertId) {
if (concertFavoriteService.isFavorite(userId, concertId)) {
throw new ConflictException(ErrorMessage.CONFLICT);
}
}

@Transactional(readOnly = true)
protected void validateExistUser(final long userId) {
if (!userService.existsById(userId)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class UserTimetableFacade {
private final ArtistResolver artistResolver;
private final UserTimetableService userTimetableService;

@Transactional(readOnly = true)
public UserTimetableDTO getTimetablesListAndDate(long userId) {
validateExistUser(userId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ public void addFavorite(final User user, final String artistId) {
public void removeFavorite(final long userId, final String artistId) {
artistFavoriteRepository.deleteByUserIdAndArtist_ArtistId(userId, artistId);
}

@Transactional(readOnly = true)
public boolean existsByUserId(final long userId) {
return artistFavoriteRepository.existsByUserId(userId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ public interface ArtistFavoriteRepository extends JpaRepository<ArtistFavorite,
boolean existsByUserIdAndArtist_ArtistId(long userId, String artistId);

void deleteByUserIdAndArtist_ArtistId(final long userId, final String artistId);

boolean existsByUserId(final long userId);
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package org.sopt.confeti.domain.concert.application;

import java.time.LocalDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.sopt.confeti.domain.concert.Concert;
import org.sopt.confeti.domain.concert.infra.repository.ConcertRepository;
import org.sopt.confeti.global.exception.NotFoundException;
import org.sopt.confeti.global.message.ErrorMessage;
import org.sopt.confeti.global.util.artistsearcher.ArtistResolver;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Order;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
public class ConcertService {

private static final int INIT_PAGE = 0;
private static final String START_AT_COLUMN = "concertStartAt";

private final ConcertRepository concertRepository;
private final ArtistResolver artistResolver;

Expand Down Expand Up @@ -40,4 +48,22 @@ public Concert findById(final long concertId) {
() -> new NotFoundException(ErrorMessage.NOT_FOUND)
);
}

@Transactional(readOnly = true)
public List<Concert> getRecentConcerts(final int size) {
return concertRepository.findAllByConcertEndAtGreaterThanEqual(
LocalDateTime.now(),
getPageRequest(size, getRecentConcertsSort())
);
}

private PageRequest getPageRequest(final int size, final Sort sort) {
return PageRequest.of(INIT_PAGE, size, sort);
}

private Sort getRecentConcertsSort() {
return Sort.by(
Order.asc(START_AT_COLUMN)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package org.sopt.confeti.domain.concert.infra.repository;

import java.time.LocalDateTime;
import java.util.List;
import org.sopt.confeti.domain.concert.Concert;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.repository.JpaRepository;

public interface ConcertRepository extends JpaRepository<Concert, Long> {

List<Concert> findAllByConcertEndAtGreaterThanEqual(final LocalDateTime localDateTime, PageRequest pageRequest);
}
Loading
Loading