-
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.
Merge branch 'main' of github.com:KBTG-Kampus-ClassNest-SE-Java/works…
…hop-group-5
- Loading branch information
Showing
11 changed files
with
88 additions
and
15 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.kampus.kbazaar.cart; | ||
|
||
import jakarta.persistence.Embeddable; | ||
import java.io.Serializable; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Embeddable | ||
public class CartId implements Serializable { | ||
private Long shopper_id; | ||
private Long product_id; | ||
|
||
public CartId(Long shopper_id, Long product_id) { | ||
this.shopper_id = shopper_id; | ||
this.product_id = product_id; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
kbazaar/src/main/java/com/kampus/kbazaar/cart/CartRepository.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,9 @@ | ||
package com.kampus.kbazaar.cart; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface CartRepository extends JpaRepository<Cart, CartId> { | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
kbazaar/src/main/java/com/kampus/kbazaar/cart/CartService.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,16 @@ | ||
package com.kampus.kbazaar.cart; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class CartService { | ||
private CartRepository cartRepository; | ||
|
||
public CartService(CartRepository cartRepository) { | ||
this.cartRepository = cartRepository; | ||
} | ||
|
||
public String deleteCartItem(String username, String product_sku) { | ||
return "deleteL: " + username + product_sku; | ||
} | ||
} |
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,4 @@ | ||
INSERT INTO cart (quantity,product_sku) VALUES | ||
(2,'MOBILE-APPLE-IPHONE-12-PRO') ON CONFLICT DO NOTHING; | ||
INSERT INTO cart (quantity,product_sku) VALUES | ||
(1,'MOBILE-SAMSUNG-GALAXY-S21-ULTRA') ON CONFLICT DO NOTHING; |
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,8 @@ | ||
CREATE TABLE IF NOT EXISTS cart ( | ||
shopper_id bigserial NOT NULL, | ||
product_id bigserial NOT NULL, | ||
quantity int4 NOT NULL, | ||
product_sku varchar(255) NOT NULL, | ||
CONSTRAINT cart_pk PRIMARY KEY (product_id, shopper_id) | ||
); | ||
CREATE INDEX IF NOT EXISTS cart_shopper_id_idx ON cart USING btree (shopper_id); |
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