| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <?php
- /**
- * 厦门云联储网络科技有限公司
- * https://www.baokuaiyun.com
- * Copyright (c) 2023 爆块云 All rights reserved.
- */
- namespace app\models;
- use yii\behaviors\TimestampBehavior;
- /**
- * Class Storage
- * @package app\models
- * @property integer $id
- * @property integer $parent_id
- * @property string $name
- * @property string $mime
- * @property string $ext
- * @property integer $size
- * @property string $path
- * @property string $url
- * @property string $platform
- * @property integer $type
- * @property integer $created_at
- * @property integer $updated_at
- * @property integer $is_delete
- * @property integer $store_id
- * @property integer $mch_id
- * @property integer $supplier_id
- * @property integer $bd_id
- */
- class Storage extends \yii\db\ActiveRecord
- {
- const PLATFORM_LOCAL = 'local';
- const PLATFORM_ALIYUN = 'aliyun';
- const PLATFORM_QINIU = 'qiniu';
- const PLATFORM_QCLOUD = 'qcloud';
- const PLATFORMS = [
- self::PLATFORM_LOCAL => '本地',
- self::PLATFORM_ALIYUN => '阿里云',
- self::PLATFORM_QINIU => '七牛',
- self::PLATFORM_QCLOUD => '腾讯云',
- ];
- const TYPE_IMAGE = 0; // 图片
- const TYPE_VIDEO = 1; // 视频
- const TYPE_DIR = 2; // 目录
- const TYPE_XlSX = 3; // excel文件
- const TYPE_CRT = 4; // 证书文件
- const TYPE_APK = 5; // APP包
- const TYPE_PFX = 6; // PFX文件
- const TYPE_CER = 7; // CER文件
- const TYPE_PEM = 8; // PFX文件
- const STATUS_NORMAL = 0; // 正常
- const STATUS_DELETE = 1; // 删除
- const IMAGE_TYPE = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];
- const IMAGE_MIME = [
- 'image/jpeg',
- 'image/jpg',
- 'image/png',
- 'image/gif',
- 'image/bmp',
- 'image/webp',
- '', // 支付宝小程序上传图片获取不到mime
- ];
- const VIDEO_TYPE = ['mp4', 'flv', 'ogg', 'mov'];
- const VIDEO_MIME = [
- 'video/mp4',
- 'video/x-flv',
- 'video/ogg',
- 'video/quicktime'
- ];
- const XlSX_TYPE = ['xlsx'];
- const XlSX_MIME = [
- 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
- ];
- const CRT_TYPE = ['crt', 'cer'];
- const CRT_MIME = [
- 'application/x-x509-ca-cert'
- ];
- const APK_TYPE = ['apk'];
- const APK_MIME = [
- 'application/vnd.android.package-archive'
- ];
- const PFX_TYPE = ['pfx'];
- const PFX_MIME = [
- 'application/x-pkcs12'
- ];
- const PEM_TYPE = ['pem'];
- const PEM_MIME = [
- 'application/octet-stream',
- 'application/x-x509-ca-cert'
- ];
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%storage}}';
- }
- public function behaviors()
- {
- return [
- [
- // 自动更新创建和更新时间
- 'class' => TimestampBehavior::class,
- 'value' => time()
- ]
- ];
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['parent_id', 'size', 'type', 'created_at', 'updated_at', 'is_delete', 'store_id', 'mch_id', 'supplier_id', 'bd_id'], 'integer'],
- [['name', 'mime', 'ext', 'path', 'url', 'platform'], 'string'],
- [['name', 'path', 'url'], 'string', 'max' => 255],
- [['mime'], 'string', 'max' => 100],
- [['platform'], 'string', 'max' => 10],
- [['ext'], 'string', 'max' => 6],
- [['created_at', 'update_at'], 'safe']
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'parent_id' => '父级ID',
- 'name' => '文件别名',
- 'mime' => 'mime类型',
- 'ext' => '扩展名',
- 'size' => '文件大小',
- 'path' => '文件路径',
- 'url' => '文件url',
- 'platform' => '存储平台',
- 'type' => '类型',
- 'created_at' => '创建时间',
- 'updated_at' => '更新时间',
- 'is_delete' => '是否已删除',
- 'store_id' => '商城ID',
- 'mch_id' => '入驻商ID',
- 'supplier_id' => '供货商ID',
- 'bd_id' => '推广代理ID',
- ];
- }
- }
|