variants
This commit is contained in:
@@ -9,5 +9,7 @@ type CartItem struct {
|
||||
SessionId string `json:"sessionid" binding:"required" gorm:"not null"`
|
||||
ShopItemId uint
|
||||
ShopItem ShopItem `json:"shopitem" gorm:"foreignKey:ShopItemId"` //gorm one2one
|
||||
ItemVariantId uint
|
||||
ItemVariant ItemVariant `json:"itemvariant" gorm:"foreignKey:ItemVariantId"` //gorm one2one
|
||||
Quantity int `json:"quantity" binding:"required"`
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -14,6 +15,19 @@ Zines
|
||||
Books
|
||||
- name, abstr, descr, price, tag
|
||||
*/
|
||||
type Category string
|
||||
|
||||
const (
|
||||
Zine Category = "Zine"
|
||||
)
|
||||
|
||||
func ParseCategory(s string) (c Category, err error) {
|
||||
if s == "Zine" {
|
||||
return Zine, nil
|
||||
}
|
||||
|
||||
return c, fmt.Errorf("Cannot parse category %s", s)
|
||||
}
|
||||
|
||||
type ItemVariant struct {
|
||||
gorm.Model
|
||||
@@ -28,7 +42,7 @@ type ShopItem struct {
|
||||
Name string `json:"name" binding:"required" gorm:"unique;not null"`
|
||||
Abstract string `json:"Abstract" binding:"required"`
|
||||
Description string `json:"description" binding:"required"`
|
||||
Category string `json:"category"`
|
||||
Category Category `json:"category"`
|
||||
Variants []ItemVariant `json:"variant"`
|
||||
BasePrice float64 `json:"basePrice"`
|
||||
IsPublic bool `json:"isPublic" gorm:"default:true"`
|
||||
|
||||
Reference in New Issue
Block a user