-
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.
feat: add cart table, adjust create new category
- Loading branch information
Showing
18 changed files
with
202 additions
and
64 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
3 changes: 2 additions & 1 deletion
3
SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/dtos/request/CategoryDTO.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,9 +1,10 @@ | ||
package com.lcaohoanq.shoppe.dtos.request; | ||
|
||
import jakarta.validation.constraints.NotEmpty; | ||
import java.util.List; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record CategoryDTO( | ||
@NotEmpty(message = "Category name is required") String name | ||
@NotEmpty(message = "Category name is required") List<String> name | ||
) {} |
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
51 changes: 51 additions & 0 deletions
51
SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/models/Cart.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,51 @@ | ||
package com.lcaohoanq.shoppe.models; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.lcaohoanq.shoppe.models.base.BaseEntity; | ||
import jakarta.persistence.CascadeType; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.OneToMany; | ||
import jakarta.persistence.OneToOne; | ||
import jakarta.persistence.SequenceGenerator; | ||
import jakarta.persistence.Table; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Entity | ||
@Table(name = "carts") | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class Cart extends BaseEntity { | ||
|
||
@Id | ||
@SequenceGenerator(name = "carts_seq", sequenceName = "carts_id_seq", allocationSize = 1) | ||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "carts_seq") | ||
@Column(name="id", unique=true, nullable=false) | ||
@JsonProperty("id") | ||
private Long id; | ||
|
||
@Column(name = "total_quantity") | ||
private int totalQuantity; | ||
|
||
@Column(name = "total_price") | ||
private double totalPrice; | ||
|
||
@OneToOne | ||
@JoinColumn(name = "user_id", referencedColumnName = "id", nullable = false) | ||
private User user; | ||
|
||
@OneToMany(mappedBy = "cart", cascade = CascadeType.ALL, orphanRemoval = true) | ||
private List<CartProduct> cartProducts = new ArrayList<>(); | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/models/CartProduct.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,46 @@ | ||
package com.lcaohoanq.shoppe.models; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.lcaohoanq.shoppe.models.base.BaseEntity; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.SequenceGenerator; | ||
import jakarta.persistence.Table; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Entity | ||
@Table(name = "cart_products") | ||
@Getter | ||
@Setter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class CartProduct extends BaseEntity { | ||
|
||
@Id | ||
@SequenceGenerator(name = "cartproducts_seq", sequenceName = "cartproducts_id_seq", allocationSize = 1) | ||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "cartproducts_seq") | ||
@Column(name="id", unique=true, nullable=false) | ||
@JsonProperty("id") | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "cart_id") | ||
private Cart cart; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "product_id") | ||
private Product product; | ||
|
||
@Column(name = "quantity") | ||
private int quantity; | ||
} |
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
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.