go_service/gorm_models/vendor.go

38 lines
1.0 KiB
Go
Raw Normal View History

2022-08-12 08:59:03 +00:00
package gorm_models
import (
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
2023-01-19 11:32:55 +00:00
Product Product
2022-08-25 05:39:59 +00:00
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
}
2022-09-03 13:27:46 +00:00
func GetSellers(db *gorm.DB) ([]MarketplaceSeller, error) {
2022-08-12 08:59:03 +00:00
var sellers []MarketplaceSeller
2022-09-03 13:27:46 +00:00
err := db.Model(&MarketplaceSeller{}).Find(&sellers).Error
2022-08-12 08:59:03 +00:00
2022-09-03 13:27:46 +00:00
return sellers, err
2022-08-12 08:59:03 +00:00
}