data.coffee 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. # Базовый класс для всех сущностей
  2. class DomainEntity
  3. constructor: ->
  4. @_id = ''
  5. @_rev = ''
  6. @type = ''
  7. @domains = []
  8. @createdAt = new Date().toISOString()
  9. @updatedAt = new Date().toISOString()
  10. @active = true
  11. @createdBy = ''
  12. @updatedBy = ''
  13. # Товар
  14. class Product extends DomainEntity
  15. constructor: ->
  16. super()
  17. @type = 'product'
  18. @name = ''
  19. @sku = ''
  20. @price = 0
  21. @oldPrice = null
  22. @category = ''
  23. @brand = ''
  24. @description = ''
  25. @shortDescription = ''
  26. @attributes = {}
  27. @images = []
  28. @richContent = null
  29. @inStock = true
  30. @stockQuantity = 0
  31. @weight = 0
  32. @volume = 0
  33. @dimensions = {}
  34. @seo = {}
  35. @tags = []
  36. @relatedProducts = []
  37. # Категория
  38. class Category extends DomainEntity
  39. constructor: ->
  40. super()
  41. @type = 'category'
  42. @name = ''
  43. @slug = ''
  44. @parent = null
  45. @order = 0
  46. @image = ''
  47. @description = ''
  48. @seo = {}
  49. @attributesConfig = {} # Конфигурация атрибутов для категории
  50. # Слайд главной страницы
  51. class HeroSlide extends DomainEntity
  52. constructor: ->
  53. super()
  54. @type = 'hero_slide'
  55. @title = ''
  56. @subtitle = ''
  57. @image = ''
  58. @buttonText = 'В каталог'
  59. @buttonLink = '/catalog'
  60. @order = 0
  61. @active = true
  62. # Настройки домена
  63. class DomainSettings extends DomainEntity
  64. constructor: ->
  65. super()
  66. @type = 'domain_settings'
  67. @domain = ''
  68. @companyName = ''
  69. @companyLogo = ''
  70. @languages = ['ru']
  71. @defaultLanguage = 'ru'
  72. @theme = 'light'
  73. @contacts = {}
  74. @seo = {}
  75. @social = {}
  76. @paymentMethods = []
  77. @shippingMethods = []
  78. # Пользователь
  79. class User extends DomainEntity
  80. constructor: ->
  81. super()
  82. @type = 'user'
  83. @username = ''
  84. @email = ''
  85. @role = 'user' # user, admin, manager
  86. @firstName = ''
  87. @lastName = ''
  88. @phone = ''
  89. @address = {}
  90. @orders = []
  91. @favorites = []
  92. @cart = []
  93. # Заказ
  94. class Order extends DomainEntity
  95. constructor: ->
  96. super()
  97. @type = 'order'
  98. @userId = ''
  99. @items = []
  100. @total = 0
  101. @status = 'pending' # pending, confirmed, shipped, delivered, cancelled
  102. @paymentStatus = 'pending'
  103. @shippingAddress = {}
  104. @billingAddress = {}
  105. @paymentMethod = ''
  106. @shippingMethod = ''
  107. @trackingNumber = ''
  108. @notes = ''
  109. module.exports = {
  110. DomainEntity,
  111. Product,
  112. Category,
  113. HeroSlide,
  114. DomainSettings,
  115. User,
  116. Order
  117. }