-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/products implementation #3
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
base: main
Are you sure you want to change the base?
Conversation
- it includes new product method
Reviewer's GuideAdds a new Product domain model with JPA and Lombok annotations, exposes persistence via a Spring Data JPA repository, and provides a service method to create new product records. Class diagram for Product domain model and serviceclassDiagram
class BaseEntity {
<<abstract>>
// (attributes not shown)
}
class ProductEntity {
String name
String description
double price
String image
}
class ProductRepository {
+save(ProductEntity): ProductEntity
}
class ProductService {
-ProductRepository productRepository
+newProduct(ProductEntity): ProductEntity
}
ProductEntity --|> BaseEntity
ProductRepository <|-- ProductService
ProductRepository o-- ProductEntity
ProductService o-- ProductRepository
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @AliDeWeb - I've reviewed your changes - here's some feedback:
- Consider using BigDecimal for the price field instead of double to avoid floating‐point precision issues with monetary values.
- Add validation annotations (e.g. @notblank for name/description and @min(0) for price) to enforce basic constraints at the model level.
- It’s generally preferable to follow a consistent naming convention for your table (e.g. singular lower‐case snake_case) rather than "Products".
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider using BigDecimal for the price field instead of double to avoid floating‐point precision issues with monetary values.
- Add validation annotations (e.g. @NotBlank for name/description and @Min(0) for price) to enforce basic constraints at the model level.
- It’s generally preferable to follow a consistent naming convention for your table (e.g. singular lower‐case snake_case) rather than "Products".
## Individual Comments
### Comment 1
<location> `src/main/java/com/github/alideweb/stuffshop/modules/product/entity/ProductEntity.java:17` </location>
<code_context>
+@Getter
+@Setter
+public class ProductEntity extends BaseEntity {
+ @Column(nullable = false)
+ private String name;
+
+ @Column(nullable = false)
+ private String description;
+
+ @Column(nullable = false)
+ private double price;
+
+ private String image;
</code_context>
<issue_to_address>
Consider using BigDecimal for price instead of double.
BigDecimal provides greater accuracy for financial values and helps prevent rounding errors.
Suggested implementation:
```java
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.math.BigDecimal;
```
```java
@Column(nullable = false)
private BigDecimal price;
```
</issue_to_address>
### Comment 2
<location> `src/main/java/com/github/alideweb/stuffshop/modules/product/entity/ProductEntity.java:26` </location>
<code_context>
+ @Column(nullable = false)
+ private double price;
+
+ private String image;
+}
</code_context>
<issue_to_address>
Clarify the expected format or constraints for the image field.
Specify whether the image field should be a URL, file path, or base64, and add validation to enforce this format.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| @Column(nullable = false) | ||
| private String name; | ||
|
|
||
| @Column(nullable = false) | ||
| private String description; | ||
|
|
||
| @Column(nullable = false) | ||
| private double price; |
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.
suggestion: Consider using BigDecimal for price instead of double.
BigDecimal provides greater accuracy for financial values and helps prevent rounding errors.
Suggested implementation:
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.math.BigDecimal; @Column(nullable = false)
private BigDecimal price;| @Column(nullable = false) | ||
| private double price; | ||
|
|
||
| private String image; |
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.
suggestion: Clarify the expected format or constraints for the image field.
Specify whether the image field should be a URL, file path, or base64, and add validation to enforce this format.
Summary by Sourcery
Implement the products module by defining a JPA entity, repository, and service for managing products
New Features: