mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-24 12:05:39 +08:00
Merge branch 'koogua/v1.7.3' into demo
This commit is contained in:
commit
592e61dc1f
@ -7,6 +7,7 @@
|
||||
|
||||
namespace App\Http\Admin\Controllers;
|
||||
|
||||
use App\Http\Admin\Services\Upload as UploadService;
|
||||
use App\Services\MyStorage as StorageService;
|
||||
use App\Services\Vod as VodService;
|
||||
use App\Validators\Validator as AppValidator;
|
||||
@ -119,20 +120,25 @@ class UploadController extends Controller
|
||||
*/
|
||||
public function uploadDefaultImageAction()
|
||||
{
|
||||
$service = new StorageService();
|
||||
$service = new UploadService();
|
||||
|
||||
$items = [];
|
||||
|
||||
$items['category_icon'] = $service->uploadDefaultCategoryIcon();
|
||||
$items['user_avatar'] = $service->uploadDefaultUserAvatar();
|
||||
$items['article_cover'] = $service->uploadDefaultArticleCover();
|
||||
$items['course_cover'] = $service->uploadDefaultCourseCover();
|
||||
$items['package_cover'] = $service->uploadDefaultPackageCover();
|
||||
$items['topic_cover'] = $service->uploadDefaultTopicCover();
|
||||
$items['slide_cover'] = $service->uploadDefaultSlideCover();
|
||||
$items['gift_cover'] = $service->uploadDefaultGiftCover();
|
||||
$items['vip_cover'] = $service->uploadDefaultVipCover();
|
||||
$items['category_icon'] = $service->uploadDefaultCategoryIcon();
|
||||
|
||||
foreach ($items as $item) {
|
||||
if (!$item) return $this->jsonError(['msg' => '上传文件失败']);
|
||||
foreach ($items as $key => $item) {
|
||||
$msg = sprintf('上传文件失败: %s', $key);
|
||||
if (!$item) {
|
||||
return $this->jsonError(['msg' => $msg]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->jsonSuccess(['msg' => '上传文件成功']);
|
||||
|
153
app/Http/Admin/Services/Upload.php
Normal file
153
app/Http/Admin/Services/Upload.php
Normal file
@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Http\Admin\Services;
|
||||
|
||||
|
||||
use App\Services\MyStorage;
|
||||
|
||||
class Upload extends Service
|
||||
{
|
||||
|
||||
/**
|
||||
* @var MyStorage
|
||||
*/
|
||||
protected $storage;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->storage = new MyStorage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传默认用户头像
|
||||
*
|
||||
* @return false|mixed|string
|
||||
*/
|
||||
public function uploadDefaultUserAvatar()
|
||||
{
|
||||
$filename = static_path('admin/img/default/user_avatar.png');
|
||||
|
||||
$key = '/img/default/user_avatar.png';
|
||||
|
||||
return $this->storage->putFile($key, $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传默认课程封面
|
||||
*
|
||||
* @return false|mixed|string
|
||||
*/
|
||||
public function uploadDefaultCourseCover()
|
||||
{
|
||||
$filename = static_path('admin/img/default/course_cover.png');
|
||||
|
||||
$key = '/img/default/course_cover.png';
|
||||
|
||||
return $this->storage->putFile($key, $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传默认套餐封面
|
||||
*
|
||||
* @return false|mixed|string
|
||||
*/
|
||||
public function uploadDefaultPackageCover()
|
||||
{
|
||||
$filename = static_path('admin/img/default/package_cover.png');
|
||||
|
||||
$key = '/img/default/package_cover.png';
|
||||
|
||||
return $this->storage->putFile($key, $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传默认话题封面
|
||||
*
|
||||
* @return false|mixed|string
|
||||
*/
|
||||
public function uploadDefaultTopicCover()
|
||||
{
|
||||
$filename = static_path('admin/img/default/topic_cover.png');
|
||||
|
||||
$key = '/img/default/topic_cover.png';
|
||||
|
||||
return $this->storage->putFile($key, $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传默认会员封面
|
||||
*
|
||||
* @return false|mixed|string
|
||||
*/
|
||||
public function uploadDefaultVipCover()
|
||||
{
|
||||
$filename = static_path('admin/img/default/vip_cover.png');
|
||||
|
||||
$key = '/img/default/vip_cover.png';
|
||||
|
||||
return $this->storage->putFile($key, $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传默认专栏封面
|
||||
*
|
||||
* @return false|mixed|string
|
||||
*/
|
||||
public function uploadDefaultArticleCover()
|
||||
{
|
||||
$filename = static_path('admin/img/default/article_cover.png');
|
||||
|
||||
$key = '/img/default/article_cover.png';
|
||||
|
||||
return $this->storage->putFile($key, $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传默认礼品封面
|
||||
*
|
||||
* @return false|mixed|string
|
||||
*/
|
||||
public function uploadDefaultGiftCover()
|
||||
{
|
||||
$filename = static_path('admin/img/default/gift_cover.png');
|
||||
|
||||
$key = '/img/default/gift_cover.png';
|
||||
|
||||
return $this->storage->putFile($key, $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传默认轮播图片
|
||||
*
|
||||
* @return false|mixed|string
|
||||
*/
|
||||
public function uploadDefaultSlideCover()
|
||||
{
|
||||
$filename = static_path('admin/img/default/slide_cover.png');
|
||||
|
||||
$key = '/img/default/slide_cover.png';
|
||||
|
||||
return $this->storage->putFile($key, $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传默认分类图标
|
||||
*
|
||||
* @return false|mixed|string
|
||||
*/
|
||||
public function uploadDefaultCategoryIcon()
|
||||
{
|
||||
$filename = static_path('admin/img/default/category_icon.png');
|
||||
|
||||
$key = '/img/default/category_icon.png';
|
||||
|
||||
return $this->storage->putFile($key, $filename);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -206,9 +206,6 @@ class User extends Service
|
||||
|
||||
if (!empty($post['vip_expiry_time'])) {
|
||||
$data['vip_expiry_time'] = $validator->checkVipExpiryTime($post['vip_expiry_time']);
|
||||
if ($data['vip_expiry_time'] < time()) {
|
||||
$data['vip'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($post['locked'])) {
|
||||
@ -217,9 +214,6 @@ class User extends Service
|
||||
|
||||
if (!empty($post['lock_expiry_time'])) {
|
||||
$data['lock_expiry_time'] = $validator->checkLockExpiryTime($post['lock_expiry_time']);
|
||||
if ($data['lock_expiry_time'] < time()) {
|
||||
$data['locked'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$oldAdminRole = $user->admin_role;
|
||||
|
@ -47,7 +47,7 @@
|
||||
xmSelect.render({
|
||||
el: '#xm-tag-ids',
|
||||
name: 'xm_tag_ids',
|
||||
max: 3,
|
||||
max: 5,
|
||||
filterable: true,
|
||||
filterMethod: function (val, item, index, prop) {
|
||||
return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1;
|
||||
|
@ -46,7 +46,7 @@
|
||||
xmSelect.render({
|
||||
el: '#xm-tag-ids',
|
||||
name: 'xm_tag_ids',
|
||||
max: 3,
|
||||
max: 5,
|
||||
filterable: true,
|
||||
filterMethod: function (val, item, index, prop) {
|
||||
return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1;
|
||||
|
@ -141,6 +141,10 @@
|
||||
<td>礼品封面</td>
|
||||
<td>public/static/admin/img/default/gift_cover.png</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>轮播封面</td>
|
||||
<td>public/static/admin/img/default/slide_cover.png</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
@ -16,7 +16,7 @@ class AppInfo
|
||||
|
||||
protected $link = 'https://www.koogua.com';
|
||||
|
||||
protected $version = '1.7.2';
|
||||
protected $version = '1.7.3';
|
||||
|
||||
public function __get($name)
|
||||
{
|
||||
|
@ -22,6 +22,7 @@ class UserSession extends Repository
|
||||
{
|
||||
return UserSessionModel::query()
|
||||
->where('user_id = :user_id:', ['user_id' => $userId])
|
||||
->andWhere('expire_time < :time:', ['time' => time()])
|
||||
->andWhere('deleted = 0')
|
||||
->execute();
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ class UserToken extends Repository
|
||||
{
|
||||
return UserTokenModel::query()
|
||||
->where('user_id = :user_id:', ['user_id' => $userId])
|
||||
->andWhere('expire_time < :time:', ['time' => time()])
|
||||
->andWhere('deleted = 0')
|
||||
->execute();
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,6 @@ class Api extends AuthService
|
||||
$cache = $this->getCache();
|
||||
|
||||
foreach ($userTokens as $record) {
|
||||
$record->delete();
|
||||
$key = $this->getTokenCacheKey($record->token);
|
||||
$cache->delete($key);
|
||||
}
|
||||
@ -114,7 +113,6 @@ class Api extends AuthService
|
||||
|
||||
foreach ($userTokens as $record) {
|
||||
if ($record->client_type == $clientType) {
|
||||
$record->delete();
|
||||
$key = $this->getTokenCacheKey($record->token);
|
||||
$cache->delete($key);
|
||||
}
|
||||
|
@ -68,7 +68,6 @@ class Home extends AuthService
|
||||
if ($records->count() == 0) return;
|
||||
|
||||
foreach ($records as $record) {
|
||||
$record->delete();
|
||||
$key = $this->getSessionCacheKey($record->session_id);
|
||||
$cache->delete($key);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ use App\Library\Utils\FileInfo;
|
||||
use App\Models\Upload as UploadModel;
|
||||
use App\Repos\Upload as UploadRepo;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
|
||||
class MyStorage extends Storage
|
||||
{
|
||||
@ -36,104 +37,6 @@ class MyStorage extends Storage
|
||||
return $this->putString($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传默认用户头像
|
||||
*
|
||||
* @return false|mixed|string
|
||||
*/
|
||||
public function uploadDefaultUserAvatar()
|
||||
{
|
||||
$filename = static_path('admin/img/default/user_avatar.png');
|
||||
|
||||
$key = '/img/default/user_avatar.png';
|
||||
|
||||
return $this->putFile($key, $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传默认课程封面
|
||||
*
|
||||
* @return false|mixed|string
|
||||
*/
|
||||
public function uploadDefaultCourseCover()
|
||||
{
|
||||
$filename = static_path('admin/img/default/course_cover.png');
|
||||
|
||||
$key = '/img/default/course_cover.png';
|
||||
|
||||
return $this->putFile($key, $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传默认套餐封面
|
||||
*
|
||||
* @return false|mixed|string
|
||||
*/
|
||||
public function uploadDefaultPackageCover()
|
||||
{
|
||||
$filename = static_path('admin/img/default/package_cover.png');
|
||||
|
||||
$key = '/img/default/package_cover.png';
|
||||
|
||||
return $this->putFile($key, $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传默认话题封面
|
||||
*
|
||||
* @return false|mixed|string
|
||||
*/
|
||||
public function uploadDefaultTopicCover()
|
||||
{
|
||||
$filename = static_path('admin/img/default/topic_cover.png');
|
||||
|
||||
$key = '/img/default/topic_cover.png';
|
||||
|
||||
return $this->putFile($key, $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传默认会员封面
|
||||
*
|
||||
* @return false|mixed|string
|
||||
*/
|
||||
public function uploadDefaultVipCover()
|
||||
{
|
||||
$filename = static_path('admin/img/default/vip_cover.png');
|
||||
|
||||
$key = '/img/default/vip_cover.png';
|
||||
|
||||
return $this->putFile($key, $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传默认礼品封面
|
||||
*
|
||||
* @return false|mixed|string
|
||||
*/
|
||||
public function uploadDefaultGiftCover()
|
||||
{
|
||||
$filename = static_path('admin/img/default/gift_cover.png');
|
||||
|
||||
$key = '/img/default/gift_cover.png';
|
||||
|
||||
return $this->putFile($key, $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传分类默认图标
|
||||
*
|
||||
* @return false|mixed|string
|
||||
*/
|
||||
public function uploadDefaultCategoryIcon()
|
||||
{
|
||||
$filename = static_path('admin/img/default/category_icon.png');
|
||||
|
||||
$key = '/img/default/category_icon.png';
|
||||
|
||||
return $this->putFile($key, $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传封面图片
|
||||
*
|
||||
@ -218,6 +121,10 @@ class MyStorage extends Storage
|
||||
|
||||
$path = $this->putFile($keyName, $file->getTempName());
|
||||
|
||||
if (!$path) {
|
||||
throw new RuntimeException('Upload File Failed');
|
||||
}
|
||||
|
||||
$upload = new UploadModel();
|
||||
|
||||
$upload->name = $name;
|
||||
|
@ -184,11 +184,18 @@ class Account extends Validator
|
||||
|
||||
public function checkIfAllowLogin(UserModel $user)
|
||||
{
|
||||
$case1 = $user->locked == 1;
|
||||
$case2 = $user->lock_expiry_time > time();
|
||||
$locked = false;
|
||||
|
||||
if ($case1 && $case2) {
|
||||
throw new ForbiddenException('account.locked');
|
||||
if ($user->locked == 1) {
|
||||
if ($user->lock_expiry_time == 0) {
|
||||
$locked = true;
|
||||
} elseif ($user->lock_expiry_time > time()) {
|
||||
$locked = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($locked) {
|
||||
throw new BadRequestException('account.locked');
|
||||
}
|
||||
}
|
||||
|
||||
|
BIN
public/static/admin/img/default/article_cover.png
Normal file
BIN
public/static/admin/img/default/article_cover.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
@ -2,6 +2,9 @@ layui.use(['jquery'], function () {
|
||||
|
||||
var $ = layui.jquery;
|
||||
|
||||
var $textarea = $('#editor-textarea');
|
||||
var $form = $('form:has(#editor-textarea)');
|
||||
|
||||
var editor;
|
||||
|
||||
var options = {
|
||||
@ -40,8 +43,25 @@ layui.use(['jquery'], function () {
|
||||
editor = K.create('#editor-textarea', options);
|
||||
});
|
||||
|
||||
/**
|
||||
* 同步编辑器内容到表单
|
||||
*/
|
||||
$('.kg-submit').on('click', function () {
|
||||
editor.sync();
|
||||
});
|
||||
|
||||
/**
|
||||
* 定时提交编辑器内容
|
||||
*/
|
||||
setInterval(function () {
|
||||
editor.sync();
|
||||
if ($textarea.val().length > 30) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: $form.attr('action'),
|
||||
data: $form.serialize(),
|
||||
});
|
||||
}
|
||||
}, 15000);
|
||||
|
||||
});
|
@ -2,6 +2,9 @@ layui.use(['jquery'], function () {
|
||||
|
||||
var $ = layui.jquery;
|
||||
|
||||
var $textarea = $('#editor-textarea');
|
||||
var $form = $('form:has(#editor-textarea)');
|
||||
|
||||
var editor;
|
||||
|
||||
var options = {
|
||||
@ -38,8 +41,25 @@ layui.use(['jquery'], function () {
|
||||
editor = K.create('#editor-textarea', options);
|
||||
});
|
||||
|
||||
/**
|
||||
* 同步编辑器内容到表单
|
||||
*/
|
||||
$('.kg-submit').on('click', function () {
|
||||
editor.sync();
|
||||
});
|
||||
|
||||
/**
|
||||
* 定时提交编辑器内容
|
||||
*/
|
||||
setInterval(function () {
|
||||
editor.sync();
|
||||
if ($textarea.val().length > 30) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: $form.attr('action'),
|
||||
data: $form.serialize(),
|
||||
});
|
||||
}
|
||||
}, 15000);
|
||||
|
||||
});
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user