-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BE] ✨ feat : 장바구니 목록 취소 기능 구현 merge
[BE] ✨ feat : 장바구니 목록 취소 기능 구현 #42
- Loading branch information
Showing
11 changed files
with
328 additions
and
0 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
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
24 changes: 24 additions & 0 deletions
24
...c/main/java/com/server/domain/video/controller/dto/request/VideoCartDeleteApiRequest.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,24 @@ | ||
package com.server.domain.video.controller.dto.request; | ||
|
||
import com.server.global.validation.EachNotBlank; | ||
import com.server.global.validation.EachPositive; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import javax.validation.constraints.Size; | ||
import java.util.List; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
@Builder | ||
public class VideoCartDeleteApiRequest { | ||
|
||
@NotNull(message = "{validation.video.cart.videoIds}") | ||
@EachPositive(message = "{validation.positive}") | ||
@Size(min = 1, message = "{validation.video.cart.videoIds}") | ||
public List<Long> videoIds; | ||
} |
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
20 changes: 20 additions & 0 deletions
20
Server/src/main/java/com/server/global/validation/EachPositive.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,20 @@ | ||
package com.server.global.validation; | ||
|
||
import javax.validation.Constraint; | ||
import javax.validation.Payload; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target({ ElementType.FIELD }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Constraint(validatedBy = EachPositiveValidator.class) | ||
public @interface EachPositive { | ||
|
||
String message() default "List contains not positive value"; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
Class<? extends Payload>[] payload() default {}; | ||
} |
27 changes: 27 additions & 0 deletions
27
Server/src/main/java/com/server/global/validation/EachPositiveValidator.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,27 @@ | ||
package com.server.global.validation; | ||
|
||
import javax.validation.ConstraintValidator; | ||
import javax.validation.ConstraintValidatorContext; | ||
import java.util.List; | ||
|
||
public class EachPositiveValidator implements ConstraintValidator<EachPositive, List<? extends Number>> { | ||
|
||
@Override | ||
public void initialize(EachPositive constraintAnnotation) { | ||
} | ||
|
||
@Override | ||
public boolean isValid(List<? extends Number> list, ConstraintValidatorContext context) { | ||
if (list == null) { | ||
return true; | ||
} | ||
|
||
for (Number item : list) { | ||
if (item == null || item.longValue() <= 0) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
} | ||
|
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
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.