package relation import ( "github.com/gshopify/service-wrapper/model" "github.com/gshopify/service-wrapper/scalar" "github.com/mailru/dbr" "github.com/microcosm-cc/bluemonday" "gshopper.com/gshopify/products/graphql/generated" "time" ) type Product struct { Id string `db:"id"` Title string `db:"title"` Subtitle dbr.NullString `db:"subtitle"` Description dbr.NullString `db:"description"` Handle dbr.NullString `db:"handle"` IsGiftcard bool `db:"is_giftcard"` Thumbnail dbr.NullString `db:"thumbnail"` ProfileId string `db:"profile_id"` Weight dbr.NullInt64 `db:"weight"` Length dbr.NullInt64 `db:"length"` Height dbr.NullInt64 `db:"height"` Width dbr.NullInt64 `db:"width"` HsCode dbr.NullString `db:"hs_code"` OriginCountry dbr.NullString `db:"origin_country"` Vendor dbr.NullString `db:"vendor"` MidCode dbr.NullString `db:"mid_code"` Material dbr.NullString `db:"material"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` DeletedAt *time.Time `db:"deleted_at"` CollectionIds []string `db:"collection_ids"` TypeId dbr.NullString `db:"type_id"` Discountable bool `db:"discountable"` Status string `db:"status"` Tags []string `db:"tags"` ExternalId dbr.NullString `db:"external_id"` } func (p *Product) As() *generated.Product { description := bluemonday.StrictPolicy().Sanitize(p.Description.String) return &generated.Product{ AvailableForSale: false, CompareAtPriceRange: nil, CreatedAt: scalar.NewDateTimeFrom(p.CreatedAt), Description: description, DescriptionHTML: scalar.Html(p.Description.String), FeaturedImage: nil, Handle: p.Handle.String, ID: model.NewId(model.GidProduct, p.Id), Images: nil, IsGiftCard: p.IsGiftcard, Media: nil, Metafield: nil, Metafields: nil, OnlineStoreURL: nil, PriceRange: nil, ProductType: p.TypeId.String, PublishedAt: scalar.NewDateTimeFrom(p.CreatedAt), RequiresSellingPlan: false, SellingPlanGroups: nil, Seo: &generated.Seo{ Description: &description, Title: &p.Title, }, Tags: p.Tags, Title: p.Title, TotalInventory: nil, UpdatedAt: scalar.NewDateTimeFrom(p.UpdatedAt), VariantBySelectedOptions: nil, Vendor: p.Vendor.String, } }