From dcc07d4e7913052525eaeda8a0f387cfe2e2978a Mon Sep 17 00:00:00 2001 From: albrecht <flo@DESKTOP-ERC0T8S> Date: Mon, 10 Jul 2023 18:20:39 +0200 Subject: [PATCH] files umbenannt --- src/gomazon/handler/{produkt.go => product.go} | 0 src/gomazon/handler/{bewertung.go => rating.go} | 0 src/gomazon/handler/{warenkorb.go => shopping_cart.go} | 0 src/gomazon/model/{bewertung.go => rating.go} | 0 src/gomazon/model/{warenkorb.go => shopping_cart.go} | 2 +- src/gomazon/service/{produkt.go => product.go} | 0 src/gomazon/service/{bewertung.go => rating.go} | 0 src/gomazon/service/{warenkorb.go => shopping_cart.go} | 10 +++++----- 8 files changed, 6 insertions(+), 6 deletions(-) rename src/gomazon/handler/{produkt.go => product.go} (100%) rename src/gomazon/handler/{bewertung.go => rating.go} (100%) rename src/gomazon/handler/{warenkorb.go => shopping_cart.go} (100%) rename src/gomazon/model/{bewertung.go => rating.go} (100%) rename src/gomazon/model/{warenkorb.go => shopping_cart.go} (75%) rename src/gomazon/service/{produkt.go => product.go} (100%) rename src/gomazon/service/{bewertung.go => rating.go} (100%) rename src/gomazon/service/{warenkorb.go => shopping_cart.go} (90%) diff --git a/src/gomazon/handler/produkt.go b/src/gomazon/handler/product.go similarity index 100% rename from src/gomazon/handler/produkt.go rename to src/gomazon/handler/product.go diff --git a/src/gomazon/handler/bewertung.go b/src/gomazon/handler/rating.go similarity index 100% rename from src/gomazon/handler/bewertung.go rename to src/gomazon/handler/rating.go diff --git a/src/gomazon/handler/warenkorb.go b/src/gomazon/handler/shopping_cart.go similarity index 100% rename from src/gomazon/handler/warenkorb.go rename to src/gomazon/handler/shopping_cart.go diff --git a/src/gomazon/model/bewertung.go b/src/gomazon/model/rating.go similarity index 100% rename from src/gomazon/model/bewertung.go rename to src/gomazon/model/rating.go diff --git a/src/gomazon/model/warenkorb.go b/src/gomazon/model/shopping_cart.go similarity index 75% rename from src/gomazon/model/warenkorb.go rename to src/gomazon/model/shopping_cart.go index 164ea4e..4964177 100644 --- a/src/gomazon/model/warenkorb.go +++ b/src/gomazon/model/shopping_cart.go @@ -4,7 +4,7 @@ import "gorm.io/gorm" type ShoppingCart struct { gorm.Model - Positionen []Position `gorm:"foreignKey:ID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"` + Positions []Position `gorm:"foreignKey:ID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"` Totalprice float64 `gorm:"notNull;default:0.0"` Username string `gorm:"unique"` } diff --git a/src/gomazon/service/produkt.go b/src/gomazon/service/product.go similarity index 100% rename from src/gomazon/service/produkt.go rename to src/gomazon/service/product.go diff --git a/src/gomazon/service/bewertung.go b/src/gomazon/service/rating.go similarity index 100% rename from src/gomazon/service/bewertung.go rename to src/gomazon/service/rating.go diff --git a/src/gomazon/service/warenkorb.go b/src/gomazon/service/shopping_cart.go similarity index 90% rename from src/gomazon/service/warenkorb.go rename to src/gomazon/service/shopping_cart.go index 0c1a70b..3dd8f6a 100644 --- a/src/gomazon/service/warenkorb.go +++ b/src/gomazon/service/shopping_cart.go @@ -38,7 +38,7 @@ func (s *ShoppingCartService) CreateShoppingCart(ShoppingCart model.ShoppingCart func (s *ShoppingCartService) AddProductToShoppingCart(username string, ProductID uint, amount int) (*model.ShoppingCart, error) { //Get ShoppingCart ShoppingCart := &model.ShoppingCart{} - result := db.DB.Preload("Positionen").Where("username = ?", username).First(ShoppingCart) + result := db.DB.Preload("Positions").Where("username = ?", username).First(ShoppingCart) if result.Error != nil { log.Errorf("Could not find Shoppingcart of User %v", username) return nil, result.Error @@ -63,7 +63,7 @@ func (s *ShoppingCartService) AddProductToShoppingCart(username string, ProductI } // Add position to shoppingcart - ShoppingCart.Positionen = append(ShoppingCart.Positionen, position) + ShoppingCart.Positions = append(ShoppingCart.Positions, position) ShoppingCart.Totalprice += position.Totalprice result = db.DB.Save(ShoppingCart) @@ -80,7 +80,7 @@ func (s *ShoppingCartService) AddProductToShoppingCart(username string, ProductI func (s *ShoppingCartService) TransferMoney(username string) error { // Get shoppingcart from user ShoppingCart := &model.ShoppingCart{} - result := db.DB.Preload("Positionen").Where("username = ?", username).First(ShoppingCart) + result := db.DB.Preload("Positions").Where("username = ?", username).First(ShoppingCart) if result.Error != nil { log.Errorf("Could not find Shoppingcart of User %v", username) return result.Error @@ -106,8 +106,8 @@ func (s *ShoppingCartService) TransferMoney(username string) error { } // Set Shoppingcart to default - for i := range ShoppingCart.Positionen { - ShoppingCart.Positionen[i].Amount = 0 + for i := range ShoppingCart.Positions { + ShoppingCart.Positions[i].Amount = 0 } ShoppingCart.Totalprice = 0.0 -- GitLab