diff --git a/api/db/member.go b/api/db/member.go index 62ea7e60e2005d04aacf4734edf8f2116314a63c..4d3f73862b9561864f3a40770de00c453910fe66 100644 --- a/api/db/member.go +++ b/api/db/member.go @@ -17,16 +17,19 @@ const ( ) type Member struct { - gorm.Model `json:"-"` - Num int `json:"num" gorm:"unique;index"` - Login string `json:"login" gorm:"unique;index"` - Name string `json:"name"` - Email string `json:"email"` - Phone string `json:"phone"` - Balance int `json:"balance"` - Role string `json:"role"` - PassHash []byte `json:"-"` - Salt []byte `json:"-"` + CreatedAt time.Time `json:"-"` + UpdatedAt time.Time `json:"-"` + DeletedAt gorm.DeletedAt `json:"-" gorm:"index"` + + Num int `json:"num" gorm:"primaryKey"` + Login string `json:"login" gorm:"unique;index"` + Name string `json:"name"` + Email string `json:"email"` + Phone string `json:"phone"` + Balance int `json:"balance"` + Role string `json:"role"` + PassHash []byte `json:"-"` + Salt []byte `json:"-"` } type PasswordReset struct { diff --git a/api/db/product.go b/api/db/product.go index 238af810283f173c4374d126ad967b952d11bd23..30f183a6ca40b08ade13448e8b77a427556bd73b 100644 --- a/api/db/product.go +++ b/api/db/product.go @@ -2,16 +2,20 @@ package db import ( "errors" + "time" "gorm.io/gorm" ) type Product struct { - gorm.Model `json:"-"` - Code int `json:"code" gorm:"unique;index"` - Name string `json:"name" gorm:"unique;index"` - Price int `json:"price"` - Stock int `json:"stock"` + CreatedAt time.Time `json:"-"` + UpdatedAt time.Time `json:"-"` + DeletedAt gorm.DeletedAt `json:"-" gorm:"index"` + + Code int `json:"code" gorm:"primaryKey"` + Name string `json:"name" gorm:"unique;index"` + Price int `json:"price"` + Stock int `json:"stock"` } func (d *DB) AddProduct(product *Product) error {