1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-24 20:06:09 +08:00

修正封面问题

This commit is contained in:
koogua 2021-03-20 17:34:20 +08:00
parent 418393f45a
commit 3bb613b2b3
8 changed files with 46 additions and 28 deletions

View File

@ -4,7 +4,10 @@
- 增加限时秒杀功能
- 更新phinx默认环境配置项
- 重构轮播图数据结构
- 优化存储相关命名以及逻辑
- 重构轮播图表结构
- 重构套餐数表结构
- 重构会员表结构
- 重构xm-select插件选取内容方式
- 整理UI展现形式

View File

@ -11,7 +11,7 @@ class AppInfo
protected $link = 'https://koogua.com';
protected $version = '1.2.8';
protected $version = '1.2.9';
public function __get($name)
{

View File

@ -293,7 +293,7 @@ class Course extends Model
}
if (empty($this->cover)) {
$this->cover = kg_default_cover_path();
$this->cover = kg_default_course_cover_path();
} elseif (Text::startsWith($this->cover, 'http')) {
$this->cover = self::getCoverPath($this->cover);
}

View File

@ -106,7 +106,7 @@ class Package extends Model
public function beforeCreate()
{
if (empty($this->cover)) {
$this->cover = kg_default_cover_path();
$this->cover = kg_default_package_cover_path();
} elseif (Text::startsWith($this->cover, 'http')) {
$this->cover = self::getCoverPath($this->cover);
}

View File

@ -167,7 +167,7 @@ class PointGift extends Model
}
if (empty($this->cover)) {
$this->cover = kg_default_cover_path();
$this->cover = kg_default_gift_cover_path();
} elseif (Text::startsWith($this->cover, 'http')) {
$this->cover = self::getCoverPath($this->cover);
}

View File

@ -179,7 +179,7 @@ class User extends Model
public function beforeCreate()
{
if (empty($this->avatar)) {
$this->avatar = kg_default_avatar_path();
$this->avatar = kg_default_user_avatar_path();
} elseif (Text::startsWith($this->avatar, 'http')) {
$this->avatar = self::getAvatarPath($this->avatar);
}

View File

@ -248,10 +248,11 @@ class Storage extends Service
*/
protected function generateFileName($extension = '', $prefix = '')
{
$randDir = date('Y') . '/' . date('m') . '/';
$randName = date('YmdHis') . rand(100, 999) . rand(100, 999);
$dir = date('Y') . '/' . date('m') . '/';
return $prefix . $randDir . $randName . '.' . $extension;
$name = uniqid();
return sprintf('%s%s%s.%s', $prefix, $dir, $name, $extension);
}
/**

View File

@ -143,6 +143,18 @@ class Schema202103141300 extends Phinx\Migration\AbstractMigration
])
->save();
$this->table('kg_package')
->addColumn('cover', 'string', [
'null' => false,
'default' => '',
'limit' => 100,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'comment' => '封面',
'after' => 'title',
])
->save();
$this->table('kg_vip')
->addColumn('cover', 'string', [
'null' => false,
@ -191,8 +203,9 @@ class Schema202103141300 extends Phinx\Migration\AbstractMigration
$this->handleSlideTargetAttrs();
$this->handleVipCover();
$this->handlePackageCover();
$this->handleVipCover();
}
public function down()
@ -204,6 +217,10 @@ class Schema202103141300 extends Phinx\Migration\AbstractMigration
->removeColumn('target_attrs')
->save();
$this->table('kg_package')
->removeColumn('cover')
->save();
$this->table('kg_vip')
->removeColumn('cover')
->save();
@ -282,18 +299,24 @@ class Schema202103141300 extends Phinx\Migration\AbstractMigration
}
}
protected function handlePackageCover()
{
$cover = '/img/default/package_cover.png';
$this->getQueryBuilder()
->update('kg_package')
->set('cover', $cover)
->execute();
}
protected function handleVipCover()
{
$vips = $this->getQueryBuilder()
->select('*')
->from('kg_vip')
$cover = '/img/default/vip_cover.png';
$this->getQueryBuilder()
->update('kg_vip')
->set('cover', $cover)
->execute();
if ($vips->count() == 0) return;
foreach ($vips as $vip) {
$this->updateVipCover($vip['id'], '/img/default/vip_cover.png');
}
}
protected function findCourseById($id)
@ -325,13 +348,4 @@ class Schema202103141300 extends Phinx\Migration\AbstractMigration
->execute();
}
protected function updateVipCover($id, $cover)
{
$this->getQueryBuilder()
->update('kg_vip')
->set('cover', $cover)
->where(['id' => $id])
->execute();
}
}