From 09f03179b330d7b3b65cd24197349c5481d4c8ab Mon Sep 17 00:00:00 2001
From: albrecht <flo@DESKTOP-ERC0T8S>
Date: Mon, 10 Jul 2023 22:21:35 +0200
Subject: [PATCH] changes

---
 README.md                            |  9 ++++++---
 src/gomazon/model/position.go        | 11 +++++------
 src/gomazon/service/shopping_cart.go | 11 -----------
 3 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/README.md b/README.md
index d4cf95f..f4da31a 100644
--- a/README.md
+++ b/README.md
@@ -23,6 +23,9 @@ docker compose up
 docker compose down
 ```
 
+## Technical Highlights
+This service does not use Gorilla as framework. Here will be Gin-Gonic used. Gin is the most popular framework used by Golang-Developers. It is an extremely fast web framework and it suits the requirements of developers when they create microservices and web applications. (https://github.com/gin-gonic/gin)
+
 ## All API Functions
 In this section all API-Functions will be presented with an example call!
 
@@ -157,7 +160,7 @@ curl --location --request PUT 'localhost:8080/bankaccounts' \
 If one user has already an ShoppingCart, the existing ShoppingCart is the result value.
 The user will also be detected with the Token-String.
 ```
-curl --location --request POST 'localhost:8080/ShoppingCart' \
+curl --location --request POST 'localhost:8080/shoppingcart' \
 --header 'Authorization: Bearer INSERT_TOKEN_HERE'
 ```
 
@@ -165,7 +168,7 @@ curl --location --request POST 'localhost:8080/ShoppingCart' \
 To add a Product (here Product with the ID = 1) use this function. In the request Body the amount will be specified.
 The user will also be detected with the Token-String.
 ```
-curl --location 'localhost:8080/ShoppingCart/Product/1' \
+curl --location 'localhost:8080/shoppingcart/Product/1' \
 --header 'Content-Type: application/json' \
 --header 'Authorization: Bearer INSERT_TOKEN_HERE' \
 --data '{
@@ -178,7 +181,7 @@ With this Function, all Products will be buyed. If the Balance is lesser than th
 If the Payment process is successfull, the Shoppingcart will be tranformed into the default version.
 The user will also be detected with the Token-String.
 ```
-curl --location --request POST 'localhost:8080/ShoppingCart/pay' \
+curl --location --request POST 'localhost:8080/shoppingcart/pay' \
 --header 'Authorization: Bearer INSERT_TOKEN_HERE'
 ```
 
diff --git a/src/gomazon/model/position.go b/src/gomazon/model/position.go
index 3e67041..0b26aec 100644
--- a/src/gomazon/model/position.go
+++ b/src/gomazon/model/position.go
@@ -4,10 +4,9 @@ import "gorm.io/gorm"
 
 type Position struct {
 	gorm.Model
-	Amount         int          `gorm:"notNull"`
-	ProductId      uint         `gorm:"notNull"`
-	Price          float64      `gorm:"notNull"`
-	Totalprice     float64      `gorm:"notNull"`
-	ShoppingCartId uint         `gorm:"notNull"`
-	ShoppingCart   ShoppingCart `gorm:"-"`
+	Amount         int     `gorm:"notNull"`
+	ProductId      uint    `gorm:"notNull"`
+	Price          float64 `gorm:"notNull"`
+	Totalprice     float64 `gorm:"notNull"`
+	ShoppingCartId uint    `gorm:"notNull"`
 }
diff --git a/src/gomazon/service/shopping_cart.go b/src/gomazon/service/shopping_cart.go
index e2db2c9..55f8167 100644
--- a/src/gomazon/service/shopping_cart.go
+++ b/src/gomazon/service/shopping_cart.go
@@ -106,17 +106,6 @@ func (s *ShoppingCartService) TransferMoney(username string) error {
 		return err
 	}
 
-	// Set Shoppingcart to default
-	for i := range ShoppingCart.Positions {
-		ShoppingCart.Positions[i].Amount = 0
-	}
-
-	ShoppingCart.Totalprice = 0.0
-
-	if err := db.DB.Where("shopping_cart_id = ?", ShoppingCart.Username).Delete(&model.Position{}).Error; err != nil {
-		return err
-	}
-
 	result = db.DB.Save(ShoppingCart)
 	if result.Error != nil {
 		log.Error("Could not save Shoppingcart")
-- 
GitLab