37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
package gorm_models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type MarketplaceProduct struct {
|
|
ID uint `gorm:"primaryKey"`
|
|
CreatedAt time.Time `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
UpdatedAt time.Time `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
ProductID uint
|
|
ParentID *uint `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
Condition string `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
Price float64
|
|
Description string `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
IsApproved bool `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
IsOwner bool
|
|
MarketplaceSellerID uint
|
|
MarketplaceSeller MarketplaceSeller
|
|
Variants []MarketplaceProduct `gorm:"foreignKey:ParentID"`
|
|
}
|
|
|
|
type MarketplaceSeller struct {
|
|
ID uint `gorm:"primaryKey"`
|
|
Url string
|
|
}
|
|
|
|
func GetSellers(db *gorm.DB) ([]MarketplaceSeller, error) {
|
|
var sellers []MarketplaceSeller
|
|
|
|
err := db.Model(&MarketplaceSeller{}).Find(&sellers).Error
|
|
|
|
return sellers, err
|
|
}
|