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:
xiaochong0302 2024-06-23 08:16:20 +08:00
parent 2b240678a9
commit ec700224a4
8 changed files with 5 additions and 104 deletions

View File

@ -1,44 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
namespace App\Caches;
use App\Repos\Stat as StatRepo;
class ModerationStat extends Cache
{
protected $lifetime = 15 * 60;
public function getLifetime()
{
return $this->lifetime;
}
public function getKey($id = null)
{
return 'moderation_stat';
}
public function getContent($id = null)
{
$statRepo = new StatRepo();
$articleCount = $statRepo->countPendingArticles();
$questionCount = $statRepo->countPendingQuestions();
$answerCount = $statRepo->countPendingAnswers();
$commentCount = $statRepo->countPendingComments();
return [
'article_count' => $articleCount,
'question_count' => $questionCount,
'answer_count' => $answerCount,
'comment_count' => $commentCount,
];
}
}

View File

@ -10,7 +10,7 @@ namespace App\Console\Tasks;
use App\Http\Admin\Services\Setting as SettingService;
use App\Library\Utils\Password as PasswordUtil;
use App\Models\ChapterVod as ChapterVodModel;
use App\Services\Utils\IndexCourseCache as IndexCourseCacheUtil;
use App\Services\Utils\IndexPageCache as IndexPageCacheUtil;
use App\Validators\Account as AccountValidator;
class MaintainTask extends Task
@ -26,7 +26,7 @@ class MaintainTask extends Task
{
$section = $params[0] ?? null;
$util = new IndexCourseCacheUtil();
$util = new IndexPageCacheUtil();
$util->rebuild($section);
@ -64,34 +64,6 @@ class MaintainTask extends Task
echo '------ reset password success ------' . PHP_EOL;
}
/**
* 关闭验证码
*
* @command: php console.php maintain disable_captcha
*/
public function disableCaptchaAction()
{
$service = new SettingService();
$service->updateSettings('captcha', ['enabled' => 0]);
echo '------ disable captcha success ------' . PHP_EOL;
}
/**
* 启用验证码
*
* @command: php console.php maintain enable_captcha
*/
public function enableCaptchaAction()
{
$service = new SettingService();
$service->updateSettings('captcha', ['enabled' => 1]);
echo '------ enable captcha success ------' . PHP_EOL;
}
/**
* 关闭站点
*

View File

@ -39,7 +39,7 @@ class Account extends Validator
$account = $accountRepo->findById($name);
}
if (!$account || $account->deleted == 1) {
if (!$account) {
throw new BadRequestException('account.not_found');
}

View File

@ -137,7 +137,7 @@ class Category extends Validator
return $status;
}
public function checkDeleteAbility($category)
public function checkDeleteAbility(CategoryModel $category)
{
$categoryRepo = new CategoryRepo();

View File

@ -42,19 +42,6 @@ class Comment extends Validator
return $comment;
}
public function checkToUser($userId)
{
$userRepo = new UserRepo();
$user = $userRepo->findById($userId);
if (!$user) {
throw new BadRequestException('comment.to_user_not_found');
}
return $user;
}
public function checkItem($itemId, $itemType)
{
if (!array_key_exists($itemType, CommentModel::itemTypes())) {

View File

@ -15,19 +15,6 @@ use App\Repos\CourseUser as CourseUserRepo;
class CourseUser extends Validator
{
public function checkRelation($id)
{
$courseUserRepo = new CourseUserRepo();
$courseUser = $courseUserRepo->findById($id);
if (!$courseUser) {
throw new BadRequestException('course_user.not_found');
}
return $courseUser;
}
public function checkCourseUser($courseId, $userId)
{
$repo = new CourseUserRepo();

View File

@ -116,7 +116,7 @@ class Nav extends Validator
return $status;
}
public function checkDeleteAbility($nav)
public function checkDeleteAbility(NavModel $nav)
{
$navRepo = new NavRepo();

View File

@ -160,7 +160,6 @@ $error['answer.delete_not_allowed'] = '当前不允许删除回答';
*/
$error['comment.not_found'] = '评论不存在';
$error['comment.parent_not_found'] = '上级评论不存在';
$error['comment.to_user_not_found'] = '回复用户不存在';
$error['comment.invalid_item_type'] = '无效的条目类型';
$error['comment.invalid_publish_status'] = '无效的发布状态';
$error['comment.invalid_reject_reason'] = '无效的拒绝理由';