Topic.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use app\jobs\storeSync\DiyCommon;
  9. use yii\behaviors\TimestampBehavior;
  10. use Yii;
  11. use yii\db\ActiveRecord;
  12. /**
  13. * This is the model class for table "{{%topic}}".
  14. *
  15. * @property int $id
  16. * @property int $store_id
  17. * @property string $title 标题
  18. * @property string $sub_title 副标题
  19. * @property string|null $cover_pic 封面图片
  20. * @property string|null $content 专题内容
  21. * @property int $read_count 阅读量
  22. * @property int $virtual_read_count 虚拟阅读量
  23. * @property int $layout 布局方式:0=小图,1=大图模式
  24. * @property int $sort 排序:升序
  25. * @property int $agree_count 点赞数
  26. * @property int $virtual_agree_count 虚拟点赞数
  27. * @property int $virtual_favorite_count 虚拟收藏量
  28. * @property int|null $created_at 添加时间
  29. * @property int $is_delete 删除
  30. * @property int|null $is_chosen 精选(0、否;1、是)
  31. * @property int $type 专题分类
  32. * @property string|null $qrcode_pic 海报分享图
  33. * @property int|null $is_show 显示1
  34. * @property int|null $updated_at 更新时间
  35. */
  36. class Topic extends ActiveRecord
  37. {
  38. const IS_DELETE_YES = 1;//已删除
  39. const IS_DELETE_NO = 0;//未删除
  40. const IS_SHOW_YES = 1;//显示
  41. const IS_SHOW_NO = 0;//前台不显示
  42. const IS_CHOSEN_YES = 1;//精选
  43. const IS_CHOSEN_NO = 0;//不精选
  44. const LAYOUT_SMALL = 0; //小图
  45. const LAYOUT_LARGE = 1; //大图
  46. /**
  47. * {@inheritdoc}
  48. */
  49. public static function tableName()
  50. {
  51. return '{{%topic}}';
  52. }
  53. public function behaviors()
  54. {
  55. return [
  56. [
  57. 'class' => TimestampBehavior::class,
  58. 'attributes' => [
  59. ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
  60. ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
  61. ]
  62. ]
  63. ];
  64. }
  65. /**
  66. * {@inheritdoc}
  67. */
  68. public function rules()
  69. {
  70. return [
  71. [['store_id', 'type'], 'required'],
  72. [['store_id', 'read_count', 'virtual_read_count', 'layout', 'sort', 'agree_count', 'virtual_agree_count', 'virtual_favorite_count', 'created_at', 'is_delete', 'is_chosen', 'type', 'is_show', 'updated_at'], 'integer'],
  73. [['cover_pic', 'content', 'qrcode_pic'], 'string'],
  74. [['title', 'sub_title'], 'string', 'max' => 255],
  75. [['read_count', 'agree_count'], 'default', 'value' => 0],
  76. [['is_delete'], 'default', 'value' => self::IS_DELETE_NO]
  77. ];
  78. }
  79. /**
  80. * {@inheritdoc}
  81. */
  82. public function attributeLabels()
  83. {
  84. return [
  85. 'id' => 'ID',
  86. 'store_id' => 'Store ID',
  87. 'title' => '标题',
  88. 'sub_title' => '副标题',
  89. 'cover_pic' => '封面图片',
  90. 'content' => '专题内容',
  91. 'read_count' => '阅读量',
  92. 'virtual_read_count' => '虚拟阅读量',
  93. 'layout' => '布局方式:0=小图,1=大图模式',
  94. 'sort' => '排序:升序',
  95. 'agree_count' => '点赞数',
  96. 'virtual_agree_count' => '虚拟点赞数',
  97. 'virtual_favorite_count' => '虚拟收藏量',
  98. 'created_at' => '添加时间',
  99. 'is_delete' => '删除',
  100. 'is_chosen' => '精选(0、否;1、是)',
  101. 'type' => '专题分类',
  102. 'qrcode_pic' => '海报分享图',
  103. 'is_show' => '显示1',
  104. 'updated_at' => '更新时间'
  105. ];
  106. }
  107. public function afterSave($insert, $changedAttributes)
  108. {
  109. parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
  110. (new DiyCommon)->JobBehaviors($this->store_id, StoreSyncExtLog::TYPE_TOPIC);
  111. }
  112. }