Skip to content

Commit

Permalink
Merge pull request #66 from AndLetgo/develop
Browse files Browse the repository at this point in the history
🚀 [DEPLOY]: 10차 배포
  • Loading branch information
phonil authored Jan 11, 2024
2 parents 39477ef + a012156 commit 4de2f08
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public ResponseEntity<?> getActivityAlarmList(Integer page, UserPrincipal userPr
User findUser = userService.validateUserByToken(userPrincipal);
List<AlarmType> types = Arrays.asList(AlarmType.RATING, AlarmType.REVIEW, AlarmType.REPLY, AlarmType.FOLLOW);

PageRequest pageRequest = PageRequest.of(page, 20, Sort.by(Sort.Direction.DESC, "modifiedDate"));
PageRequest pageRequest = PageRequest.of(page, 20, Sort.by(Sort.Direction.DESC, "createdDate"));
Slice<Alarm> alarmPage = alarmRepository.findSliceByUserIdAndAlarmTypeIn(pageRequest, findUser.getId(), types);
List<Alarm> alarmList = alarmPage.getContent();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ public ResponseEntity<?> searchPlaces(Integer page, String searchWord) {

DefaultAssert.isTrue(!places.isEmpty(), "해당 검색어를 포함한 전시 공간이 존재하지 않습니다.");

List<PlaceResponseDto.SearchPlaceRes> searchPlaceResList = PlaceConverter.toSearchPlaceListRes(places);
List<PlaceResponseDto.PlaceInfoRes> placeInfoListRes = PlaceConverter.toPlaceInfoListRes(places);
boolean hasNextPage = placePage.hasNext();
PlaceResponseDto.SearchPlaceResWithPaging searchPlaceResWithPaging = PlaceConverter.toSearchPlaceResWithPaging(hasNextPage, searchPlaceResList);
PlaceResponseDto.PlaceInfoResWithPaging placeInfoResWithPaging = PlaceConverter.toPlaceInfoResWithPaging(hasNextPage, placeInfoListRes);

ApiResponse apiResponse = ApiResponse.toApiResponse(searchPlaceResWithPaging);
ApiResponse apiResponse = ApiResponse.toApiResponse(placeInfoResWithPaging);

return ResponseEntity.ok(apiResponse);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,10 @@ public static List<PlaceResponseDto.PlaceInfoRes> toPlaceInfoListRes(List<Place>
return placeInfoResList;
}

// Places -> SearchPlaceResList
public static List<PlaceResponseDto.SearchPlaceRes> toSearchPlaceListRes(List<Place> places) {

List<PlaceResponseDto.SearchPlaceRes> searchPlaceResList = new ArrayList<>();

for (Place place : places) {
PlaceResponseDto.SearchPlaceRes searchPlaceRes = PlaceResponseDto.SearchPlaceRes.builder()
.placeId(place.getId())
.placeName(place.getName())
.build();

searchPlaceResList.add(searchPlaceRes);
}

return searchPlaceResList;
}

public static PlaceResponseDto.SearchPlaceResWithPaging toSearchPlaceResWithPaging(boolean hasNextPage, List<PlaceResponseDto.SearchPlaceRes> searchPlaceResList) {
return PlaceResponseDto.SearchPlaceResWithPaging.builder()
public static PlaceResponseDto.PlaceInfoResWithPaging toPlaceInfoResWithPaging(boolean hasNextPage, List<PlaceResponseDto.PlaceInfoRes> placeInfoResList) {
return PlaceResponseDto.PlaceInfoResWithPaging.builder()
.hasNextPage(hasNextPage)
.data(searchPlaceResList)
.data(placeInfoResList)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,5 @@ public interface PlaceRepository extends JpaRepository<Place, Long> {

Optional<Place> findByAddress(String placeAddr);

Page<Place> findByNameContainingOrAddressContaining(Pageable pageable, String searchWord, String searchWord2);

Slice<Place> findSliceByNameContainingOrAddressContaining(Pageable pageable, String searchWord, String searchWord2);
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,14 @@ public static class PlaceInfoRes {
private String placeAddress;
}

// 검색어를 포함한 전시 공간 목록 조회
@Data
@Builder
public static class SearchPlaceRes {

@Schema(type = "Long", example = "1", description = "전시 공간 ID입니다.")
private Long placeId;

@Schema(type = "String", example = "롯데콘서트홀", description = "전시 공간 이름입니다.")
private String placeName;

}

@Data
@Builder
public static class SearchPlaceResWithPaging {
public static class PlaceInfoResWithPaging {

@Schema(type = "boolean", example = "true", description = "다음 페이지 존재 여부를 반환합니다.")
private boolean hasNextPage;

private List<PlaceResponseDto.SearchPlaceRes> data;
private List<PlaceResponseDto.PlaceInfoRes> data;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public ResponseEntity<?> findExhibitionListInPlace(
// TODO : 논의 후 페이징 처리
@Operation(summary = "검색어를 포함한 전시 공간의 목록 조회", description = "전시 공간을 검색합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "조회 성공", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = PlaceResponseDto.SearchPlaceResWithPaging.class))}),
@ApiResponse(responseCode = "200", description = "조회 성공", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = PlaceResponseDto.PlaceInfoResWithPaging.class))}),
@ApiResponse(responseCode = "400", description = "조회 실패", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class))}),
})
@GetMapping("/search/{searchWord}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,19 @@ public ResponseEntity<?> checkIsWrite(UserPrincipal userPrincipal, Long exhibiti
Optional<Exhibition> findExhibition = exhibitionRepository.findById(exhibitionId);
DefaultAssert.isTrue(findExhibition.isPresent(), "전시회 정보가 올바르지 않습니다.");

Boolean isWrite = reviewRepository.existsByUserIdAndExhibitionId(findUser.getId(), exhibitionId);
ReviewResponseDto.CheckIsWriteRes responseDto = ReviewResponseDto.CheckIsWriteRes.builder().isWrite(isWrite).build();
Optional<Review> findReview = reviewRepository.findByUserIdAndExhibitionId(findUser.getId(), exhibitionId);
Boolean isWrite = false;
String contents = "";
if (findReview.isPresent()) {
isWrite = true;
contents = findReview.get().getContents();
} else {
contents = null;
}
ReviewResponseDto.CheckIsWriteRes responseDto = ReviewResponseDto.CheckIsWriteRes.builder()
.isWrite(isWrite)
.contents(contents)
.build();
ApiResponse apiResponse = ApiResponse.toApiResponse(responseDto);
return ResponseEntity.ok(apiResponse);
}
Expand All @@ -174,8 +185,13 @@ public ResponseEntity<?> getReview(Long reviewId) {
Review review = validateReviewById(reviewId);
User user = review.getUser();
Exhibition exhibition = review.getExhibition();
Rating rating = ratingService.validateRatingByUserIdAndExhibitionId(user.getId(), exhibition.getId());
Double rate = rating.getRate();

Optional<Rating> findRating = ratingRepository.findByUserIdAndExhibitionId(user.getId(), exhibition.getId());
Double rate = null;
if (findRating.isPresent()) {
Rating rating = findRating.get();
rate = rating.getRate();
}

UserResponseDto.SearchUsersRes userRes = UserConverter.toSearchUserRes(user);
ReviewResponseDto.ReviewListRes reviewRes = ReviewConverter.toReviewListRes(review, userRes, rate);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package depth.jeonsilog.domain.review.domain.repository;

import depth.jeonsilog.domain.reply.domain.Reply;
import depth.jeonsilog.domain.review.domain.Review;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
Expand All @@ -9,13 +8,14 @@
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface ReviewRepository extends JpaRepository<Review, Long> {

List<Review> findAllByUserId(Long userId);

Boolean existsByUserIdAndExhibitionId(Long userId, Long exhibitionId);
Optional<Review> findByUserIdAndExhibitionId(Long userId, Long exhibitionId);

Page<Review> findByUserId(PageRequest pageRequest, Long userId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public static class CheckIsWriteRes {

@Schema(type = "boolean", example = "true", description = "해당 전시회 - 감상평 작성 여부를 출력합니다.")
private Boolean isWrite;

@Schema(type = "string", example = "멋진 전시였다.", description = "감상평을 출력합니다. isWrite = false 시 contents = null.")
private String contents;
}

}

0 comments on commit 4de2f08

Please sign in to comment.