-
Notifications
You must be signed in to change notification settings - Fork 1
feat: 상품 필터링 기능 개선 #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 상품 필터링 기능 개선 #153
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| package com.ongil.backend.domain.product.dto.request; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
@@ -12,14 +14,23 @@ public class ProductSearchCondition { | |
| @Schema(description = "카테고리 ID", example = "1") | ||
| private Long categoryId; | ||
|
|
||
| @Schema(description = "브랜드 ID", example = "5") | ||
| private Long brandId; | ||
| @Schema(description = "브랜드 ID 목록 (다중 선택)", example = "[1, 2, 3]") | ||
| private List<Long> brandIds; | ||
|
|
||
| @Schema(description = "가격 범위 (형식: minPrice-maxPrice)", example = "50000-100000") | ||
| private String priceRange; | ||
|
|
||
| @Schema(description = "사이즈 (예: XS, S, M, L, XL)", example = "M") | ||
| private String size; | ||
| @Schema(description = "사이즈 목록 (다중 선택, 예: XS, S, M, L, XL)", example = "[M, L]") | ||
| private List<String> sizes; | ||
|
|
||
| // 사이즈 목록을 REGEXP 패턴으로 변환 (예: [M, L] → "(^|,)(M|L)(,|$)") | ||
| public String buildSizesPattern() { | ||
| if (sizes == null || sizes.isEmpty()) { | ||
| return null; | ||
| } | ||
| String sizeGroup = String.join("|", sizes); | ||
| return "(^|,)(" + sizeGroup + ")(,|$)"; | ||
| } | ||
|
Comment on lines
+27
to
+33
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
수정 방법은 두 가지입니다:
🛡️ 제안 수정 (화이트리스트 방식) public String buildSizesPattern() {
if (sizes == null || sizes.isEmpty()) {
return null;
}
- String sizeGroup = String.join("|", sizes);
+ // 영숫자와 '+'만 허용하여 정규식 메타문자 삽입 차단
+ String sizeGroup = sizes.stream()
+ .map(s -> s.replaceAll("[^a-zA-Z0-9+]", ""))
+ .filter(s -> !s.isEmpty())
+ .collect(java.util.stream.Collectors.joining("|"));
+ if (sizeGroup.isEmpty()) {
+ return null;
+ }
return "(^|,)(" + sizeGroup + ")(,|$)";
}🤖 Prompt for AI Agents |
||
|
|
||
| // 가격 범위 파싱 | ||
| public Integer[] parsePriceRange() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Schemaexample 값이 유효하지 않은 JSON 형식example = "[M, L]"는 JSON 배열 형식이 아닙니다. Swagger UI에서 잘못된 예시로 표시됩니다.📝 제안 수정
🤖 Prompt for AI Agents