1234567891011121314151617181920212223242526272829303132333435363738394041 |
- 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 Collection struct {
- Id string `db:"id"`
- Title string `db:"title"`
- Description string `db:"description"`
- Handle dbr.NullString `db:"handle"`
- Thumbnail dbr.NullString `db:"thumbnail"`
- CreatedAt time.Time `db:"created_at"`
- UpdatedAt time.Time `db:"updated_at"`
- DeletedAt *time.Time `db:"deleted_at"`
- }
- func (c *Collection) 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:
- Metafield: nil,
- Metafields: nil,
- OnlineStoreURL: nil, //TODO:
- Seo: &generated.Seo{
- Description: &description,
- Title: &c.Title,
- },
- Title: c.Title,
- UpdatedAt: scalar.NewDateTimeFrom(c.UpdatedAt),
- }
- }
|