forked from KBTG-Kampus-ClassNest-SE-Java/workshopb2-group-1
-
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 https://github.com/KBTG-Kampus-ClassNest-SE-Ja…
…va/workshopb2-group-4 # Conflicts: # kbazaar/src/main/java/com/kampus/kbazaar/cart/Cart.java
- Loading branch information
Showing
45 changed files
with
1,702 additions
and
1,630 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
24 changes: 12 additions & 12 deletions
24
kbazaar/src/main/java/com/kampus/kbazaar/KBazaarApplication.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,12 +1,12 @@ | ||
package com.kampus.kbazaar; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class KBazaarApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(KBazaarApplication.class, args); | ||
} | ||
} | ||
package com.kampus.kbazaar; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class KBazaarApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(KBazaarApplication.class, args); | ||
} | ||
} |
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
15 changes: 13 additions & 2 deletions
15
kbazaar/src/main/java/com/kampus/kbazaar/cart/CartController.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,14 +1,25 @@ | ||
package com.kampus.kbazaar.cart; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1") | ||
public class CartController { | ||
|
||
private CartService cartService; | ||
|
||
public CartController(CartService cartService) { | ||
this.cartService = cartService; | ||
} | ||
|
||
@GetMapping("/carts") | ||
public ResponseEntity getCart() { // NOSONAR | ||
return ResponseEntity.ok().build(); | ||
public ResponseEntity<List<CartResponse>> getCart() { // NOSONAR | ||
// return ResponseEntity.ok().build(); | ||
|
||
return new ResponseEntity<>(cartService.getAll(), HttpStatus.OK); | ||
} | ||
} |
101 changes: 53 additions & 48 deletions
101
kbazaar/src/main/java/com/kampus/kbazaar/cart/CartResponse.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,48 +1,53 @@ | ||
package com.kampus.kbazaar.cart; | ||
|
||
import com.kampus.kbazaar.cartItem.CartItem; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.List; | ||
|
||
public class CartResponse { | ||
private String username; | ||
private List<CartItem> items; | ||
private BigDecimal discount; | ||
private BigDecimal totalDiscount; | ||
private BigDecimal subtotal; | ||
private BigDecimal grandTotal; | ||
|
||
public CartResponse(String username, List<CartItem> items, BigDecimal discount, BigDecimal totalDiscount, BigDecimal subtotal, BigDecimal grandTotal) { | ||
this.username = username; | ||
this.items = items; | ||
this.discount = discount; | ||
this.totalDiscount = totalDiscount; | ||
this.subtotal = subtotal; | ||
this.grandTotal = grandTotal; | ||
} | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
public List<CartItem> getItems() { | ||
return items; | ||
} | ||
|
||
public BigDecimal getDiscount() { | ||
return discount; | ||
} | ||
|
||
public BigDecimal getTotalDiscount() { | ||
return totalDiscount; | ||
} | ||
|
||
public BigDecimal getSubtotal() { | ||
return subtotal; | ||
} | ||
|
||
public BigDecimal getGrandTotal() { | ||
return grandTotal; | ||
} | ||
} | ||
package com.kampus.kbazaar.cart; | ||
|
||
import com.kampus.kbazaar.cartItem.CartItem; | ||
import java.math.BigDecimal; | ||
import java.util.List; | ||
|
||
public class CartResponse { | ||
private String username; | ||
private List<CartItem> items; | ||
private BigDecimal discount; | ||
private BigDecimal totalDiscount; | ||
private BigDecimal subtotal; | ||
private BigDecimal grandTotal; | ||
|
||
public CartResponse( | ||
String username, | ||
List<CartItem> items, | ||
BigDecimal discount, | ||
BigDecimal totalDiscount, | ||
BigDecimal subtotal, | ||
BigDecimal grandTotal) { | ||
this.username = username; | ||
this.items = items; | ||
this.discount = discount; | ||
this.totalDiscount = totalDiscount; | ||
this.subtotal = subtotal; | ||
this.grandTotal = grandTotal; | ||
} | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
public List<CartItem> getItems() { | ||
return items; | ||
} | ||
|
||
public BigDecimal getDiscount() { | ||
return discount; | ||
} | ||
|
||
public BigDecimal getTotalDiscount() { | ||
return totalDiscount; | ||
} | ||
|
||
public BigDecimal getSubtotal() { | ||
return subtotal; | ||
} | ||
|
||
public BigDecimal getGrandTotal() { | ||
return grandTotal; | ||
} | ||
} |
Oops, something went wrong.