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] 수정사항을 반영해 배포합니다. #161

Merged
merged 94 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 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
eaaec2a
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 @@ -18,17 +18,14 @@ public class ArtistFacade {

@Transactional(readOnly = true)
public SearchArtistDTO searchByKeyword(final Long userId, final String keyword) {
Optional<ConfetiArtist> confetiArtist = spotifyAPIHandler.findArtistsByKeyword(keyword);
ConfetiArtist confetiArtist = spotifyAPIHandler.findArtistsByKeyword(keyword);

boolean isFavorite = false;

if (confetiArtist.isPresent() && userId != null) {
isFavorite = artistFavoriteService.isFavorite(userId, confetiArtist.get().getArtistId());
if (userId != null) {
isFavorite = artistFavoriteService.isFavorite(userId, confetiArtist.getArtistId());
}

return SearchArtistDTO.from(
confetiArtist.orElse(ConfetiArtist.empty()),
isFavorite
);
return SearchArtistDTO.from(confetiArtist, isFavorite);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ResponseEntity<BaseResponse<?>> getConcertInfo(
@RequestHeader(name = "Authorization", required = false) Long userId,
@PathVariable("concertId") @Min(value = 0, message = "요청 형식이 올바르지 않습니다.") long concertId
) {
ConcertDetailDTO concertDetailDTO = performanceFacade.getConcertDetailInfo(concertId);
ConcertDetailDTO concertDetailDTO = performanceFacade.getConcertDetailInfo(userId, concertId);
return ApiResponseUtil.success(SuccessMessage.SUCCESS, ConcertDetailResponse.of(concertDetailDTO, s3FileHandler));
}

Expand All @@ -54,7 +54,7 @@ public ResponseEntity<BaseResponse<?>> getFestivalInfo(@RequestHeader(name = "Au
public ResponseEntity<BaseResponse<?>> createConcert(@RequestBody CreateFestivalRequest createFestivalRequest) {
performanceFacade.createFestival(CreateFestivalDTO.from(createFestivalRequest));

return ApiResponseUtil.success(SuccessMessage.SUCCESS);
return ApiResponseUtil.success(SuccessMessage.CREATED);
}

@GetMapping("/reservation")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import java.util.List;

public record CreateFestivalDateRequest(
@JsonFormat(pattern = "yyyy.MM.dd")
@JsonFormat(pattern = "yyyy.MM.dd", timezone = "Asia/Seoul")
@JsonProperty(value = "festival_at")
LocalDate festivalAt,
@JsonFormat(pattern = "HH:mm:ss")
@JsonFormat(pattern = "HH:mm:ss", timezone = "Asia/Seoul")
@JsonProperty(value = "ticket_open_at")
LocalTime ticketOpenAt,
@JsonProperty(value = "festival_stages")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ public record CreateFestivalRequest(
String festivalTitle,
@JsonProperty(value = "festival_subtitle")
String festivalSubtitle,
@JsonFormat(pattern = "yyyy.MM.dd")
@JsonFormat(pattern = "yyyy.MM.dd", timezone = "Asia/Seoul")
@JsonProperty(value = "festival_start_at")
LocalDateTime festivalStartAt,
@JsonFormat(pattern = "yyyy.MM.dd")
LocalDate festivalStartAt,
@JsonFormat(pattern = "yyyy.MM.dd", timezone = "Asia/Seoul")
@JsonProperty(value = "festival_end_at")
LocalDateTime festivalEndAt,
LocalDate festivalEndAt,
@JsonProperty(value = "festival_area")
String festivalArea,
@JsonProperty(value = "festival_poster_path")
Expand All @@ -29,9 +29,9 @@ public record CreateFestivalRequest(
String festivalReservationBgPath,
@JsonProperty(value = "festival_logo_path")
String festivalLogoPath,
@JsonFormat(pattern = "yyyy.MM.dd")
@JsonFormat(pattern = "yyyy.MM.dd", timezone = "Asia/Seoul")
@JsonProperty(value = "reserve_at")
LocalDateTime reserveAt,
LocalDate reserveAt,
@JsonProperty(value = "reservation_url")
String reservationUrl,
@JsonProperty(value = "reservation_office")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import java.util.List;

public record CreateFestivalTimeRequest(
@JsonFormat(pattern = "HH:mm:ss")
@JsonFormat(pattern = "HH:mm:ss", timezone = "Asia/Seoul")
@JsonProperty(value = "start_at")
LocalTime startAt,
@JsonFormat(pattern = "HH:mm:ss")
@JsonFormat(pattern = "HH:mm:ss", timezone = "Asia/Seoul")
@JsonProperty(value = "end_at")
LocalTime endAt,
@JsonProperty(value = "festival_artists")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public record ConcertDetailInfoResponse(
String ageRating,
String reservationOffice,
String price,
String infoImgUrl
String infoImgUrl,
boolean isFavorite
) {
public static ConcertDetailInfoResponse of(final ConcertDetailDTO concertDetailDTO, final S3FileHandler s3FileHandler) {
return new ConcertDetailInfoResponse(
Expand All @@ -39,7 +40,8 @@ public static ConcertDetailInfoResponse of(final ConcertDetailDTO concertDetailD
concertDetailDTO.ageRating(),
concertDetailDTO.reservationOffice(),
concertDetailDTO.price(),
s3FileHandler.getFileUrl(concertDetailDTO.infoImgPath())
s3FileHandler.getFileUrl(concertDetailDTO.infoImgPath()),
concertDetailDTO.isFavorite()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,20 @@ public class PerformanceFacade {
private final ConcertFavoriteService concertFavoriteService;

@Transactional(readOnly = true)
public ConcertDetailDTO getConcertDetailInfo(final long concertId) {
public ConcertDetailDTO getConcertDetailInfo(final Long userId, final long concertId) {
Concert concert = concertService.getConcertDetailByConcertId(concertId);
validateConcertNotPassed(concert);

return ConcertDetailDTO.from(concert);
return ConcertDetailDTO.of(concert, getConcertFavorite(userId, concertId));
}

@Transactional(readOnly = true)
public boolean getConcertFavorite(final Long userId, final long concertId) {
if (userId == null) {
return false;
}

return concertFavoriteService.isFavorite(userId, concertId);
}

@Transactional(readOnly = true)
Expand All @@ -52,7 +61,8 @@ protected void validateConcertNotPassed(final Concert concert) {

@Transactional
public void createFestival(final CreateFestivalDTO createFestivalDTO) {
festivalService.create(createFestivalDTO);
Festival festival = festivalService.create(createFestivalDTO);
performanceService.create(festival);
}

@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.sopt.confeti.api.performance.facade.dto.request;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import org.sopt.confeti.api.performance.dto.request.CreateFestivalRequest;
Expand Down Expand Up @@ -28,15 +27,15 @@ public static CreateFestivalDTO from(final CreateFestivalRequest createFestivalR
return new CreateFestivalDTO(
createFestivalRequest.festivalTitle(),
createFestivalRequest.festivalSubtitle(),
createFestivalRequest.festivalStartAt(),
createFestivalRequest.festivalEndAt(),
createFestivalRequest.festivalStartAt().atStartOfDay(),
createFestivalRequest.festivalEndAt().atStartOfDay(),
createFestivalRequest.festivalArea(),
createFestivalRequest.festivalPosterPath(),
createFestivalRequest.festivalPosterBgPath(),
createFestivalRequest.festivalInfoImgPath(),
createFestivalRequest.festivalReservationBgPath(),
createFestivalRequest.festivalLogoPath(),
createFestivalRequest.reserveAt(),
createFestivalRequest.reserveAt().atStartOfDay(),
createFestivalRequest.reservationUrl(),
createFestivalRequest.reservationOffice(),
createFestivalRequest.ageRating(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ public record ConcertDetailDTO(
String ageRating,
String time,
String price,
List<ConcertArtistDTO> artists
List<ConcertArtistDTO> artists,
boolean isFavorite
) {
public static ConcertDetailDTO from(final Concert concert) {
public static ConcertDetailDTO of(final Concert concert, final boolean isFavorite) {
return new ConcertDetailDTO(
concert.getId(),
concert.getConcertTitle(),
Expand All @@ -44,7 +45,8 @@ public static ConcertDetailDTO from(final Concert concert) {
concert.getPrice(),
concert.getArtists().stream()
.map(ConcertArtistDTO::of)
.toList()
.toList(),
isFavorite
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,25 @@
import jakarta.validation.constraints.Min;
import lombok.RequiredArgsConstructor;
import org.sopt.confeti.api.user.dto.request.AddTimetableFestivalRequest;
import org.sopt.confeti.api.user.dto.request.PatchTimetableRequest;
import org.sopt.confeti.api.user.dto.response.TimetablesToAddResponse;
import org.sopt.confeti.api.user.dto.response.UserTimetableDetailResponse;
import org.sopt.confeti.api.user.dto.response.UserTimetableFestivalResponse;
import org.sopt.confeti.api.user.facade.UserTimetableFacade;
import org.sopt.confeti.api.user.facade.dto.request.AddTimetableFestivalDTO;
import org.sopt.confeti.api.user.facade.dto.request.PatchTimetableDTO;
import org.sopt.confeti.api.user.facade.dto.response.TimetableToAddDTO;
import org.sopt.confeti.api.user.facade.dto.response.UserTimetableDTO;
import org.sopt.confeti.api.user.facade.dto.response.UserTimetableFestivalBasicDTO;
import org.sopt.confeti.api.user.facade.dto.response.UserTimetableFestivalDTO;
import org.sopt.confeti.global.common.BaseResponse;
import org.sopt.confeti.global.common.CursorPage;
import org.sopt.confeti.global.message.SuccessMessage;
import org.sopt.confeti.global.util.ApiResponseUtil;
import org.sopt.confeti.global.util.S3FileHandler;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

@RestController
@Validated
Expand Down Expand Up @@ -78,4 +73,13 @@ public ResponseEntity<BaseResponse<?>> getTimetableFestival(
UserTimetableFestivalBasicDTO response = userTimetableFacade.getTimetableInfo(userId, festivalDateId);
return ApiResponseUtil.success(SuccessMessage.SUCCESS, UserTimetableFestivalResponse.from(response));
}

@PatchMapping
public ResponseEntity<BaseResponse<?>> updateTimetableFestival(
@RequestHeader("Authorization") long userId,
@RequestBody PatchTimetableRequest patchTimetablerequest
){
userTimetableFacade.patchTimetableFestivals(userId, PatchTimetableDTO.from(patchTimetablerequest));
return ApiResponseUtil.success(SuccessMessage.SUCCESS);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sopt.confeti.api.user.dto.request;

public record PatchTimetableListRequest (
long userTimetableId,
boolean isSelected
){
public static PatchTimetableListRequest from(PatchTimetableListRequest request) {
return new PatchTimetableListRequest(request.userTimetableId(), request.isSelected());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.sopt.confeti.api.user.dto.request;

import java.util.List;

public record PatchTimetableRequest (
List<PatchTimetableListRequest> userTimetables
){
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import java.util.List;

public record UserTimetableFestivalTimeResponse(
Long festivalTimeId,
Long userTimetableId,
String startAt,
String endAt,
Boolean isSelected,
List<UserTimetableFestivalArtistResponse> artists
) {
public static UserTimetableFestivalTimeResponse from(UserTimetableFestivalTimeDTO festivalTime) {
return new UserTimetableFestivalTimeResponse(
festivalTime.festivalTimeId(),
festivalTime.userTimetableId(),
DateConvertor.convert(festivalTime.startAt()),
DateConvertor.convert(festivalTime.endAt()),
festivalTime.isSelected(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package org.sopt.confeti.api.user.facade;

import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Predicate;
import lombok.RequiredArgsConstructor;
import org.sopt.confeti.annotation.Facade;
import org.sopt.confeti.api.user.facade.dto.request.AddTimetableFestivalArtiestDTO;
import org.sopt.confeti.api.user.facade.dto.request.AddTimetableFestivalDTO;
import org.sopt.confeti.api.user.facade.dto.request.PatchTimetableDTO;
import org.sopt.confeti.api.user.facade.dto.request.PatchTimetableListDTO;
import org.sopt.confeti.api.user.facade.dto.response.TimetableToAddDTO;
import org.sopt.confeti.api.user.facade.dto.response.UserTimetableDTO;
import org.sopt.confeti.api.user.facade.dto.response.UserTimetableFestivalBasicDTO;
Expand All @@ -14,23 +18,23 @@
import org.sopt.confeti.domain.festivaldate.FestivalDate;
import org.sopt.confeti.domain.festivaldate.application.FestivalDateService;
import org.sopt.confeti.domain.festival.application.dto.FestivalCursorDTO;
import org.sopt.confeti.domain.festivaldate.FestivalDate;
import org.sopt.confeti.domain.festivaldate.application.FestivalDateService;
import org.sopt.confeti.domain.festivaltime.FestivalTime;
import org.sopt.confeti.domain.timetablefestival.TimetableFestival;
import org.sopt.confeti.domain.timetablefestival.application.TimetableFestivalService;
import org.sopt.confeti.domain.user.User;
import org.sopt.confeti.domain.user.application.UserService;
import org.sopt.confeti.domain.usertimetable.UserTimetable;
import org.sopt.confeti.domain.usertimetable.application.UserTimetableService;
import org.sopt.confeti.global.common.CursorPage;
import org.sopt.confeti.global.exception.ConflictException;
import org.sopt.confeti.global.exception.NotFoundException;
import org.sopt.confeti.global.exception.UnauthorizedException;
import org.sopt.confeti.global.message.ErrorMessage;
import org.sopt.confeti.global.util.artistsearcher.ArtistResolver;
import org.sopt.confeti.global.util.artistsearcher.ArtistResolver;
import org.springframework.data.domain.PageRequest;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

@Facade
@RequiredArgsConstructor
Expand All @@ -45,8 +49,8 @@ public class UserTimetableFacade {
private final FestivalService festivalService;
private final FestivalDateService festivalDateService;
private final ArtistResolver artistResolver;
private final UserTimetableService userTimetableService;

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

Expand Down Expand Up @@ -151,10 +155,20 @@ public CursorPage<TimetableToAddDTO> getTimetablesToAdd(final long userId, final
public UserTimetableFestivalBasicDTO getTimetableInfo(final long userId, final long festivalDateId) {
validateUserExists(userId);

FestivalDate festivalDate = festivalDateService.findFestivalDateId(userId, festivalDateId);
FestivalDate festivalDate = festivalDateService.findFestivalDateId(festivalDateId);
artistResolver.load(festivalDate);

return UserTimetableFestivalBasicDTO.from(festivalDate);
List<Long> festivalTimeIds = festivalDate.getStages().stream()
.flatMap(festivalStage -> festivalStage.getTimes().stream())
.map(FestivalTime::getId)
.toList();

List<UserTimetable> userTimetables = userTimetableService.getUserTimetables(userId, festivalTimeIds);

Map<Long, UserTimetable> userTimetableMapper = userTimetables.stream()
.collect(Collectors.toMap(UserTimetable::getId, Function.identity()));

return UserTimetableFestivalBasicDTO.of(festivalDate, userTimetableMapper);
}

@Transactional(readOnly = true)
Expand All @@ -171,5 +185,11 @@ public FestivalCursorDTO getFestivalCursor(final long userId, final long cursor)
() -> new NotFoundException(ErrorMessage.NOT_FOUND)
);
}

@Transactional
public void patchTimetableFestivals(final long userId, final PatchTimetableDTO timetableDTO) {
validateUserExists(userId);
userTimetableService.patchTimetableFestival(userId, timetableDTO);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.sopt.confeti.api.user.facade.dto.request;

import org.sopt.confeti.api.user.dto.request.PatchTimetableRequest;

import java.util.List;

public record PatchTimetableDTO (
List<PatchTimetableListDTO> userTimetables
) {
public static PatchTimetableDTO from(PatchTimetableRequest timetableRequest) {
return new PatchTimetableDTO(
timetableRequest.userTimetables()
.stream()
.map(PatchTimetableListDTO::from)
.toList()
);
}
}

Loading
Loading