12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- 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 ProductCollection struct {
- Id string `db:"id"`
- Title string `db:"title"`
- Description string `db:"description"`
- Handle dbr.NullString `db:"handle"`
- Scope string `db:"scope"`
- SortOrder string `db:"sort_order"`
- Image dbr.NullString `db:"image"`
- TemplateSuffix dbr.NullString `db:"template_suffix"`
- CreatedAt time.Time `db:"created_at"`
- UpdatedAt time.Time `db:"updated_at"`
- PublishedAt *time.Time `db:"published_at"`
- DeletedAt *time.Time `db:"deleted_at"`
- }
- func (c *ProductCollection) As() *generated.Collection {
- description := bluemonday.StrictPolicy().Sanitize(c.Description)
- return &generated.Collection{
- Description: description,
- DescriptionHTML: scalar.Html(c.Description),
- Handle: c.Handle.String,
- ID: model.NewId(model.GidCollection, c.Id),
- Image: nil, //TODO:
- OnlineStoreURL: nil, //TODO:
- Seo: &generated.Seo{
- Description: &description,
- Title: &c.Title,
- },
- Title: c.Title,
- UpdatedAt: scalar.NewDateTimeFrom(c.UpdatedAt),
- }
- }
|