mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-07-23 00:16:39 +08:00
新增课时资源结构
This commit is contained in:
parent
e4bf021203
commit
8f6c3eb3e5
@ -62,7 +62,7 @@ class Setting extends Service
|
||||
*/
|
||||
if ($items->count() > 0) {
|
||||
foreach ($items as $item) {
|
||||
$case1 = preg_match('/(id|auth|key|secret|pass|pwd)/', $item->item_key);
|
||||
$case1 = preg_match('/(id|auth|key|secret|password|pwd)$/', $item->item_key);
|
||||
$case2 = $this->dispatcher->getControllerName() == 'setting';
|
||||
if ($case1 && $case2) {
|
||||
$item->item_value = '***';
|
||||
|
@ -160,6 +160,13 @@ class Chapter extends Model
|
||||
*/
|
||||
public $like_count;
|
||||
|
||||
/**
|
||||
* 资源数
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $res_count;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*
|
||||
|
86
app/Models/ChapterResource.php
Normal file
86
app/Models/ChapterResource.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
|
||||
class ChapterResource extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* 主键编号
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* 课程编号
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $course_id;
|
||||
|
||||
/**
|
||||
* 章节编号
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $chapter_id;
|
||||
|
||||
/**
|
||||
* 上传编号
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $upload_id;
|
||||
|
||||
/**
|
||||
* 删除标识
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $deleted;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $create_time;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_chapter_resource';
|
||||
}
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
$this->addBehavior(
|
||||
new SoftDelete([
|
||||
'field' => 'deleted',
|
||||
'value' => 1,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
public function beforeCreate()
|
||||
{
|
||||
$this->create_time = time();
|
||||
}
|
||||
|
||||
public function beforeUpdate()
|
||||
{
|
||||
$this->update_time = time();
|
||||
}
|
||||
|
||||
}
|
@ -221,6 +221,13 @@ class Course extends Model
|
||||
*/
|
||||
public $favorite_count;
|
||||
|
||||
/**
|
||||
* 资源数
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $res_count;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*
|
||||
|
@ -7,6 +7,16 @@ use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
class Upload extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* 资源类型
|
||||
*/
|
||||
const TYPE_COVER_IMG = 1; // 封面图
|
||||
const TYPE_CONTENT_IMG = 2; // 内容图
|
||||
const TYPE_AVATAR_IMG = 3; // 头像
|
||||
const TYPE_COURSE_RES = 4; // 课件资源
|
||||
const TYPE_IM_IMG = 5; // IM图片
|
||||
const TYPE_IM_FILE = 6; // IM文件
|
||||
|
||||
/**
|
||||
* 主键编号
|
||||
*
|
||||
@ -49,6 +59,13 @@ class Upload extends Model
|
||||
*/
|
||||
public $size;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* 删除标识
|
||||
*
|
||||
|
@ -10,12 +10,12 @@ class MyStorage extends Storage
|
||||
{
|
||||
|
||||
/**
|
||||
* 文件类型
|
||||
* mime类型
|
||||
*/
|
||||
const TYPE_IMAGE = 'image';
|
||||
const TYPE_VIDEO = 'video';
|
||||
const TYPE_AUDIO = 'audio';
|
||||
const TYPE_FILE = 'file';
|
||||
const MIME_IMAGE = 'image';
|
||||
const MIME_VIDEO = 'video';
|
||||
const MIME_AUDIO = 'audio';
|
||||
const MIME_FILE = 'file';
|
||||
|
||||
public function uploadTestFile()
|
||||
{
|
||||
@ -50,7 +50,7 @@ class MyStorage extends Storage
|
||||
*/
|
||||
public function uploadCoverImage()
|
||||
{
|
||||
return $this->upload('/img/cover/', self::TYPE_IMAGE);
|
||||
return $this->upload('/img/cover/', self::MIME_IMAGE, UploadModel::TYPE_COVER_IMG);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,7 +60,7 @@ class MyStorage extends Storage
|
||||
*/
|
||||
public function uploadContentImage()
|
||||
{
|
||||
return $this->upload('/img/content/', self::TYPE_IMAGE);
|
||||
return $this->upload('/img/content/', self::MIME_IMAGE, UploadModel::TYPE_CONTENT_IMG);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,7 +70,17 @@ class MyStorage extends Storage
|
||||
*/
|
||||
public function uploadAvatarImage()
|
||||
{
|
||||
return $this->upload('/img/avatar/', self::TYPE_IMAGE);
|
||||
return $this->upload('/img/avatar/', self::MIME_IMAGE, UploadModel::TYPE_AVATAR_IMG);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传课件资源
|
||||
*
|
||||
* @return UploadModel|bool
|
||||
*/
|
||||
public function uploadCourseResource()
|
||||
{
|
||||
return $this->upload('/res/course/', self::MIME_FILE, UploadModel::TYPE_COURSE_RES);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,7 +90,7 @@ class MyStorage extends Storage
|
||||
*/
|
||||
public function uploadImImage()
|
||||
{
|
||||
return $this->upload('/im/img/', self::TYPE_IMAGE);
|
||||
return $this->upload('/im/img/', self::MIME_IMAGE, UploadModel::TYPE_IM_IMG);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,17 +98,18 @@ class MyStorage extends Storage
|
||||
*/
|
||||
public function uploadImFile()
|
||||
{
|
||||
return $this->upload('/im/file/', self::TYPE_FILE);
|
||||
return $this->upload('/im/file/', self::MIME_FILE, UploadModel::TYPE_IM_FILE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param string $prefix
|
||||
* @param string $type
|
||||
* @param string $mimeType
|
||||
* @param string $uploadType
|
||||
* @return UploadModel|bool
|
||||
*/
|
||||
protected function upload($prefix = '', $type = self::TYPE_IMAGE)
|
||||
protected function upload($prefix, $mimeType, $uploadType)
|
||||
{
|
||||
$list = [];
|
||||
|
||||
@ -110,7 +121,7 @@ class MyStorage extends Storage
|
||||
|
||||
foreach ($files as $file) {
|
||||
|
||||
if ($this->checkFile($file->getRealType(), $type) == false) {
|
||||
if ($this->checkFile($file->getRealType(), $mimeType) == false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -131,6 +142,7 @@ class MyStorage extends Storage
|
||||
$upload->name = $name;
|
||||
$upload->mime = $file->getRealType();
|
||||
$upload->size = $file->getSize();
|
||||
$upload->type = $uploadType;
|
||||
$upload->path = $path;
|
||||
$upload->md5 = $md5;
|
||||
|
||||
@ -148,19 +160,19 @@ class MyStorage extends Storage
|
||||
* 检查上传文件
|
||||
*
|
||||
* @param string $mime
|
||||
* @param string $type
|
||||
* @param string $alias
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkFile($mime, $type)
|
||||
protected function checkFile($mime, $alias)
|
||||
{
|
||||
switch ($type) {
|
||||
case self::TYPE_IMAGE:
|
||||
switch ($alias) {
|
||||
case self::MIME_IMAGE:
|
||||
$result = FileInfo::isImage($mime);
|
||||
break;
|
||||
case self::TYPE_VIDEO:
|
||||
case self::MIME_VIDEO:
|
||||
$result = FileInfo::isVideo($mime);
|
||||
break;
|
||||
case self::TYPE_AUDIO:
|
||||
case self::MIME_AUDIO:
|
||||
$result = FileInfo::isAudio($mime);
|
||||
break;
|
||||
default:
|
||||
|
@ -21,11 +21,6 @@ class AlipayGateway extends Service
|
||||
$this->settings = array_merge($defaults, $options);
|
||||
}
|
||||
|
||||
public function getSettings()
|
||||
{
|
||||
return $this->settings;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->settings['return_url'] = $returnUrl;
|
||||
|
@ -21,11 +21,6 @@ class WxpayGateway extends Service
|
||||
$this->settings = array_merge($defaults, $options);
|
||||
}
|
||||
|
||||
public function getSettings()
|
||||
{
|
||||
return $this->settings;
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->settings['notify_url'] = $notifyUrl;
|
||||
|
File diff suppressed because it is too large
Load Diff
22137
db/migrations/schema.php
22137
db/migrations/schema.php
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user