2
0

product.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package db
  2. import (
  3. "github.com/gshopify/service-wrapper/model"
  4. "gshopper.com/gshopify/products/cache"
  5. "time"
  6. )
  7. const defaultCurrency = "USD"
  8. var (
  9. productKey = func(clause string, args ...any) *cache.SqlKey {
  10. return cache.NewSQLKey(
  11. "product",
  12. time.Minute,
  13. clause, args...)
  14. }
  15. productSelection = func(ln model.LanguageCode) []string {
  16. return append([]string{
  17. "id", "profile_id", "collection_ids", "type_id", "handle", "thumbnail", "is_giftcard", "discountable",
  18. "hs_code", "mid_code", "weight", "length", "height", "width", "origin_country", "vendor", "material",
  19. "created_at", "updated_at", "deleted_at", "tags", "status",
  20. },
  21. ln.SqlFieldSelection("title", ""),
  22. ln.SqlFieldSelection("subtitle", ""),
  23. ln.SqlFieldSelection("description", ""),
  24. )
  25. }
  26. productCollectionKey = func(clause string, args ...any) *cache.SqlKey {
  27. return cache.NewSQLKey(
  28. "product_collection",
  29. 3*time.Minute,
  30. clause,
  31. args...,
  32. )
  33. }
  34. productOptionSelection = func(ln model.LanguageCode) []string {
  35. return append([]string{
  36. "id", "product_id",
  37. "created_at", "updated_at", "deleted_at",
  38. },
  39. ln.SqlFieldSelection("name", ""),
  40. ln.SqlArraySelection("values"),
  41. )
  42. }
  43. productOptionKey = func(clause string, args ...any) *cache.SqlKey {
  44. return cache.NewSQLKey(
  45. "product_option",
  46. time.Minute,
  47. clause, args...)
  48. }
  49. productVariantKey = func(clause string, args ...any) *cache.SqlKey {
  50. return cache.NewSQLKey(
  51. "product_variant",
  52. time.Minute,
  53. clause, args...)
  54. }
  55. )