Skip to content

Commit

Permalink
Merge pull request #64 from AndLetgo/develop
Browse files Browse the repository at this point in the history
🚀 [DEPLOY]: 9차 배포
  • Loading branch information
gyehwan24 authored Jan 10, 2024
2 parents e0c34cf + 656b01f commit 39477ef
Show file tree
Hide file tree
Showing 49 changed files with 497 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Sort;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Scheduled;
Expand Down Expand Up @@ -63,7 +64,7 @@ public ResponseEntity<?> getActivityAlarmList(Integer page, UserPrincipal userPr
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"));
Page<Alarm> alarmPage = alarmRepository.findByUserIdAndAlarmTypeIn(pageRequest, findUser.getId(), types);
Slice<Alarm> alarmPage = alarmRepository.findSliceByUserIdAndAlarmTypeIn(pageRequest, findUser.getId(), types);
List<Alarm> alarmList = alarmPage.getContent();

DefaultAssert.isTrue(!alarmList.isEmpty(), "활동 알림이 존재하지 않습니다.");
Expand Down Expand Up @@ -94,7 +95,10 @@ public ResponseEntity<?> getActivityAlarmList(Integer page, UserPrincipal userPr
alarmResList.add(alarmRes);
}

ApiResponse apiResponse = ApiResponse.toApiResponse(alarmResList);
boolean hasNextPage = alarmPage.hasNext();
AlarmResponseDto.AlarmResListWithPaging alarmResListWithPaging = AlarmConverter.toAlarmResListWithPaging(hasNextPage, alarmResList);

ApiResponse apiResponse = ApiResponse.toApiResponse(alarmResListWithPaging);
return ResponseEntity.ok(apiResponse);
}

Expand All @@ -103,8 +107,8 @@ public ResponseEntity<?> getExhibitionAlarmList(Integer page, UserPrincipal user
User findUser = userService.validateUserByToken(userPrincipal);
List<AlarmType> types = List.of(AlarmType.EXHIBITION);

PageRequest pageRequest = PageRequest.of(page, 20, Sort.by(Sort.Direction.DESC, "modifiedDate"));
Page<Alarm> alarmPage = alarmRepository.findByUserIdAndAlarmTypeIn(pageRequest, findUser.getId(), types);
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();

DefaultAssert.isTrue(!alarmList.isEmpty(), "전시 알림이 존재하지 않습니다.");
Expand All @@ -126,7 +130,10 @@ public ResponseEntity<?> getExhibitionAlarmList(Integer page, UserPrincipal user
alarmResList.add(alarmRes);
}

ApiResponse apiResponse = ApiResponse.toApiResponse(alarmResList);
boolean hasNextPage = alarmPage.hasNext();
AlarmResponseDto.AlarmResListWithPaging alarmResListWithPaging = AlarmConverter.toAlarmResListWithPaging(hasNextPage, alarmResList);

ApiResponse apiResponse = ApiResponse.toApiResponse(alarmResListWithPaging);
return ResponseEntity.ok(apiResponse);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import depth.jeonsilog.domain.alarm.domain.Alarm;
import depth.jeonsilog.domain.alarm.domain.AlarmType;
import depth.jeonsilog.domain.alarm.dto.AlarmResponseDto;
import depth.jeonsilog.domain.interest.domain.Interest;
import depth.jeonsilog.domain.reply.dto.ReplyResponseDto;

import java.util.List;

public class AlarmConverter {

Expand All @@ -16,4 +20,11 @@ public static Alarm toExhibitionAlarm(Interest interest, String contents) {
.isChecked(false)
.build();
}

public static AlarmResponseDto.AlarmResListWithPaging toAlarmResListWithPaging(boolean hasNextPage, List<AlarmResponseDto.AlarmRes> alarmResList) {
return AlarmResponseDto.AlarmResListWithPaging.builder()
.hasNextPage(hasNextPage)
.data(alarmResList)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import depth.jeonsilog.domain.interest.domain.Interest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Slice;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

Expand All @@ -16,4 +17,6 @@ public interface AlarmRepository extends JpaRepository<Alarm, Long> {
Boolean existsByUserIdAndTargetIdAndContents(Long userId, Long targetId, String contents);

Page<Alarm> findByUserIdAndAlarmTypeIn(PageRequest pageRequest, Long userId, List<AlarmType> types);

Slice<Alarm> findSliceByUserIdAndAlarmTypeIn(PageRequest pageRequest, Long userId, List<AlarmType> types);
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package depth.jeonsilog.domain.alarm.dto;

import depth.jeonsilog.domain.alarm.domain.AlarmType;
import depth.jeonsilog.domain.reply.dto.ReplyResponseDto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

public class AlarmResponseDto {

Expand Down Expand Up @@ -37,4 +39,14 @@ public static class AlarmRes {
@Schema(type = "boolean", example = "true", description = "알림을 확인했는지 출력합니다.")
private Boolean isChecked;
}

@Data
@Builder
public static class AlarmResListWithPaging {

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

private List<AlarmResponseDto.AlarmRes> data;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class AlarmController {

@Operation(summary = "활동 알림 목록 조회", description = "활동 알림 목록을 조회합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "조회 성공", content = {@Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = AlarmResponseDto.AlarmRes.class)))}),
@ApiResponse(responseCode = "200", description = "조회 성공", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = AlarmResponseDto.AlarmResListWithPaging.class))}),
@ApiResponse(responseCode = "400", description = "조회 실패", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class))}),
})
@GetMapping("/activity")
Expand All @@ -42,7 +42,7 @@ public ResponseEntity<?> getActivityAlarmList(

@Operation(summary = "전시 알림 목록 조회", description = "전시 알림 목록을 조회합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "조회 성공", content = {@Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = AlarmResponseDto.AlarmRes.class)))}),
@ApiResponse(responseCode = "200", description = "조회 성공", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = AlarmResponseDto.AlarmResListWithPaging.class))}),
@ApiResponse(responseCode = "400", description = "조회 실패", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class))}),
})
@GetMapping("/exhibition")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public ResponseEntity<?> findExhibitionList(Integer page) {
Sort.Order.asc("createdDate")
));

Page<Exhibition> exhibitionPage = exhibitionRepository.findAll(pageRequest);

Slice<Exhibition> exhibitionPage = exhibitionRepository.findSliceBy(pageRequest);
List<Exhibition> exhibitions = exhibitionPage.getContent();

List<Place> places = new ArrayList<>();
Expand All @@ -71,8 +70,10 @@ public ResponseEntity<?> findExhibitionList(Integer page) {
List<PlaceResponseDto.PlaceInfoRes> placeInfoResList = PlaceConverter.toPlaceInfoListRes(places);

List<ExhibitionResponseDto.ExhibitionRes> exhibitionResList = ExhibitionConverter.toExhibitionListRes(exhibitions, placeInfoResList);
boolean hasNextPage = exhibitionPage.hasNext();
ExhibitionResponseDto.ExhibitionResListWithPaging exhibitionResListWithPaging = ExhibitionConverter.toExhibitionResListWithPaging(hasNextPage, exhibitionResList);

ApiResponse apiResponse = ApiResponse.toApiResponse(exhibitionResList);
ApiResponse apiResponse = ApiResponse.toApiResponse(exhibitionResListWithPaging);

return ResponseEntity.ok(apiResponse);
}
Expand Down Expand Up @@ -138,8 +139,7 @@ public ResponseEntity<?> searchExhibitions(Integer page, String searchWord) {

PageRequest pageRequest = PageRequest.of(page, 10, Sort.by(Sort.Direction.ASC, "createdDate"));

Page<Exhibition> exhibitionPage = exhibitionRepository.findByNameContainingOrPlace_AddressContaining(pageRequest, searchWord, searchWord);

Slice<Exhibition> exhibitionPage = exhibitionRepository.findSliceByNameContainingOrPlace_AddressContaining(pageRequest, searchWord, searchWord);
List<Exhibition> exhibitions = exhibitionPage.getContent();

DefaultAssert.isTrue(!exhibitions.isEmpty(), "해당 검색어를 포함한 전시회가 존재하지 않습니다.");
Expand All @@ -154,8 +154,10 @@ public ResponseEntity<?> searchExhibitions(Integer page, String searchWord) {
List<PlaceResponseDto.PlaceInfoRes> placeInfoResList = PlaceConverter.toPlaceInfoListRes(places);

List<ExhibitionResponseDto.ExhibitionRes> exhibitionResList = ExhibitionConverter.toExhibitionListRes(exhibitions, placeInfoResList);
boolean hasNextPage = exhibitionPage.hasNext();
ExhibitionResponseDto.ExhibitionResListWithPaging exhibitionResListWithPaging = ExhibitionConverter.toExhibitionResListWithPaging(hasNextPage, exhibitionResList);

ApiResponse apiResponse = ApiResponse.toApiResponse(exhibitionResList);
ApiResponse apiResponse = ApiResponse.toApiResponse(exhibitionResListWithPaging);

return ResponseEntity.ok(apiResponse);
}
Expand All @@ -164,14 +166,16 @@ public ResponseEntity<?> searchExhibitions(Integer page, String searchWord) {
public ResponseEntity<?> searchExhibitionsByName(Integer page, String exhibitionName) {

PageRequest pageRequest = PageRequest.of(page, 10);
Page<Exhibition> exhibitionPage = exhibitionRepository.findByNameContaining(pageRequest, exhibitionName);
Slice<Exhibition> exhibitionPage = exhibitionRepository.findSliceByNameContaining(pageRequest, exhibitionName);

List<Exhibition> exhibitions = exhibitionPage.getContent();
DefaultAssert.isTrue(!exhibitions.isEmpty(), "해당 검색어를 포함한 전시회가 존재하지 않습니다.");

List<ExhibitionResponseDto.SearchExhibitionByNameRes> exhibitionResList = ExhibitionConverter.toSearchByNameRes(exhibitions);
boolean hasNextPage = exhibitionPage.hasNext();
ExhibitionResponseDto.SearchExhibitionByNameResListWithPaging searchExhibitionByNameResListWithPaging = ExhibitionConverter.toSearchExhibitionByNameResListWithPaging(hasNextPage, exhibitionResList);

ApiResponse apiResponse = ApiResponse.toApiResponse(exhibitionResList);
ApiResponse apiResponse = ApiResponse.toApiResponse(searchExhibitionByNameResListWithPaging);
return ResponseEntity.ok(apiResponse);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import depth.jeonsilog.domain.exhibition.domain.Exhibition;
import depth.jeonsilog.domain.exhibition.dto.ExhibitionResponseDto;
import depth.jeonsilog.domain.place.dto.PlaceResponseDto;
import depth.jeonsilog.domain.reply.dto.ReplyResponseDto;
import depth.jeonsilog.global.DefaultAssert;

import java.util.ArrayList;
Expand Down Expand Up @@ -35,6 +36,13 @@ public static List<ExhibitionResponseDto.ExhibitionRes> toExhibitionListRes(List
return exhibitionResList;
}

public static ExhibitionResponseDto.ExhibitionResListWithPaging toExhibitionResListWithPaging(boolean hasNextPage, List<ExhibitionResponseDto.ExhibitionRes> exhibitionResList) {
return ExhibitionResponseDto.ExhibitionResListWithPaging.builder()
.hasNextPage(hasNextPage)
.data(exhibitionResList)
.build();
}

// EXHIBITION & PlaceRes -> ExhibitionDetailRes
public static ExhibitionResponseDto.ExhibitionDetailRes toExhibitionDetailRes(Exhibition exhibition, PlaceResponseDto.PlaceRes placeRes, Boolean checkInterest, Double myRate) {
return ExhibitionResponseDto.ExhibitionDetailRes.builder()
Expand Down Expand Up @@ -92,6 +100,13 @@ public static List<ExhibitionResponseDto.ExhibitionInPlaceRes> toExhibitionListI
return exhibitionInPlaceResList;
}

public static ExhibitionResponseDto.ExhibitionInPlaceResWithPaging toExhibitionInPlaceResWithPaging(boolean hasNextPage, List<ExhibitionResponseDto.ExhibitionInPlaceRes> exhibitionInPlaceResList) {
return ExhibitionResponseDto.ExhibitionInPlaceResWithPaging.builder()
.hasNextPage(hasNextPage)
.data(exhibitionInPlaceResList)
.build();
}

public static List<ExhibitionResponseDto.SearchExhibitionByNameRes> toSearchByNameRes(List<Exhibition> exhibitions) {

List<ExhibitionResponseDto.SearchExhibitionByNameRes> exhibitionByNameResList = new ArrayList<>();
Expand All @@ -107,4 +122,11 @@ public static List<ExhibitionResponseDto.SearchExhibitionByNameRes> toSearchByNa
}
return exhibitionByNameResList;
}

public static ExhibitionResponseDto.SearchExhibitionByNameResListWithPaging toSearchExhibitionByNameResListWithPaging(boolean hasNextPage, List<ExhibitionResponseDto.SearchExhibitionByNameRes> searchExhibitionByNameRes) {
return ExhibitionResponseDto.SearchExhibitionByNameResListWithPaging.builder()
.hasNextPage(hasNextPage)
.data(searchExhibitionByNameRes)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import depth.jeonsilog.domain.place.domain.Place;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
Expand All @@ -14,14 +15,18 @@
public interface ExhibitionRepository extends JpaRepository<Exhibition, Long> {

@EntityGraph(attributePaths = {"place"})
Page<Exhibition> findAll(Pageable pageable);
Slice<Exhibition> findSliceBy(Pageable pageable);

Page<Exhibition> findByNameContaining(Pageable pageable, String searchWord);

Page<Exhibition> findByNameContainingOrPlace_AddressContaining(Pageable pageable, String searchWord, String searchWord2);
Slice<Exhibition> findSliceByNameContaining(Pageable pageable, String searchWord);

Slice<Exhibition> findSliceByNameContainingOrPlace_AddressContaining(Pageable pageable, String searchWord, String searchWord2);

Page<Exhibition> findByPlace(Pageable pageable, Place place);

Slice<Exhibition> findSliceByPlace(Pageable pageable, Place place);

Optional<Exhibition> findBySequence(Integer sequence);

Optional<Exhibition> findByExhibitionSeq(Integer exhibitionSeq);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import depth.jeonsilog.domain.exhibition.domain.OperatingKeyword;
import depth.jeonsilog.domain.exhibition.domain.PriceKeyword;
import depth.jeonsilog.domain.place.dto.PlaceResponseDto;
import depth.jeonsilog.domain.reply.dto.ReplyResponseDto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Data;

import java.util.List;

public class ExhibitionResponseDto {

// 전시회 목록 조회 + 검색어를 포함한 전시회 목록 조회
Expand All @@ -32,6 +35,16 @@ public static class ExhibitionRes {
private PlaceResponseDto.PlaceInfoRes place;
}

@Data
@Builder
public static class ExhibitionResListWithPaging {

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

private List<ExhibitionResponseDto.ExhibitionRes> data;
}

// 전시회 상세 정보 조회
@Data
@Builder
Expand Down Expand Up @@ -128,6 +141,16 @@ public static class ExhibitionInPlaceRes {
private String endDate;
}

@Data
@Builder
public static class ExhibitionInPlaceResWithPaging {

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

private List<ExhibitionResponseDto.ExhibitionInPlaceRes> data;
}

@Data
@Builder
public static class SearchExhibitionByNameRes {
Expand All @@ -141,4 +164,14 @@ public static class SearchExhibitionByNameRes {
@Schema(type = "String", example = "http://www.culture.go.kr/upload/rdf/23/11/rdf_2023112721202875517.jpg", description = "전시회 이미지 포스터를 출력합니다.")
private String imageUrl;
}

@Data
@Builder
public static class SearchExhibitionByNameResListWithPaging {

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

private List<ExhibitionResponseDto.SearchExhibitionByNameRes> data;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ExhibitionController {
// Description : 전시회 목록 조회
@Operation(summary = "전시회 목록 조회", description = "전시회 목록을 조회합니다. 관리자가 미리 설정해 둔 10개의 전시회와 그 뒤로 저장 순서대로 전시회 목록을 조회합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "조회 성공", content = {@Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = ExhibitionResponseDto.ExhibitionRes.class)))}),
@ApiResponse(responseCode = "200", description = "조회 성공", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ExhibitionResponseDto.ExhibitionResListWithPaging.class))}),
@ApiResponse(responseCode = "400", description = "조회 실패", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class))}),
})
@GetMapping
Expand Down Expand Up @@ -72,7 +72,7 @@ public ResponseEntity<?> randomTwoExhibitions() {
// TODO : 논의 후 페이징 처리 필요
@Operation(summary = "검색어를 포함한 전시회 목록 조회", description = "검색어를 포함한 전시회 목록을 조회합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "조회 성공", content = {@Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = ExhibitionResponseDto.ExhibitionRes.class)))}),
@ApiResponse(responseCode = "200", description = "조회 성공", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ExhibitionResponseDto.ExhibitionResListWithPaging.class))}),
@ApiResponse(responseCode = "400", description = "조회 실패", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class))}),
})
@GetMapping("/search/{searchWord}")
Expand Down Expand Up @@ -113,7 +113,7 @@ public ResponseEntity<?> findPoster(

@Operation(summary = "전시회 이름으로 전시회 조회", description = "전시회 이름만으로 전시회를 조회합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "조회 성공", content = {@Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = ExhibitionResponseDto.SearchExhibitionByNameRes.class)))}),
@ApiResponse(responseCode = "200", description = "조회 성공", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ExhibitionResponseDto.SearchExhibitionByNameResListWithPaging.class))}),
@ApiResponse(responseCode = "400", description = "조회 실패", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class))}),
})
@GetMapping("/search/name/{searchWord}")
Expand Down
Loading

0 comments on commit 39477ef

Please sign in to comment.