add(backend) Сделано API под корзину
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type CartItem struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
UserID uint `json:"user_id" gorm:"not null;uniqueIndex;idx_user_item"`
|
||||
ItemID uint `json:"item_id" gorm:"not null;uniqueIndex;idx_user_item"`
|
||||
Quantity float64 `json:"quantity" gorm:"not null;default:1"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
|
||||
Item Item `json:"item" gorm:"foreignKey:ItemID"`
|
||||
}
|
||||
@@ -6,7 +6,7 @@ type User struct {
|
||||
gorm.Model `json:"-"`
|
||||
Username string `gorm:"unique;not null" binding:"required"`
|
||||
Password string `gorm:"not null" json:"-" binding:"required,min=8"`
|
||||
Role string `gorm:"default:'Рабочий'" json:"role"`
|
||||
Role string `gorm:"default:'customer'" json:"role"`
|
||||
FirstName string `json:"first_name" binding:"required"`
|
||||
LastName string `gorm:"index" json:"last_name" binding:"required"`
|
||||
Phone string `gorm:"index" json:"phone"`
|
||||
|
||||
Reference in New Issue
Block a user