diff --git a/README.md b/README.md index d4cf95fd247662b935b134bee602053e8dc49d9f..f4da31a3c3db23c6a22bd88a23461d1db605c580 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 3e67041728962ade368b590c85c05e79fba489e6..0b26aec5da50037c46818b642197c94134fa6d30 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 e2db2c9b0a8ae415bfdf5a25d30191a9bd8b7438..55f816774e727d3c62f02375f62fe296b2be97db 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")