13 changed files with 236 additions and 52 deletions
Split View
Diff Options
-
2ShopifyOrderAndReview/src/main/java/com/shopify/cart/ShopifyOrderAndReviewApplication.java
-
48ShopifyOrderAndReview/src/main/java/com/shopify/cart/controller/OrderController.java
-
2ShopifyOrderAndReview/src/main/java/com/shopify/cart/controller/ProductController.java
-
44ShopifyOrderAndReview/src/main/java/com/shopify/cart/controller/ReviewController.java
-
2ShopifyOrderAndReview/src/main/java/com/shopify/cart/controller/UserController.java
-
62ShopifyOrderAndReview/src/main/java/com/shopify/cart/model/Cart.java
-
46ShopifyOrderAndReview/src/main/java/com/shopify/cart/model/Order.java
-
5ShopifyOrderAndReview/src/main/java/com/shopify/cart/model/OrderDto.java
-
10ShopifyOrderAndReview/src/main/java/com/shopify/cart/model/Product.java
-
38ShopifyOrderAndReview/src/main/java/com/shopify/cart/model/ReviewDto.java
-
15ShopifyOrderAndReview/src/main/java/com/shopify/cart/repository/CartRepository.java
-
6ShopifyOrderAndReview/src/main/java/com/shopify/cart/repository/OrderRepository.java
-
8ShopifyOrderAndReview/src/main/resources/application.properties
@ -0,0 +1,62 @@ |
|||
package com.shopify.cart.model; |
|||
|
|||
import javax.persistence.Entity; |
|||
import javax.persistence.GeneratedValue; |
|||
import javax.persistence.GenerationType; |
|||
import javax.persistence.Id; |
|||
import javax.persistence.OneToOne; |
|||
|
|||
@Entity |
|||
public class Cart { |
|||
|
|||
@Id |
|||
@GeneratedValue(strategy = GenerationType.AUTO) |
|||
private Long cart_id; |
|||
@OneToOne |
|||
private User user; |
|||
@OneToOne |
|||
private Product product; |
|||
private Integer quantity; |
|||
private Double price; |
|||
|
|||
public Long getCart_id() { |
|||
return cart_id; |
|||
} |
|||
|
|||
public void setCart_id(Long cart_id) { |
|||
this.cart_id = cart_id; |
|||
} |
|||
|
|||
public User getUser() { |
|||
return user; |
|||
} |
|||
|
|||
public void setUser(User user) { |
|||
this.user = user; |
|||
} |
|||
|
|||
public Product getProduct() { |
|||
return product; |
|||
} |
|||
|
|||
public void setProduct(Product product) { |
|||
this.product = product; |
|||
} |
|||
|
|||
public int getQuantity() { |
|||
return quantity; |
|||
} |
|||
|
|||
public void setQuantity(int quantity) { |
|||
this.quantity = quantity; |
|||
} |
|||
|
|||
public double getPrice() { |
|||
return price; |
|||
} |
|||
|
|||
public void setPrice(double price) { |
|||
this.price = price; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
package com.shopify.cart.model; |
|||
|
|||
public class OrderDto { |
|||
|
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
package com.shopify.cart.model; |
|||
|
|||
public class ReviewDto { |
|||
private String reviewText; |
|||
private Integer rating; |
|||
private String username; |
|||
private String product_name; |
|||
public ReviewDto() { |
|||
super(); |
|||
// TODO Auto-generated constructor stub |
|||
} |
|||
public String getReviewText() { |
|||
return reviewText; |
|||
} |
|||
public void setReviewText(String reviewText) { |
|||
this.reviewText = reviewText; |
|||
} |
|||
public Integer getRating() { |
|||
return rating; |
|||
} |
|||
public void setRating(Integer rating) { |
|||
this.rating = rating; |
|||
} |
|||
public String getUsername() { |
|||
return username; |
|||
} |
|||
public void setUsername(String username) { |
|||
this.username = username; |
|||
} |
|||
public String getProduct_name() { |
|||
return product_name; |
|||
} |
|||
public void setProduct_name(String product_name) { |
|||
this.product_name = product_name; |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
package com.shopify.cart.repository; |
|||
|
|||
import java.util.List; |
|||
|
|||
import org.springframework.data.jpa.repository.JpaRepository; |
|||
import org.springframework.data.jpa.repository.Query; |
|||
|
|||
import com.shopify.cart.model.Cart; |
|||
|
|||
public interface CartRepository extends JpaRepository<Cart, Long> { |
|||
|
|||
@Query("select c from Cart c join c.user u where u.id=?1") |
|||
List<Cart> findAllByUserId(Long uid); |
|||
|
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue