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

Merge branch 'koogua/v1.7.3' into demo

This commit is contained in:
xiaochong0302 2024-09-22 07:13:29 +08:00
commit 592e61dc1f
18 changed files with 231 additions and 120 deletions

View File

@ -7,6 +7,7 @@
namespace App\Http\Admin\Controllers; namespace App\Http\Admin\Controllers;
use App\Http\Admin\Services\Upload as UploadService;
use App\Services\MyStorage as StorageService; use App\Services\MyStorage as StorageService;
use App\Services\Vod as VodService; use App\Services\Vod as VodService;
use App\Validators\Validator as AppValidator; use App\Validators\Validator as AppValidator;
@ -119,20 +120,25 @@ class UploadController extends Controller
*/ */
public function uploadDefaultImageAction() public function uploadDefaultImageAction()
{ {
$service = new StorageService(); $service = new UploadService();
$items = []; $items = [];
$items['category_icon'] = $service->uploadDefaultCategoryIcon();
$items['user_avatar'] = $service->uploadDefaultUserAvatar(); $items['user_avatar'] = $service->uploadDefaultUserAvatar();
$items['article_cover'] = $service->uploadDefaultArticleCover();
$items['course_cover'] = $service->uploadDefaultCourseCover(); $items['course_cover'] = $service->uploadDefaultCourseCover();
$items['package_cover'] = $service->uploadDefaultPackageCover(); $items['package_cover'] = $service->uploadDefaultPackageCover();
$items['topic_cover'] = $service->uploadDefaultTopicCover(); $items['topic_cover'] = $service->uploadDefaultTopicCover();
$items['slide_cover'] = $service->uploadDefaultSlideCover();
$items['gift_cover'] = $service->uploadDefaultGiftCover(); $items['gift_cover'] = $service->uploadDefaultGiftCover();
$items['vip_cover'] = $service->uploadDefaultVipCover(); $items['vip_cover'] = $service->uploadDefaultVipCover();
$items['category_icon'] = $service->uploadDefaultCategoryIcon();
foreach ($items as $item) { foreach ($items as $key => $item) {
if (!$item) return $this->jsonError(['msg' => '上传文件失败']); $msg = sprintf('上传文件失败: %s', $key);
if (!$item) {
return $this->jsonError(['msg' => $msg]);
}
} }
return $this->jsonSuccess(['msg' => '上传文件成功']); return $this->jsonSuccess(['msg' => '上传文件成功']);

View 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);
}
}

View File

@ -206,9 +206,6 @@ class User extends Service
if (!empty($post['vip_expiry_time'])) { if (!empty($post['vip_expiry_time'])) {
$data['vip_expiry_time'] = $validator->checkVipExpiryTime($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'])) { if (isset($post['locked'])) {
@ -217,9 +214,6 @@ class User extends Service
if (!empty($post['lock_expiry_time'])) { if (!empty($post['lock_expiry_time'])) {
$data['lock_expiry_time'] = $validator->checkLockExpiryTime($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; $oldAdminRole = $user->admin_role;

View File

@ -47,7 +47,7 @@
xmSelect.render({ xmSelect.render({
el: '#xm-tag-ids', el: '#xm-tag-ids',
name: 'xm_tag_ids', name: 'xm_tag_ids',
max: 3, max: 5,
filterable: true, filterable: true,
filterMethod: function (val, item, index, prop) { filterMethod: function (val, item, index, prop) {
return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1; return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1;

View File

@ -46,7 +46,7 @@
xmSelect.render({ xmSelect.render({
el: '#xm-tag-ids', el: '#xm-tag-ids',
name: 'xm_tag_ids', name: 'xm_tag_ids',
max: 3, max: 5,
filterable: true, filterable: true,
filterMethod: function (val, item, index, prop) { filterMethod: function (val, item, index, prop) {
return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1; return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1;

View File

@ -141,6 +141,10 @@
<td>礼品封面</td> <td>礼品封面</td>
<td>public/static/admin/img/default/gift_cover.png</td> <td>public/static/admin/img/default/gift_cover.png</td>
</tr> </tr>
<tr>
<td>轮播封面</td>
<td>public/static/admin/img/default/slide_cover.png</td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@ -16,7 +16,7 @@ class AppInfo
protected $link = 'https://www.koogua.com'; protected $link = 'https://www.koogua.com';
protected $version = '1.7.2'; protected $version = '1.7.3';
public function __get($name) public function __get($name)
{ {

View File

@ -22,6 +22,7 @@ class UserSession extends Repository
{ {
return UserSessionModel::query() return UserSessionModel::query()
->where('user_id = :user_id:', ['user_id' => $userId]) ->where('user_id = :user_id:', ['user_id' => $userId])
->andWhere('expire_time < :time:', ['time' => time()])
->andWhere('deleted = 0') ->andWhere('deleted = 0')
->execute(); ->execute();
} }

View File

@ -22,6 +22,8 @@ class UserToken extends Repository
{ {
return UserTokenModel::query() return UserTokenModel::query()
->where('user_id = :user_id:', ['user_id' => $userId]) ->where('user_id = :user_id:', ['user_id' => $userId])
->andWhere('expire_time < :time:', ['time' => time()])
->andWhere('deleted = 0')
->execute(); ->execute();
} }

View File

@ -98,7 +98,6 @@ class Api extends AuthService
$cache = $this->getCache(); $cache = $this->getCache();
foreach ($userTokens as $record) { foreach ($userTokens as $record) {
$record->delete();
$key = $this->getTokenCacheKey($record->token); $key = $this->getTokenCacheKey($record->token);
$cache->delete($key); $cache->delete($key);
} }
@ -114,7 +113,6 @@ class Api extends AuthService
foreach ($userTokens as $record) { foreach ($userTokens as $record) {
if ($record->client_type == $clientType) { if ($record->client_type == $clientType) {
$record->delete();
$key = $this->getTokenCacheKey($record->token); $key = $this->getTokenCacheKey($record->token);
$cache->delete($key); $cache->delete($key);
} }

View File

@ -68,7 +68,6 @@ class Home extends AuthService
if ($records->count() == 0) return; if ($records->count() == 0) return;
foreach ($records as $record) { foreach ($records as $record) {
$record->delete();
$key = $this->getSessionCacheKey($record->session_id); $key = $this->getSessionCacheKey($record->session_id);
$cache->delete($key); $cache->delete($key);
} }

View File

@ -11,6 +11,7 @@ use App\Library\Utils\FileInfo;
use App\Models\Upload as UploadModel; use App\Models\Upload as UploadModel;
use App\Repos\Upload as UploadRepo; use App\Repos\Upload as UploadRepo;
use InvalidArgumentException; use InvalidArgumentException;
use RuntimeException;
class MyStorage extends Storage class MyStorage extends Storage
{ {
@ -36,104 +37,6 @@ class MyStorage extends Storage
return $this->putString($key, $value); 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()); $path = $this->putFile($keyName, $file->getTempName());
if (!$path) {
throw new RuntimeException('Upload File Failed');
}
$upload = new UploadModel(); $upload = new UploadModel();
$upload->name = $name; $upload->name = $name;

View File

@ -184,11 +184,18 @@ class Account extends Validator
public function checkIfAllowLogin(UserModel $user) public function checkIfAllowLogin(UserModel $user)
{ {
$case1 = $user->locked == 1; $locked = false;
$case2 = $user->lock_expiry_time > time();
if ($case1 && $case2) { if ($user->locked == 1) {
throw new ForbiddenException('account.locked'); if ($user->lock_expiry_time == 0) {
$locked = true;
} elseif ($user->lock_expiry_time > time()) {
$locked = true;
}
}
if ($locked) {
throw new BadRequestException('account.locked');
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -2,6 +2,9 @@ layui.use(['jquery'], function () {
var $ = layui.jquery; var $ = layui.jquery;
var $textarea = $('#editor-textarea');
var $form = $('form:has(#editor-textarea)');
var editor; var editor;
var options = { var options = {
@ -40,8 +43,25 @@ layui.use(['jquery'], function () {
editor = K.create('#editor-textarea', options); editor = K.create('#editor-textarea', options);
}); });
/**
* 同步编辑器内容到表单
*/
$('.kg-submit').on('click', function () { $('.kg-submit').on('click', function () {
editor.sync(); editor.sync();
}); });
/**
* 定时提交编辑器内容
*/
setInterval(function () {
editor.sync();
if ($textarea.val().length > 30) {
$.ajax({
type: 'POST',
url: $form.attr('action'),
data: $form.serialize(),
});
}
}, 15000);
}); });

View File

@ -2,6 +2,9 @@ layui.use(['jquery'], function () {
var $ = layui.jquery; var $ = layui.jquery;
var $textarea = $('#editor-textarea');
var $form = $('form:has(#editor-textarea)');
var editor; var editor;
var options = { var options = {
@ -38,8 +41,25 @@ layui.use(['jquery'], function () {
editor = K.create('#editor-textarea', options); editor = K.create('#editor-textarea', options);
}); });
/**
* 同步编辑器内容到表单
*/
$('.kg-submit').on('click', function () { $('.kg-submit').on('click', function () {
editor.sync(); 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