-
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.
- Loading branch information
1 parent
b0ad55c
commit 9e786ed
Showing
8 changed files
with
87 additions
and
13 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
26 changes: 26 additions & 0 deletions
26
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,26 @@ | ||
package com.kampus.kbazaar.cart; | ||
|
||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface CartRepository extends JpaRepository<Cart, Long> { | ||
|
||
String sqlCart = | ||
"SELECT " | ||
+ "c.id AS cart_id, " | ||
+ "p.name AS product_name, " | ||
+ "s.username AS user_name " | ||
+ "FROM " | ||
+ "cart c " | ||
+ "INNER JOIN product p ON c.productid = p.id " | ||
+ "INNER JOIN shopper s ON c.shopperid = s.id " | ||
+ "WHERE " | ||
+ "c.shopperid = :shopperId"; | ||
|
||
@Query(value = sqlCart, nativeQuery = true) | ||
public List<Object[]> findCartDetailById(@Param("shopperId") Long shopperId); | ||
} |
13 changes: 13 additions & 0 deletions
13
kbazaar/src/main/java/com/kampus/kbazaar/cart/CartRequest.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,13 @@ | ||
package com.kampus.kbazaar.cart; | ||
|
||
import jakarta.validation.constraints.Min; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class CartRequest { | ||
@NotNull private String sku; | ||
|
||
@Min(value = 1, message = "QTY must be greater than or equal to 0") | ||
private Integer qty; | ||
} |
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
8 changes: 8 additions & 0 deletions
8
kbazaar/src/main/java/com/kampus/kbazaar/cart/CreateCartResponse.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,8 @@ | ||
package com.kampus.kbazaar.cart; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class CreateCartResponse { | ||
private Integer cartId; | ||
} |