Skip to content

Commit

Permalink
Merge pull request #23 from duongminhhieu/develop
Browse files Browse the repository at this point in the history
refactor: validation + throw exception
  • Loading branch information
duongminhhieu committed Jun 8, 2024
2 parents a09a1af + e4e708a commit 5e68ac4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class SecurityConfiguration {
"/swagger-ui/**",
"/api-docs/**",
"/categories",
"/categories/{slug}",
"/categories/slug/{slug}",
"/products",
"/products/{slug}",
"/rating",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.learning.yasminishop.common.validator.FieldNotEmpty.FieldNotEmptyConstraint;
import com.learning.yasminishop.common.validator.FieldNotNull.FieldNotNullConstraint;
import jakarta.validation.constraints.Min;
import lombok.*;
import lombok.experimental.FieldDefaults;

Expand Down Expand Up @@ -40,6 +41,7 @@ public class ProductRequest {

@FieldNotNullConstraint(field = "quantity", message = "FIELD_NOT_NULL")
@FieldNotEmptyConstraint(field = "quantity", message = "FIELD_NOT_EMPTY")
@Min(value = 1, message = "INVALID_QUANTITY")
Long quantity;

@FieldNotNullConstraint(field = "isAvailable", message = "FIELD_NOT_NULL")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public List<ProductResponse> findCarByImage(MultipartFile file){

} catch (Exception e) {
log.error("Error finding car by image", e);
throw new AppException(ErrorCode.GENERATIVE_AI_ERROR);
return List.of();
}
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ server:
port: 8080
servlet:
context-path: /api/v1
# address: 0.0.0.0

application:
jwt:
Expand Down

0 comments on commit 5e68ac4

Please sign in to comment.