-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from taco-official/KL-68/상품-정보-수정-api-구현
feat(KL-68): update Product API
- Loading branch information
Showing
19 changed files
with
796 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 30 additions & 8 deletions
38
src/main/java/taco/klkl/domain/product/dto/request/ProductCreateRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,47 @@ | ||
package taco.klkl.domain.product.dto.request; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.PositiveOrZero; | ||
import jakarta.validation.constraints.Size; | ||
import taco.klkl.global.common.constants.ProductConstants; | ||
import taco.klkl.global.common.constants.ProductValidationMessages; | ||
|
||
/** | ||
* TODO: 상품필터속성 추가 해야함 (상품필터속성 테이블 개발 후) | ||
* TODO: 상품 컨트롤러에서 필터 서비스를 이용해서 조합 하는게 괜찮아 보입니다. | ||
* @param name | ||
* @param description | ||
* @param address | ||
* @param price | ||
* @param cityId | ||
* @param subcategoryId | ||
* @param currencyId | ||
* @param address | ||
* @param price | ||
*/ | ||
public record ProductCreateRequestDto( | ||
@NotNull(message = "상품명은 필수 항목입니다.") String name, | ||
@NotNull(message = "상품 설명은 필수 항목입니다.") String description, | ||
@NotNull(message = "도시 ID는 필수 항목입니다.") Long cityId, | ||
@NotNull(message = "상품 소분류 ID은 필수 항목입니다.") Long subcategoryId, | ||
@NotNull(message = "통화 ID는 필수 항목입니다.") Long currencyId, | ||
@NotNull(message = ProductValidationMessages.NAME_NOT_NULL) | ||
@NotBlank(message = ProductValidationMessages.NAME_NOT_BLANK) | ||
@Size(max = ProductConstants.NAME_MAX_LENGTH, message = ProductValidationMessages.NAME_SIZE) | ||
String name, | ||
|
||
@NotNull(message = ProductValidationMessages.DESCRIPTION_NOT_NULL) | ||
@NotBlank(message = ProductValidationMessages.DESCRIPTION_NOT_BLANK) | ||
@Size(max = ProductConstants.DESCRIPTION_MAX_LENGTH, message = ProductValidationMessages.DESCRIPTION_SIZE) | ||
String description, | ||
|
||
@Size(max = ProductConstants.ADDRESS_MAX_LENGTH, message = ProductValidationMessages.ADDRESS_SIZE) | ||
String address, | ||
Integer price | ||
|
||
@PositiveOrZero(message = ProductValidationMessages.PRICE_POSITIVE_OR_ZERO) | ||
Integer price, | ||
|
||
@NotNull(message = ProductValidationMessages.CITY_ID_NOT_NULL) | ||
Long cityId, | ||
|
||
@NotNull(message = ProductValidationMessages.SUBCATEGORY_ID_NOT_NULL) | ||
Long subcategoryId, | ||
|
||
@NotNull(message = ProductValidationMessages.CURRENCY_ID_NOT_NULL) | ||
Long currencyId | ||
) { | ||
} |
22 changes: 19 additions & 3 deletions
22
src/main/java/taco/klkl/domain/product/dto/request/ProductUpdateRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,28 @@ | ||
package taco.klkl.domain.product.dto.request; | ||
|
||
import jakarta.validation.constraints.PositiveOrZero; | ||
import jakarta.validation.constraints.Size; | ||
import taco.klkl.global.common.constants.ProductConstants; | ||
import taco.klkl.global.common.constants.ProductValidationMessages; | ||
|
||
public record ProductUpdateRequestDto( | ||
@Size(max = ProductConstants.NAME_MAX_LENGTH, message = ProductValidationMessages.NAME_SIZE) | ||
String name, | ||
|
||
@Size(max = ProductConstants.DESCRIPTION_MAX_LENGTH, message = ProductValidationMessages.DESCRIPTION_SIZE) | ||
String description, | ||
|
||
@Size(max = ProductConstants.ADDRESS_MAX_LENGTH, message = ProductValidationMessages.ADDRESS_SIZE) | ||
String address, | ||
|
||
@PositiveOrZero(message = ProductValidationMessages.PRICE_POSITIVE_OR_ZERO) | ||
Integer price, | ||
|
||
Long cityId, | ||
|
||
Long subcategoryId, | ||
Long currencyId, | ||
String address, | ||
Integer price | ||
|
||
Long currencyId | ||
|
||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/taco/klkl/global/common/constants/DefaultConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
src/main/java/taco/klkl/global/common/constants/ProductConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
package taco.klkl.global.common.constants; | ||
|
||
public class ProductConstants { | ||
public final class ProductConstants { | ||
|
||
public static final int DEFAULT_PRICE = 0; | ||
public static final int DEFAULT_LIKE_COUNT = 0; | ||
public static final String DEFAULT_ADDRESS = "N/A"; | ||
|
||
public static final int NAME_MAX_LENGTH = 100; | ||
public static final int DESCRIPTION_MAX_LENGTH = 2000; | ||
public static final int ADDRESS_MAX_LENGTH = 100; | ||
|
||
private ProductConstants() { | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/taco/klkl/global/common/constants/ProductValidationMessages.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package taco.klkl.global.common.constants; | ||
|
||
public final class ProductValidationMessages { | ||
|
||
public static final String NAME_NOT_NULL = "상품명은 필수 항목입니다."; | ||
public static final String NAME_NOT_BLANK = "상품명은 비어있을 수 없습니다."; | ||
public static final String NAME_SIZE = "상품명은 100자 이하여야 합니다."; | ||
|
||
public static final String DESCRIPTION_NOT_NULL = "상품 설명은 필수 항목입니다."; | ||
public static final String DESCRIPTION_NOT_BLANK = "상품 설명은 비어있을 수 없습니다."; | ||
public static final String DESCRIPTION_SIZE = "상품 설명은 2000자 이하여야 합니다."; | ||
|
||
public static final String ADDRESS_SIZE = "주소는 100자 이하여야 합니다."; | ||
|
||
public static final String PRICE_POSITIVE_OR_ZERO = "가격은 0 이상이어야 합니다."; | ||
|
||
public static final String CITY_ID_NOT_NULL = "도시 ID는 필수 항목입니다."; | ||
public static final String SUBCATEGORY_ID_NOT_NULL = "상품 소분류 ID는 필수 항목입니다."; | ||
public static final String CURRENCY_ID_NOT_NULL = "통화 ID는 필수 항목입니다."; | ||
|
||
private ProductValidationMessages() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.