diff --git a/src/main/java/org/withtime/be/withtimebe/domain/date/controller/query/DateQueryController.java b/src/main/java/org/withtime/be/withtimebe/domain/date/controller/query/DateQueryController.java index b3d4e62..2af48e6 100644 --- a/src/main/java/org/withtime/be/withtimebe/domain/date/controller/query/DateQueryController.java +++ b/src/main/java/org/withtime/be/withtimebe/domain/date/controller/query/DateQueryController.java @@ -1,6 +1,13 @@ package org.withtime.be.withtimebe.domain.date.controller.query; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.enums.Explode; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.enums.ParameterStyle; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; @@ -15,6 +22,7 @@ import org.withtime.be.withtimebe.domain.date.dto.request.DateRequestDTO; import org.withtime.be.withtimebe.domain.date.dto.response.DateResponseDTO; import org.withtime.be.withtimebe.domain.date.entity.DateCourse; +import org.withtime.be.withtimebe.domain.date.entity.enums.*; import org.withtime.be.withtimebe.domain.date.service.query.DateQueryService; import org.withtime.be.withtimebe.domain.member.entity.Member; import org.withtime.be.withtimebe.global.annotation.SwaggerPageable; @@ -33,11 +41,29 @@ public class DateQueryController { @ApiResponse(responseCode = "200", description = "성공입니다."), @ApiResponse(responseCode = "404", description = "DATE_COURSE404_1 : 해당하는 데이트 코스를 찾을 수 없습니다.") }) + @Parameters({ + @Parameter(name = "datePriceRange", in = ParameterIn.QUERY, + schema = @Schema(implementation = DatePriceRange.class)), + @Parameter(name = "datePlaces", in = ParameterIn.QUERY, + description = "만날 장소", required = false, + style = ParameterStyle.FORM, explode = Explode.TRUE, + array = @ArraySchema(schema = @Schema(type = "string"))), + @Parameter(name = "dateDurationTime", in = ParameterIn.QUERY, + schema = @Schema(implementation = DateTime.class)), + @Parameter(name = "mealTypes", in = ParameterIn.QUERY, description = "식사 타입", + style = ParameterStyle.FORM, explode = Explode.TRUE, + array = @ArraySchema(schema = @Schema(type = "string",allowableValues = { "BREAKFAST", "LUNCH", "DINNER" }))), + @Parameter(name = "transportation", in = ParameterIn.QUERY, + schema = @Schema(implementation = Transportation.class)), + @Parameter(name = "userPreferredKeywords", in = ParameterIn.QUERY, description = "키워드", + style = ParameterStyle.FORM, explode = Explode.TRUE, + array = @ArraySchema(schema = @Schema(type = "string"))) + }) @SwaggerPageable @GetMapping public DefaultResponse findDateCourses( @PageableDefault(page = 0, size = 10) Pageable pageable, - @ParameterObject DateRequestDTO.DateCourseSearchCond dateCourseSearchCond, + @ModelAttribute @ParameterObject DateRequestDTO.DateCourseSearchCond dateCourseSearchCond, @AuthenticatedMember Member member ) { DateResponseDTO.DateCourseList response = dateQueryService.findDateCourses(dateCourseSearchCond, pageable, member); @@ -50,11 +76,29 @@ public DefaultResponse findDateCourses( @ApiResponse(responseCode = "DATE_COURSE_BOOKMARK404_1", description = "해당 코스를 찾을 수 없습니다") }) + @Parameters({ + @Parameter(name = "datePriceRange", in = ParameterIn.QUERY, + schema = @Schema(implementation = DatePriceRange.class)), + @Parameter(name = "datePlaces", in = ParameterIn.QUERY, + description = "만날 장소", required = false, + style = ParameterStyle.FORM, explode = Explode.TRUE, + array = @ArraySchema(schema = @Schema(type = "string"))), + @Parameter(name = "dateDurationTime", in = ParameterIn.QUERY, + schema = @Schema(implementation = DateTime.class)), + @Parameter(name = "mealTypes", in = ParameterIn.QUERY, description = "식사 타입", + style = ParameterStyle.FORM, explode = Explode.TRUE, + array = @ArraySchema(schema = @Schema(implementation = MealType.class))), + @Parameter(name = "transportation", in = ParameterIn.QUERY, + schema = @Schema(implementation = Transportation.class)), + @Parameter(name = "userPreferredKeywords", in = ParameterIn.QUERY, description = "키워드", + style = ParameterStyle.FORM, explode = Explode.TRUE, + array = @ArraySchema(schema = @Schema(type = "string"))) + }) @SwaggerPageable - @PostMapping("/bookmarks/search") + @GetMapping("/bookmarks/search") public DefaultResponse findDateCourseBookmark( @PageableDefault(page = 0, size = 10) Pageable pageable, - @ModelAttribute DateRequestDTO.DateCourseSearchCond dateCourseSearchCond, + @ModelAttribute @ParameterObject DateRequestDTO.DateCourseSearchCond dateCourseSearchCond, @AuthenticatedMember Member member ){ Page bookmarkedDateCourses = dateQueryService.findDateCourseBookmarks(dateCourseSearchCond, pageable, member); diff --git a/src/main/java/org/withtime/be/withtimebe/domain/date/converter/DateConverter.java b/src/main/java/org/withtime/be/withtimebe/domain/date/converter/DateConverter.java index 13a9a19..6b8d579 100644 --- a/src/main/java/org/withtime/be/withtimebe/domain/date/converter/DateConverter.java +++ b/src/main/java/org/withtime/be/withtimebe/domain/date/converter/DateConverter.java @@ -7,7 +7,6 @@ import org.withtime.be.withtimebe.domain.date.entity.*; import org.withtime.be.withtimebe.domain.member.entity.Member; -import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.util.Collections; @@ -132,6 +131,7 @@ public static DateResponseDTO.DateCourse createDateCourse(DateCourse dateCourse, .toList(); return DateResponseDTO.DateCourse.builder() + .dateCourseId(dateCourse.getId()) .name(dateCourse.getName()) .datePlaces(datePlaces) .isBookmarked(bookmarked) @@ -141,7 +141,7 @@ public static DateResponseDTO.DateCourse createDateCourse(DateCourse dateCourse, public static DateResponseDTO.DateCourseSearchCondInfo createSearchCond(DateRequestDTO.DateCourseSearchCond cond){ return DateResponseDTO.DateCourseSearchCondInfo.builder() - .budget(cond.budget()) + .budget(cond.datePriceRange()) .datePlaces(cond.datePlaces()) .mealTypes(cond.mealTypes()) .transportation(cond.transportation()) diff --git a/src/main/java/org/withtime/be/withtimebe/domain/date/dto/request/DateRequestDTO.java b/src/main/java/org/withtime/be/withtimebe/domain/date/dto/request/DateRequestDTO.java index 94d2e2a..40deadc 100644 --- a/src/main/java/org/withtime/be/withtimebe/domain/date/dto/request/DateRequestDTO.java +++ b/src/main/java/org/withtime/be/withtimebe/domain/date/dto/request/DateRequestDTO.java @@ -1,6 +1,5 @@ package org.withtime.be.withtimebe.domain.date.dto.request; -import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; @@ -65,11 +64,13 @@ public record SaveDateCourse( ){} public record DateCourseSearchCond( - DatePriceRange budget, + DatePriceRange datePriceRange, List datePlaces, DateTime dateDurationTime, + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) List mealTypes, Transportation transportation, + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) List userPreferredKeywords ){} } diff --git a/src/main/java/org/withtime/be/withtimebe/domain/date/dto/response/DateResponseDTO.java b/src/main/java/org/withtime/be/withtimebe/domain/date/dto/response/DateResponseDTO.java index 0a62a0e..67557a9 100644 --- a/src/main/java/org/withtime/be/withtimebe/domain/date/dto/response/DateResponseDTO.java +++ b/src/main/java/org/withtime/be/withtimebe/domain/date/dto/response/DateResponseDTO.java @@ -35,6 +35,7 @@ public record DatePlace( @Builder public record DateCourse( + Long dateCourseId, String name, List datePlaces, DateCourseSearchCondInfo dateCourseSearchCondInfo, diff --git a/src/main/java/org/withtime/be/withtimebe/domain/date/repository/DateCourseRepositoryImpl.java b/src/main/java/org/withtime/be/withtimebe/domain/date/repository/DateCourseRepositoryImpl.java index 3bbbcb0..ceca04f 100644 --- a/src/main/java/org/withtime/be/withtimebe/domain/date/repository/DateCourseRepositoryImpl.java +++ b/src/main/java/org/withtime/be/withtimebe/domain/date/repository/DateCourseRepositoryImpl.java @@ -19,7 +19,6 @@ import java.util.Collection; import java.util.List; -import static org.springframework.util.ObjectUtils.isEmpty; import static org.withtime.be.withtimebe.domain.date.entity.QDateCourse.dateCourse; @@ -37,7 +36,7 @@ public Page searchDateCourseByApplyPage(DateRequestDTO.DateCourseSea boolean hasKeywords = dateCourseSearchCond.userPreferredKeywords() != null && !dateCourseSearchCond.userPreferredKeywords().isEmpty(); List content = queryFactory.selectFrom(dateCourse) - .where(datePriceRangeEq(dateCourseSearchCond.budget()), + .where(datePriceRangeEq(dateCourseSearchCond.datePriceRange()), datePlacesEq(dateCourseSearchCond.datePlaces()), dateTimeEq(dateCourseSearchCond.dateDurationTime()), mealTypesEq(dateCourseSearchCond.mealTypes()), @@ -51,7 +50,7 @@ public Page searchDateCourseByApplyPage(DateRequestDTO.DateCourseSea Long total = queryFactory.select(dateCourse.id.countDistinct()) .from(dateCourse) - .where(datePriceRangeEq(dateCourseSearchCond.budget()), + .where(datePriceRangeEq(dateCourseSearchCond.datePriceRange()), datePlacesEq(dateCourseSearchCond.datePlaces()), dateTimeEq(dateCourseSearchCond.dateDurationTime()), mealTypesEq(dateCourseSearchCond.mealTypes()), @@ -75,7 +74,7 @@ public Page searchDateCourseBookmarkByMemberAndApplyPage(DateReques List content = queryFactory.selectFrom(dateCourse) .join(dateCourseBookmark).on(dateCourseBookmark.dateCourse.eq(dateCourse)) .where(dateCourseBookmark.member.id.eq(member.getId()), - datePriceRangeEq(dateCourseSearchCond.budget()), + datePriceRangeEq(dateCourseSearchCond.datePriceRange()), datePlacesEq(dateCourseSearchCond.datePlaces()), dateTimeEq(dateCourseSearchCond.dateDurationTime()), mealTypesEq(dateCourseSearchCond.mealTypes()), @@ -91,7 +90,7 @@ public Page searchDateCourseBookmarkByMemberAndApplyPage(DateReques .from(dateCourse) .join(dateCourseBookmark).on(dateCourseBookmark.dateCourse.eq(dateCourse)) .where(dateCourseBookmark.member.id.eq(member.getId()), - datePriceRangeEq(dateCourseSearchCond.budget()), + datePriceRangeEq(dateCourseSearchCond.datePriceRange()), datePlacesEq(dateCourseSearchCond.datePlaces()), dateTimeEq(dateCourseSearchCond.dateDurationTime()), mealTypesEq(dateCourseSearchCond.mealTypes()), @@ -124,19 +123,19 @@ private BooleanExpression datePriceRangeEq(DatePriceRange datePriceRange){ } private BooleanExpression datePlacesEq(List datePlaces){ - return datePlaces.isEmpty() ? null : dateCourse.datePlaces.any().in(datePlaces); + return datePlaces == null ? null : dateCourse.datePlaces.any().in(datePlaces); } private BooleanExpression dateTimeEq(DateTime dateTime){ - return isEmpty(dateTime) ? null : dateCourse.dateTime.eq(dateTime); + return dateTime == null ? null : dateCourse.dateTime.eq(dateTime); } private BooleanExpression mealTypesEq(List mealTypes){ - return mealTypes.isEmpty() ? null : dateCourse.mealTypes.any().in(mealTypes); + return mealTypes== null ? null : dateCourse.mealTypes.any().in(mealTypes); } private BooleanExpression transportationEq(Transportation transportation){ - return isEmpty(transportation) ? null : dateCourse.transportation.eq(transportation); + return transportation == null ? null : dateCourse.transportation.eq(transportation); } private BooleanExpression allEq(DatePriceRange datePriceRange, List datePlaces, diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 6417d78..f22e129 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -149,4 +149,4 @@ scheduler: sync-cron: "0 */5 * * * *" # 5분마다 Redis -> Mongo 동기화 date-place: enabled: true - sync-cron: "0 0 0 * * *" # 매일 자정마다 동기화 \ No newline at end of file + sync-cron: "0 0 0 * * *" # 매일 자정마다 동기화