| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?php
- /**
- * 厦门云联储网络科技有限公司
- * https://www.baokuaiyun.com
- * Copyright (c) 2023 爆块云 All rights reserved.
- */
- namespace app\models;
- use app\jobs\storeSync\DiyCommon;
- use yii\behaviors\TimestampBehavior;
- use Yii;
- use yii\db\ActiveRecord;
- /**
- * This is the model class for table "{{%topic}}".
- *
- * @property int $id
- * @property int $store_id
- * @property string $title 标题
- * @property string $sub_title 副标题
- * @property string|null $cover_pic 封面图片
- * @property string|null $content 专题内容
- * @property int $read_count 阅读量
- * @property int $virtual_read_count 虚拟阅读量
- * @property int $layout 布局方式:0=小图,1=大图模式
- * @property int $sort 排序:升序
- * @property int $agree_count 点赞数
- * @property int $virtual_agree_count 虚拟点赞数
- * @property int $virtual_favorite_count 虚拟收藏量
- * @property int|null $created_at 添加时间
- * @property int $is_delete 删除
- * @property int|null $is_chosen 精选(0、否;1、是)
- * @property int $type 专题分类
- * @property string|null $qrcode_pic 海报分享图
- * @property int|null $is_show 显示1
- * @property int|null $updated_at 更新时间
- */
- class Topic extends ActiveRecord
- {
-
- const IS_DELETE_YES = 1;//已删除
- const IS_DELETE_NO = 0;//未删除
- const IS_SHOW_YES = 1;//显示
- const IS_SHOW_NO = 0;//前台不显示
- const IS_CHOSEN_YES = 1;//精选
- const IS_CHOSEN_NO = 0;//不精选
- const LAYOUT_SMALL = 0; //小图
- const LAYOUT_LARGE = 1; //大图
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%topic}}';
- }
- public function behaviors()
- {
- return [
- [
- 'class' => TimestampBehavior::class,
- 'attributes' => [
- ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
- ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
- ]
- ]
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['store_id', 'type'], 'required'],
- [['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'],
- [['cover_pic', 'content', 'qrcode_pic'], 'string'],
- [['title', 'sub_title'], 'string', 'max' => 255],
- [['read_count', 'agree_count'], 'default', 'value' => 0],
- [['is_delete'], 'default', 'value' => self::IS_DELETE_NO]
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'store_id' => 'Store ID',
- 'title' => '标题',
- 'sub_title' => '副标题',
- 'cover_pic' => '封面图片',
- 'content' => '专题内容',
- 'read_count' => '阅读量',
- 'virtual_read_count' => '虚拟阅读量',
- 'layout' => '布局方式:0=小图,1=大图模式',
- 'sort' => '排序:升序',
- 'agree_count' => '点赞数',
- 'virtual_agree_count' => '虚拟点赞数',
- 'virtual_favorite_count' => '虚拟收藏量',
- 'created_at' => '添加时间',
- 'is_delete' => '删除',
- 'is_chosen' => '精选(0、否;1、是)',
- 'type' => '专题分类',
- 'qrcode_pic' => '海报分享图',
- 'is_show' => '显示1',
- 'updated_at' => '更新时间'
- ];
- }
- public function afterSave($insert, $changedAttributes)
- {
- parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
- (new DiyCommon)->JobBehaviors($this->store_id, StoreSyncExtLog::TYPE_TOPIC);
- }
- }
|