Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
79 changes: 79 additions & 0 deletions src/docs/asciidoc/product.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@
== 키워드 검색

=== HTTP query parameters
include::{snippets}/products-search/query-parameters.adoc[]

=== HTTP request
include::{snippets}/products-search/http-request.adoc[]

=== HTTP response fields
include::{snippets}/products-search/response-fields.adoc[]

=== HTTP response
include::{snippets}/products-search/http-response.adoc[]

== 예약 목록 조회

=== HTTP path parameters
include::{snippets}/reservations-all/path-parameters.adoc[]

=== HTTP request
include::{snippets}/reservations-all/http-request.adoc[]

=== HTTP response fields
include::{snippets}/reservations-all/response-fields.adoc[]

=== HTTP response
include::{snippets}/reservations-all/http-response.adoc[]

== 상품 등록

=== HTTP request fields
include::{snippets}/product-create/request-fields.adoc[]

=== HTTP request
include::{snippets}/product-create/http-request.adoc[]

=== HTTP response fields
include::{snippets}/product-create/response-fields.adoc[]

=== HTTP response
include::{snippets}/product-create/http-response.adoc[]

== 상품 상세 조회

=== HTTP path parameters
include::{snippets}/products-details/path-parameters.adoc[]

=== HTTP request
include::{snippets}/products-details/http-request.adoc[]

Expand All @@ -11,6 +56,9 @@ include::{snippets}/products-details/http-response.adoc[]

== 상품 수정

=== HTTP path parameters
include::{snippets}/products-update/path-parameters.adoc[]

=== HTTP request fields
include::{snippets}/products-update/request-fields.adoc[]

Expand All @@ -25,6 +73,9 @@ include::{snippets}/products-update/http-response.adoc[]

== 상품 삭제

=== HTTP path parameters
include::{snippets}/products-delete/path-parameters.adoc[]

=== HTTP request
include::{snippets}/products-delete/http-request.adoc[]

Expand All @@ -45,6 +96,17 @@ include::{snippets}/products/history/progress-all/response-fields.adoc[]
=== HTTP response
include::{snippets}/products/history/progress-all/http-response.adoc[]

== 판매내역 - 판매중 전체 조회

=== HTTP request
include::{snippets}/products/history/progress-all/http-request.adoc[]

=== HTTP response fields
include::{snippets}/products/history/progress-all/response-fields.adoc[]

=== HTTP response
include::{snippets}/products/history/progress-all/http-response.adoc[]

== 판매내역 - 판매완료 전체 조회

=== HTTP request
Expand All @@ -56,9 +118,26 @@ include::{snippets}/products/history/completed-all/response-fields.adoc[]
=== HTTP response
include::{snippets}/products/history/completed-all/http-response.adoc[]

== 판매내역 - 판매완료 상세 조회

=== HTTP query parameters
include::{snippets}/products/history/completed-details/query-parameters.adoc[]

=== HTTP request
include::{snippets}/products/history/completed-details/http-request.adoc[]

=== HTTP response fields
include::{snippets}/products/history/completed-details/response-fields.adoc[]

=== HTTP response
include::{snippets}/products/history/completed-details/http-response.adoc[]


== 판매내역 - 판매완료 삭제

=== HTTP path parameters
include::{snippets}/products/history/completed-delete/path-parameters.adoc[]

=== HTTP request
include::{snippets}/products/history/completed-delete/http-request.adoc[]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class SecurityConfiguration {
private static final String[] PERMIT_ALL_URLS = new String[]{
"/h2-console/**",
"/dummy/**",
"/test/**",
"/payments/**",
"/home",
"/chats/test/**"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.ResponseEntity;
Expand All @@ -19,6 +18,7 @@
import site.goldenticket.domain.product.constants.PriceRange;
import site.goldenticket.domain.product.constants.ProductStatus;
import site.goldenticket.domain.product.dto.*;
import site.goldenticket.domain.product.repository.CustomSlice;
import site.goldenticket.domain.product.search.service.SearchService;
import site.goldenticket.domain.product.service.ProductOrderService;
import site.goldenticket.domain.product.service.ProductService;
Expand All @@ -41,7 +41,7 @@ public class ProductController {
private final ProductOrderService productOrderService;

@GetMapping
public CompletableFuture<ResponseEntity<CommonResponse<Slice<SearchProductResponse>>>> getProductsBySearch(
public CompletableFuture<ResponseEntity<CommonResponse<CustomSlice<SearchProductResponse>>>> getProductsBySearch(
@RequestParam AreaCode areaCode,
@RequestParam String keyword,
@RequestParam LocalDate checkInDate,
Expand All @@ -57,7 +57,7 @@ public CompletableFuture<ResponseEntity<CommonResponse<Slice<SearchProductRespon
) Pageable pageable,
@AuthenticationPrincipal PrincipalDetails principalDetails
) {
CompletableFuture<Slice<SearchProductResponse>> searchProductFuture = CompletableFuture.supplyAsync(() ->
CompletableFuture<CustomSlice<SearchProductResponse>> searchProductFuture = CompletableFuture.supplyAsync(() ->
productService.getProductsBySearch(areaCode, keyword, checkInDate, checkOutDate, priceRange, cursorCheckInDate, cursorId, pageable, principalDetails)
);

Expand All @@ -74,7 +74,7 @@ public CompletableFuture<ResponseEntity<CommonResponse<Slice<SearchProductRespon
}

@GetMapping("/region")
public CompletableFuture<ResponseEntity<CommonResponse<Slice<RegionProductResponse>>>> getProductsByAreaCode(
public CompletableFuture<ResponseEntity<CommonResponse<CustomSlice<RegionProductResponse>>>> getProductsByAreaCode(
@RequestParam AreaCode areaCode,
@RequestParam(required = false) LocalDate cursorCheckInDate,
@RequestParam(required = false) Long cursorId,
Expand All @@ -86,7 +86,7 @@ public CompletableFuture<ResponseEntity<CommonResponse<Slice<RegionProductRespon
) Pageable pageable,
@AuthenticationPrincipal PrincipalDetails principalDetails
) {
CompletableFuture<Slice<RegionProductResponse>> regionProductFuture = CompletableFuture.supplyAsync(() ->
CompletableFuture<CustomSlice<RegionProductResponse>> regionProductFuture = CompletableFuture.supplyAsync(() ->
productService.getProductsByAreaCode(areaCode, cursorCheckInDate, cursorId, pageable, principalDetails)
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package site.goldenticket.domain.product.dto;

import org.springframework.data.domain.Slice;
import site.goldenticket.domain.product.model.Product;
import site.goldenticket.domain.product.repository.CustomSlice;

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

public record RegionProductResponse(
long totalCount,
List<WishedProductResponse> wishedProductResponseList
) {
public static RegionProductResponse fromEntity(long totalCount, Slice<Product> productSlice, boolean isAuthenticated) {
public static RegionProductResponse fromEntity(CustomSlice<Product> productSlice, boolean isAuthenticated) {

List<WishedProductResponse> wishedProductResponseList = productSlice.getContent().stream()
.map(
Expand All @@ -19,7 +18,6 @@ public static RegionProductResponse fromEntity(long totalCount, Slice<Product> p
.collect(Collectors.toList());

return new RegionProductResponse(
totalCount,
wishedProductResponseList
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package site.goldenticket.domain.product.dto;

import org.springframework.data.domain.Slice;
import site.goldenticket.domain.product.constants.AreaCode;
import site.goldenticket.domain.product.constants.PriceRange;
import site.goldenticket.domain.product.model.Product;
import site.goldenticket.domain.product.repository.CustomSlice;

import java.time.LocalDate;
import java.util.List;
Expand All @@ -15,13 +15,12 @@ public record SearchProductResponse(
LocalDate checkInDate,
LocalDate checkOutDate,
String priceRange,
long totalCount,
List<WishedProductResponse> wishedProductResponseList
) {

public static SearchProductResponse fromEntity(
AreaCode areaCode, String keyword, LocalDate checkInDate, LocalDate checkOutDate,
PriceRange priceRange, long totalCount, Slice<Product> productSlice, boolean isAuthenticated) {
PriceRange priceRange, CustomSlice<Product> productSlice, boolean isAuthenticated) {

List<WishedProductResponse> wishedProductResponseList = productSlice.getContent().stream()
.map(
Expand All @@ -35,7 +34,6 @@ public static SearchProductResponse fromEntity(
checkInDate,
checkOutDate,
priceRange.getLabel(),
totalCount,
wishedProductResponseList
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,97 +1,35 @@
package site.goldenticket.domain.product.repository;

import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Sort;

import java.util.Iterator;
import java.util.List;
import java.util.function.Function;

public class CustomSlice<T> implements Slice<T> {
public class CustomSlice<T> {

private final List<T> content;
private final Pageable pageable;
private final boolean hasNext;
private final long totalCount;

public CustomSlice(List<T> content, Pageable pageable, boolean hasNext, long totalCount) {
public CustomSlice(List<T> content, boolean hasNext, long totalCount) {
this.content = content;
this.pageable = pageable;
this.hasNext = hasNext;
this.totalCount = totalCount;
}

@Override
public int getNumber() {
return pageable.getPageNumber();
}

@Override
public int getSize() {
return pageable.getPageSize();
}

@Override
public int getNumberOfElements() {
return content.size();
}

@Override
public List<T> getContent() {
return content;
}

@Override
public boolean hasContent() {
return !content.isEmpty();
}

@Override
public Sort getSort() {
return pageable.getSort();
}

@Override
public boolean isFirst() {
return !hasPrevious();
}

@Override
public boolean isLast() {
return !hasNext;
}

@Override
public boolean hasNext() {
return hasNext;
}

@Override
public boolean hasPrevious() {
return pageable.getPageNumber() > 0;
}

@Override
public Pageable nextPageable() {
return hasNext() ? pageable.next() : Pageable.unpaged();
}

@Override
public Pageable previousPageable() {
return hasPrevious() ? pageable.previousOrFirst() : Pageable.unpaged();
}

@Override
public <U> Slice<U> map(Function<? super T, ? extends U> converter) {
return null;
}

@Override
public Iterator<T> iterator() {
return content.iterator();
}

public long getTotalElements() {
return totalCount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public CustomSlice<Product> getProductsBySearch(
content.remove(pageable.getPageSize());
}

return new CustomSlice<>(content, pageable, hasNext, totalCount);
return new CustomSlice<>(content, hasNext, totalCount);
}

@Override
Expand Down Expand Up @@ -132,7 +132,7 @@ public CustomSlice<Product> getProductsByAreaCode(
content.remove(pageable.getPageSize());
}

return new CustomSlice<>(content, pageable, hasNext, totalCount);
return new CustomSlice<>(content, hasNext, totalCount);
}

private BooleanExpression buildRegionCondition(QProduct product, AreaCode areaCode) {
Expand All @@ -145,9 +145,7 @@ private BooleanExpression buildAccommodationNameCondition(QProduct product, Stri

private BooleanExpression buildCheckInCheckOutCondition(QProduct product, LocalDate checkInDate, LocalDate checkOutDate) {
return product.checkInDate.between(checkInDate, checkOutDate)
.and(product.checkOutDate.between(checkInDate, checkOutDate))
.or(product.checkInDate.eq(checkInDate))
.or(product.checkOutDate.eq(checkOutDate));
.and(product.checkOutDate.between(checkInDate, checkOutDate));
}

private BooleanExpression buildPriceRangeCondition(QProduct product, PriceRange priceRange) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package site.goldenticket.domain.product.service;

import org.springframework.stereotype.Component;

@Component
public class ApiUrlProperties {

public String getYanoljaUrl() {
return System.getProperty("yanolja.url");
}
}
Loading