go-importer/gorm_models/vendor.go

41 lines
1.1 KiB
Go
Raw Permalink Normal View History

2022-08-12 08:59:03 +00:00
package gorm_models
import (
"log"
2022-08-25 05:39:59 +00:00
"time"
2022-08-12 08:59:03 +00:00
"gorm.io/gorm"
)
2022-08-25 05:39:59 +00:00
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"`
}
2022-08-12 08:59:03 +00:00
type MarketplaceSeller struct {
ID uint `gorm:"primaryKey"`
Url string
}
func GetSellers(db *gorm.DB) []MarketplaceSeller {
var sellers []MarketplaceSeller
err := db.Model(&MarketplaceSeller{}).Find(&sellers).Error
if err != nil {
log.Println(err.Error())
}
return sellers
}