Content.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { Collection, Model } from 'js-abstract-model'
  2. import { CelebrityList } from 'src/models/Celebrity.js'
  3. import { ContentCategory } from 'src/models/ContentCategory.js'
  4. import { ContentHashtagList } from 'src/models/ContentHashtag.js'
  5. class Content extends Model {
  6. constructor (data) {
  7. super(data, [
  8. { key: 'id' },
  9. { key: 'title' },
  10. { key: 'description' },
  11. { key: 'summary' },
  12. { key: 'thumbnail' },
  13. {
  14. key: 'is_free',
  15. defalut: false
  16. },
  17. {
  18. key: 'medias',
  19. defalut: []
  20. },
  21. {
  22. key: 'medias_info',
  23. defalut: []
  24. },
  25. { key: 'category' },
  26. {
  27. key: 'category_info',
  28. relatedModel: ContentCategory
  29. },
  30. {
  31. key: 'celebrities',
  32. relatedModel: CelebrityList
  33. },
  34. { key: 'hashtags' },
  35. {
  36. key: 'hashtags_info',
  37. relatedModel: ContentHashtagList
  38. }
  39. ])
  40. if (!this.thumbnail) {
  41. this.thumbnail = '/img/custom/Mask_group2.png'
  42. }
  43. }
  44. }
  45. class ContentList extends Collection {
  46. model () {
  47. return Content
  48. }
  49. }
  50. export { Content, ContentList }