Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ public ApiResponse<SliceResponse<ProductListResponse>> getCustomKeyboardProducts
/// 서비스
Slice<ProductListResponse> content = service.getCustomProducts(userId, category.getValue(), layout, pageable);

/// 개수 조회
Long counts = service.getCustomProductCounts(category.getValue(), layout);

/// DTO 변경
Slice<ProductListResponse> dtoSlice = new SliceImpl<>(
content.getContent(),
Expand All @@ -143,7 +146,7 @@ public ApiResponse<SliceResponse<ProductListResponse>> getCustomKeyboardProducts
);

/// 응답
return ApiResponse.ok(SliceResponse.from(dtoSlice));
return ApiResponse.ok(SliceResponse.from(dtoSlice, counts));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public class CustomKeyboardRequest {
@Schema(description = "키캡 ID", example = "keycap_29")
private String keyCapId;

@Schema(description = "악세사리 ID", example = "accessory_id")
private String accessoryId;

@Schema(description = "커스텀 키보드 이름", example = "내 인생 첫 커스텀 65키")
private String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,39 @@
description = "커스텀 키보드의 상세 정보를 조회하는 응답 DTO입니다."
)
public record CustomKeyboardDetailResponse(
@Schema(description = "커스텀 키보드 ID", example = "101")
@Schema(description = "커스텀 키보드 ID", example = "1")
Long customId,

@Schema(description = "커스텀 키보드 이름", example = "타건감 좋은 65키 키보드")
String customName,

@Schema(description = "커스텀 키보드 타입", example = "65%")
@Schema(description = "커스텀 키보드 타입", example = "60배열")
String customKeyboardType,

@Schema(description = "하우징 상품 ID", example = "68b3f4fedc26d32d8881fe12")
String housingId,

@Schema(description = "하우징(프레임) 이름", example = "TX-65")
String housingName,

@Schema(description = "키캡 ID", example = "GMK Red Samurai")
String keyCapId,

@Schema(description = "키캡 이름", example = "GMK Red Samurai")
String keyCapName,

@Schema(description = "스위치 이름", example = "Gateron Ink Black v2")
@Schema(description = "스위치 ID", example = "689d4fd15f80b10f1691fc96")
String switchId,

@Schema(description = "스위치 이름", example = "게이트론 브라운 스위치 (10개) - 갈축 10개")
String switchName,

@Schema(description = "악세사리 ID", example = "68baf9e37de370ef29647eb1")
String accessoryId,

@Schema(description = "악세사리 이름", example = "아크릴 키보드 덮개 케이스 커버 보관함 방진 중형 보호 먼지 차단 투명 수납함 정리함")
String accessoryName,

@Schema(description = "썸네일 이미지 URL", example = "https://example.com/custom/101.jpg")
String thumbnail,

Expand All @@ -52,9 +67,14 @@ public static CustomKeyboardDetailResponse from(CustomKeyboardWithName entity){
.customId(entity.id())
.customName(entity.name())
.customKeyboardType(entity.layout())
.housingId(entity.frameId())
.housingName(entity.frameName())
.keyCapId(entity.keyCapId())
.keyCapName(entity.keyCapName())
.switchId(entity.switchId())
.switchName(entity.switchName())
.accessoryId(entity.accessoryId())
.accessoryName(entity.accessoryName())
.thumbnail(entity.imageUrl())
.price(entity.totalPrice())
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package site.kikihi.custom.platform.adapter.in.web.dto.response.product;


import com.fasterxml.jackson.annotation.JsonInclude;
import site.kikihi.custom.platform.domain.product.Product;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
Expand All @@ -21,6 +22,7 @@
* @param discountedPrice 가격 (기존 DTO 컬럼과 동일하게 유지)
*/

@JsonInclude(JsonInclude.Include.NON_NULL)
@Builder
@Schema(name = "[응답][상품] 상품 목록 조회 Response", description = "상품 목록 조회를 위한 DTO입니다.")
public record ProductListResponse(
Expand All @@ -31,6 +33,9 @@ public record ProductListResponse(
@Schema(description = "상품 썸네일 이미지 URL", example = "https://example.com/product/101.jpg")
String thumbnail,

@Schema(description = "상품 매핑 이미지 URL", example = "https://example.com/product/101.jpg")
String mappingUrl,

@Schema(description = "카테고리명", example = "keycap")
String category,

Expand All @@ -53,6 +58,7 @@ public static ProductListResponse from(Product product) {
.id(product.getId())
.thumbnail(product.getThumbnail())
.category(product.getCategory())
.mappingUrl(product.getMapping())
.manufacturerName(product.getManufacturer())
.productName(product.getName())
.discountedPrice(getPrice(product))
Expand Down Expand Up @@ -81,6 +87,7 @@ public static ProductListResponse from(Product product, boolean likedByMe) {
return ProductListResponse.builder()
.id(product.getId())
.thumbnail(product.getThumbnail())
.mappingUrl(product.getMapping())
.category(product.getCategory())
.manufacturerName(product.getManufacturer())
.productName(product.getName())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package site.kikihi.custom.platform.adapter.in.web.swagger;

import io.swagger.v3.oas.annotations.Parameter;
import site.kikihi.custom.global.response.ApiResponse;
import site.kikihi.custom.global.response.page.PageRequest;
import site.kikihi.custom.global.response.page.SliceResponse;
Expand Down Expand Up @@ -52,13 +53,15 @@ ApiResponse<Void> createCustomKeyboard(

/**
* 키보드 상세 조회
* @param customKeyboardId 키보드 ID
*
* @param customKeyboardId 키보드 ID
*/
@Operation(
summary = "커스텀 키보드 상세 조회 API",
description = "커스텀 키보드를 상세 조회합니다."
)
ApiResponse<CustomKeyboardDetailResponse> getCustomKeyboard(
@Parameter(example = "1")
@PathVariable Long customKeyboardId);


Expand Down Expand Up @@ -112,9 +115,10 @@ ApiResponse<Void> deleteCustomKeyboard(
String REQUEST = """
{
"layout" : "PERCENT_60",
"housingId" : "68b3f4fedc26d32d8881fdff",
"switchId" : "686bd26d34c3c12ea9b8e7e3",
"keyCapId" : "68b3f653dc26d32d8881fe3d",
"housingId" : "68b3f4fedc26d32d8881fe12",
"switchId" : "689d4fd15f80b10f1691fc96",
"keyCapId" : "68b3f653dc26d32d8881fe43",
"accessoryId" : "68baf9e37de370ef29647eb1",
"name" : "테스트 커스텀"
}
""";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,22 @@ public Slice<Product> getProductsAndCategoryByType(String type, String categoryI
.map(ProductDocument::toDomain);
}

@Override
public Long getProductsAndCategoryByType(String type, String categoryId) {
return documentRepository.countByTypeAndCategoryAndIsCustomTrue(type, categoryId);
}

@Override
public Slice<Product> getProductsByCategoryAndCustom(String categoryId, Pageable pageable) {
return documentRepository.findByCategoryAndIsCustomTrue(categoryId, pageable)
.map(ProductDocument::toDomain);
}

@Override
public Long getProductsByCategoryAndCustom(String categoryId) {
return documentRepository.countByCategoryAndIsCustomTrue(categoryId);
}


/**
* 상품 개수 조회
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class CustomKeyboardJpaEntity extends BaseTimeEntity {

private String keyCapId;

private String accessoryId;

private String name;

private String imageUrl;
Expand All @@ -45,6 +47,7 @@ public static CustomKeyboardJpaEntity from(CustomKeyboard entity) {
.frameId(entity.getFrameId())
.switchId(entity.getSwitchId())
.keyCapId(entity.getKeyCapId())
.accessoryId(entity.getAccessoryId())
.name(entity.getName())
.imageUrl(entity.getImageUrl())
.layout(entity.getLayout())
Expand All @@ -59,6 +62,7 @@ public CustomKeyboard toDomain(){
.frameId(frameId)
.switchId(switchId)
.keyCapId(keyCapId)
.accessoryId(accessoryId)
.name(name)
.imageUrl(imageUrl)
.layout(layout)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public class ProductDocument {
@Field("thumbnail")
private String thumbnail;

@Field("mapping")
private String mapping;

private String manufacturer;

@Field("detail_page_url")
Expand Down Expand Up @@ -65,6 +68,7 @@ public Product toDomain(){
.price(price)
.description(description)
.thumbnail(thumbnail)
.mapping(mapping)
.manufacturer(manufacturer)
.detailPageUrl(detailPageUrl)
.options(options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ Slice<ProductDocument> findByTypeAndCategoryAndIsCustomTrue(
Pageable pageable
);

@Query(value = """
{ 'type': ?0, 'category': ?1, 'is_custom': true }
""", count = true)
Long countByTypeAndCategoryAndIsCustomTrue(String type, String category);

@Query("""
{
'category': ?0,
Expand All @@ -90,6 +95,14 @@ Slice<ProductDocument> findByCategoryAndIsCustomTrue(
Pageable pageable
);


@Query(value = """
{'category': ?0, 'is_custom': true }
""", count = true)
Long countByCategoryAndIsCustomTrue(String category);



/// 아이디 기반 조회
Slice<ProductDocument> findByIdIn(List<String> ids, Pageable pageable);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public interface CustomKeyboardUseCase {
// 배열에 맞는 상품 조회하기
Slice<ProductListResponse> getCustomProducts(UUID userId, String categoryId, CustomKeyboardLayout type, Pageable pageable);

// 배여에 맞는 상품 개수 조회하기
Long getCustomProductCounts(String categoryId, CustomKeyboardLayout type);


/// 삭제
void deleteCustomKeyboard(Long customKeyboardId, UUID userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,14 @@ public interface ProductPort {

Slice<Product> getProductsAndCategoryByType(String type, String categoryId, Pageable pageable);

// 개수
Long getProductsAndCategoryByType(String type, String categoryId);

Slice<Product> getProductsByCategoryAndCustom(String categoryId, Pageable pageable);

// 개수
Long getProductsByCategoryAndCustom(String categoryId);

/// 상품 개수 조회
Long getProductsCount(String category);

Expand Down
Loading
Loading