2
0

product_option.go 881 B

12345678910111213141516171819202122232425262728293031323334
  1. package relation
  2. import (
  3. "github.com/gshopify/service-wrapper/model"
  4. "gshopper.com/gshopify/products/graphql/generated"
  5. "time"
  6. )
  7. type ProductOption struct {
  8. Id string `db:"id"`
  9. Name string `db:"name"`
  10. SelectedValue string `db:"value"`
  11. Values []string `db:"values"`
  12. Position int8 `db:"position"`
  13. CreatedAt time.Time `db:"created_at"`
  14. UpdatedAt time.Time `db:"updated_at"`
  15. PublishedAt *time.Time `db:"published_at"`
  16. DeletedAt *time.Time `db:"deleted_at"`
  17. }
  18. func (opt *ProductOption) As() *generated.ProductOption {
  19. return &generated.ProductOption{
  20. ID: model.NewId(model.GidOption, opt.Id),
  21. Name: opt.Name,
  22. Values: opt.Values,
  23. }
  24. }
  25. func (opt *ProductOption) AsSelected() *generated.SelectedOption {
  26. return &generated.SelectedOption{
  27. Name: opt.Name,
  28. Value: opt.SelectedValue,
  29. }
  30. }