From 1a15ad58c98dec14f723ac3d8c49ac1f44ff8712 Mon Sep 17 00:00:00 2001
From: koogua
Date: Thu, 13 May 2021 17:50:39 +0800
Subject: [PATCH] =?UTF-8?q?=E9=98=B6=E6=AE=B5=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CHANGELOG.md | 8 +-
...cleHotAuthorList.php => TopAuthorList.php} | 4 +-
app/Console/Tasks/RevokeVipTask.php | 2 +-
app/Console/Tasks/UpgradeTask.php | 18 +++++
.../Admin/Controllers/AnswerController.php | 8 +-
.../Admin/Controllers/ArticleController.php | 2 +-
.../Admin/Controllers/QuestionController.php | 2 +-
app/Http/Admin/Services/Answer.php | 16 ++++
app/Http/Admin/Services/Article.php | 8 ++
app/Http/Admin/Services/AuthNode.php | 80 +++++++++----------
app/Http/Admin/Services/Question.php | 8 ++
app/Http/Admin/Views/answer/review.volt | 8 +-
app/Http/Admin/Views/article/list.volt | 2 +-
app/Http/Admin/Views/article/review.volt | 16 +++-
app/Http/Admin/Views/macros/article.volt | 8 +-
app/Http/Admin/Views/moderation/articles.volt | 3 +-
app/Http/Admin/Views/question/review.volt | 8 +-
.../Home/Controllers/AnswerController.php | 21 ++---
.../Home/Controllers/ArticleController.php | 39 ++++-----
.../Home/Controllers/QuestionController.php | 48 ++++-------
.../Home/Controllers/WidgetController.php | 15 ++++
app/Http/Home/Views/answer/edit.volt | 1 +
app/Http/Home/Views/article/edit.volt | 1 +
app/Http/Home/Views/article/list.volt | 4 +-
app/Http/Home/Views/article/show.volt | 5 +-
app/Http/Home/Views/question/answer_tips.volt | 17 ----
app/Http/Home/Views/question/answers.volt | 66 ++++++++-------
app/Http/Home/Views/question/edit.volt | 1 +
app/Http/Home/Views/question/list.volt | 4 +-
app/Http/Home/Views/question/show.volt | 11 ++-
.../Home/Views/user/console/articles.volt | 15 +---
.../Views/user/console/favorites_article.volt | 7 +-
.../user/console/favorites_question.volt | 7 +-
app/Http/Home/Views/user/console/menu.volt | 2 +-
.../Home/Views/user/console/questions.volt | 6 --
.../{question => widget}/hot_questions.volt | 0
.../{question => widget}/top_answerers.volt | 0
.../top_authors.volt} | 0
app/Services/Logic/Answer/AnswerInfo.php | 1 +
app/Services/Logic/Article/ArticleInfo.php | 1 +
.../{HotAuthorList.php => TopAuthorList.php} | 6 +-
app/Services/Logic/Question/QuestionInfo.php | 1 +
db/migrations/20210430023157.php | 61 ++++++++++++++
public/static/admin/css/common.css | 4 +
public/static/home/css/common.css | 54 +++++++++++--
public/static/home/js/article.list.js | 10 +--
46 files changed, 373 insertions(+), 236 deletions(-)
rename app/Caches/{ArticleHotAuthorList.php => TopAuthorList.php} (96%)
delete mode 100644 app/Http/Home/Views/question/answer_tips.volt
rename app/Http/Home/Views/{question => widget}/hot_questions.volt (100%)
rename app/Http/Home/Views/{question => widget}/top_answerers.volt (100%)
rename app/Http/Home/Views/{article/hot_authors.volt => widget/top_authors.volt} (100%)
rename app/Services/Logic/Article/{HotAuthorList.php => TopAuthorList.php} (56%)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 965bfae9..c1b2c565 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,13 +2,15 @@
### 更新
-- 前台增加问答功能
+- 增加问答功能
+- 增加标签关注功能
- 优化标签功能
- 优化文章功能以及全文搜索
- 优化课程评价,咨询,文章等相关统计
-- 后台增加提问和回答审核功能
-- 后台增加查看用户在线记录 修正后台编辑角色权限错误
- 优化前台界面
+- 后台增加提问和回答审核功能
+- 后台增加查看用户在线记录
+- 修正后台编辑角色权限错误
### [v1.3.3](https://gitee.com/koogua/course-tencent-cloud/releases/v1.3.3)(2021-04-30)
diff --git a/app/Caches/ArticleHotAuthorList.php b/app/Caches/TopAuthorList.php
similarity index 96%
rename from app/Caches/ArticleHotAuthorList.php
rename to app/Caches/TopAuthorList.php
index ff4440be..9fe35c24 100644
--- a/app/Caches/ArticleHotAuthorList.php
+++ b/app/Caches/TopAuthorList.php
@@ -8,7 +8,7 @@ use App\Repos\User as UserRepo;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
-class ArticleHotAuthorList extends Cache
+class TopAuthorList extends Cache
{
protected $lifetime = 1 * 86400;
@@ -20,7 +20,7 @@ class ArticleHotAuthorList extends Cache
public function getKey($id = null)
{
- return 'article_hot_author_list';
+ return 'top_author_list';
}
public function getContent($id = null)
diff --git a/app/Console/Tasks/RevokeVipTask.php b/app/Console/Tasks/RevokeVipTask.php
index 58380c4b..461df80f 100644
--- a/app/Console/Tasks/RevokeVipTask.php
+++ b/app/Console/Tasks/RevokeVipTask.php
@@ -24,7 +24,7 @@ class RevokeVipTask extends Task
}
/**
- * 查找待解锁用户
+ * 查找待撤销会员
*
* @param int $limit
* @return ResultsetInterface|Resultset|UserModel[]
diff --git a/app/Console/Tasks/UpgradeTask.php b/app/Console/Tasks/UpgradeTask.php
index 521289f1..e36388a7 100644
--- a/app/Console/Tasks/UpgradeTask.php
+++ b/app/Console/Tasks/UpgradeTask.php
@@ -2,6 +2,7 @@
namespace App\Console\Tasks;
+use App\Caches\NavTreeList as NavTreeListCache;
use App\Caches\Setting as SettingCache;
use App\Models\Setting as SettingModel;
@@ -14,6 +15,7 @@ class UpgradeTask extends Task
$this->resetAnnotationAction();
$this->resetMetadataAction();
$this->resetVoltAction();
+ $this->resetNavAction();
}
/**
@@ -103,6 +105,22 @@ class UpgradeTask extends Task
echo '------ end reset volt ------' . PHP_EOL;
}
+ /**
+ * 重置导航
+ *
+ * @command: php console.php upgrade reset_nav
+ */
+ public function resetNavAction()
+ {
+ echo '------ start reset navigation ------' . PHP_EOL;
+
+ $cache = new NavTreeListCache();
+
+ $cache->delete();
+
+ echo '------ end reset navigation ------' . PHP_EOL;
+ }
+
protected function handlePhKeys($keys)
{
return array_map(function ($key) {
diff --git a/app/Http/Admin/Controllers/AnswerController.php b/app/Http/Admin/Controllers/AnswerController.php
index e22ca8f3..42f0af5d 100644
--- a/app/Http/Admin/Controllers/AnswerController.php
+++ b/app/Http/Admin/Controllers/AnswerController.php
@@ -171,8 +171,6 @@ class AnswerController extends Controller
{
$answerService = new AnswerService();
- $answer = $answerService->getAnswer($id);
-
if ($this->request->isPost()) {
$answerService->reviewAnswer($id);
@@ -188,13 +186,9 @@ class AnswerController extends Controller
}
$reasons = $answerService->getReasons();
-
- $questionService = new QuestionService();
-
- $question = $questionService->getQuestion($answer->question_id);
+ $answer = $answerService->getAnswerInfo($id);
$this->view->setVar('reasons', $reasons);
- $this->view->setVar('question', $question);
$this->view->setVar('answer', $answer);
}
diff --git a/app/Http/Admin/Controllers/ArticleController.php b/app/Http/Admin/Controllers/ArticleController.php
index 26080afb..a849d35e 100644
--- a/app/Http/Admin/Controllers/ArticleController.php
+++ b/app/Http/Admin/Controllers/ArticleController.php
@@ -190,7 +190,7 @@ class ArticleController extends Controller
}
$reasons = $articleService->getReasons();
- $article = $articleService->getArticle($id);
+ $article = $articleService->getArticleInfo($id);
$this->view->setVar('reasons', $reasons);
$this->view->setVar('article', $article);
diff --git a/app/Http/Admin/Controllers/QuestionController.php b/app/Http/Admin/Controllers/QuestionController.php
index ef92e49d..082139dd 100644
--- a/app/Http/Admin/Controllers/QuestionController.php
+++ b/app/Http/Admin/Controllers/QuestionController.php
@@ -186,7 +186,7 @@ class QuestionController extends Controller
}
$reasons = $questionService->getReasons();
- $question = $questionService->getQuestion($id);
+ $question = $questionService->getQuestionInfo($id);
$this->view->setVar('reasons', $reasons);
$this->view->setVar('question', $question);
diff --git a/app/Http/Admin/Services/Answer.php b/app/Http/Admin/Services/Answer.php
index b1fd1263..abaf914e 100644
--- a/app/Http/Admin/Services/Answer.php
+++ b/app/Http/Admin/Services/Answer.php
@@ -11,6 +11,7 @@ use App\Models\User as UserModel;
use App\Repos\Answer as AnswerRepo;
use App\Repos\Question as QuestionRepo;
use App\Repos\User as UserRepo;
+use App\Services\Logic\Answer\AnswerInfo as AnswerInfoService;
use App\Services\Logic\Notice\System\AnswerApproved as AnswerApprovedNotice;
use App\Services\Logic\Notice\System\AnswerRejected as AnswerRejectedNotice;
use App\Services\Logic\Notice\System\QuestionAnswered as QuestionAnsweredNotice;
@@ -54,6 +55,13 @@ class Answer extends Service
return $this->findOrFail($id);
}
+ public function getAnswerInfo($id)
+ {
+ $service = new AnswerInfoService();
+
+ return $service->handle($id);
+ }
+
public function createAnswer()
{
$post = $this->request->getPost();
@@ -78,6 +86,8 @@ class Answer extends Service
$this->handleAnswerPostPoint($answer);
$this->handleQuestionAnsweredNotice($answer);
+ $this->eventsManager->fire('Answer:afterCreate', $this, $answer);
+
return $answer;
}
@@ -110,6 +120,8 @@ class Answer extends Service
$answer->update($data);
+ $this->eventsManager->fire('Answer:afterUpdate', $this, $answer);
+
return $answer;
}
@@ -129,6 +141,8 @@ class Answer extends Service
$this->recountUserAnswers($owner);
+ $this->eventsManager->fire('Answer:afterDelete', $this, $answer);
+
return $answer;
}
@@ -148,6 +162,8 @@ class Answer extends Service
$this->recountUserAnswers($owner);
+ $this->eventsManager->fire('Answer:afterRestore', $this, $answer);
+
return $answer;
}
diff --git a/app/Http/Admin/Services/Article.php b/app/Http/Admin/Services/Article.php
index fa39df84..3ccb3aef 100644
--- a/app/Http/Admin/Services/Article.php
+++ b/app/Http/Admin/Services/Article.php
@@ -15,6 +15,7 @@ use App\Repos\Category as CategoryRepo;
use App\Repos\Tag as TagRepo;
use App\Repos\User as UserRepo;
use App\Services\Logic\Article\ArticleDataTrait;
+use App\Services\Logic\Article\ArticleInfo as ArticleInfoService;
use App\Services\Logic\Notice\System\ArticleApproved as ArticleApprovedNotice;
use App\Services\Logic\Notice\System\ArticleRejected as ArticleRejectedNotice;
use App\Services\Logic\Point\History\ArticlePost as ArticlePostPointHistory;
@@ -111,6 +112,13 @@ class Article extends Service
return $this->findOrFail($id);
}
+ public function getArticleInfo($id)
+ {
+ $service = new ArticleInfoService();
+
+ return $service->handle($id);
+ }
+
public function createArticle()
{
$post = $this->request->getPost();
diff --git a/app/Http/Admin/Services/AuthNode.php b/app/Http/Admin/Services/AuthNode.php
index b62914ae..2ed2d003 100644
--- a/app/Http/Admin/Services/AuthNode.php
+++ b/app/Http/Admin/Services/AuthNode.php
@@ -243,6 +243,43 @@ class AuthNode extends Service
],
],
],
+ [
+ 'id' => '1-8',
+ 'title' => '标签管理',
+ 'type' => 'menu',
+ 'children' => [
+ [
+ 'id' => '1-8-1',
+ 'title' => '标签列表',
+ 'type' => 'menu',
+ 'route' => 'admin.tag.list',
+ ],
+ [
+ 'id' => '1-8-2',
+ 'title' => '搜索标签',
+ 'type' => 'menu',
+ 'route' => 'admin.tag.search',
+ ],
+ [
+ 'id' => '1-8-3',
+ 'title' => '添加标签',
+ 'type' => 'menu',
+ 'route' => 'admin.tag.add',
+ ],
+ [
+ 'id' => '1-8-4',
+ 'title' => '编辑标签',
+ 'type' => 'button',
+ 'route' => 'admin.tag.edit',
+ ],
+ [
+ 'id' => '1-8-5',
+ 'title' => '删除标签',
+ 'type' => 'button',
+ 'route' => 'admin.tag.delete',
+ ],
+ ],
+ ],
[
'id' => '1-7',
'title' => '文章管理',
@@ -390,43 +427,6 @@ class AuthNode extends Service
],
],
],
- [
- 'id' => '1-8',
- 'title' => '标签管理',
- 'type' => 'menu',
- 'children' => [
- [
- 'id' => '1-8-1',
- 'title' => '标签列表',
- 'type' => 'menu',
- 'route' => 'admin.tag.list',
- ],
- [
- 'id' => '1-8-2',
- 'title' => '搜索标签',
- 'type' => 'menu',
- 'route' => 'admin.tag.search',
- ],
- [
- 'id' => '1-8-3',
- 'title' => '添加标签',
- 'type' => 'menu',
- 'route' => 'admin.tag.add',
- ],
- [
- 'id' => '1-8-4',
- 'title' => '编辑标签',
- 'type' => 'button',
- 'route' => 'admin.tag.edit',
- ],
- [
- 'id' => '1-8-5',
- 'title' => '删除标签',
- 'type' => 'button',
- 'route' => 'admin.tag.delete',
- ],
- ],
- ],
[
'id' => '1-9',
'title' => '评论管理',
@@ -475,19 +475,19 @@ class AuthNode extends Service
'children' => [
[
'id' => '2-10-1',
- 'title' => '文章列表',
+ 'title' => '文章审核',
'type' => 'menu',
'route' => 'admin.mod.articles',
],
[
'id' => '2-10-2',
- 'title' => '问题列表',
+ 'title' => '问题审核',
'type' => 'menu',
'route' => 'admin.mod.questions',
],
[
'id' => '2-10-3',
- 'title' => '回答列表',
+ 'title' => '回答审核',
'type' => 'menu',
'route' => 'admin.mod.answers',
],
diff --git a/app/Http/Admin/Services/Question.php b/app/Http/Admin/Services/Question.php
index eda8ffd3..a83914fd 100644
--- a/app/Http/Admin/Services/Question.php
+++ b/app/Http/Admin/Services/Question.php
@@ -17,6 +17,7 @@ use App\Services\Logic\Notice\System\QuestionApproved as QuestionApprovedNotice;
use App\Services\Logic\Notice\System\QuestionRejected as QuestionRejectedNotice;
use App\Services\Logic\Point\History\QuestionPost as QuestionPostPointHistory;
use App\Services\Logic\Question\QuestionDataTrait;
+use App\Services\Logic\Question\QuestionInfo as QuestionInfoService;
use App\Services\Sync\QuestionIndex as QuestionIndexSync;
use App\Validators\Question as QuestionValidator;
@@ -105,6 +106,13 @@ class Question extends Service
return $this->findOrFail($id);
}
+ public function getQuestionInfo($id)
+ {
+ $service = new QuestionInfoService();
+
+ return $service->handle($id);
+ }
+
public function createQuestion()
{
$post = $this->request->getPost();
diff --git a/app/Http/Admin/Views/answer/review.volt b/app/Http/Admin/Views/answer/review.volt
index c94e5e6e..f93a7162 100644
--- a/app/Http/Admin/Views/answer/review.volt
+++ b/app/Http/Admin/Views/answer/review.volt
@@ -2,12 +2,18 @@
{% block content %}
+ {% set owner_url = url({'for':'home.user.show','id':answer.owner.id}) %}
+
-
{{ question.title }}
+
{{ answer.question.title }}
+
{{ answer.content }}
diff --git a/app/Http/Admin/Views/article/list.volt b/app/Http/Admin/Views/article/list.volt
index b13ccdea..272c8348 100644
--- a/app/Http/Admin/Views/article/list.volt
+++ b/app/Http/Admin/Views/article/list.volt
@@ -70,7 +70,7 @@
{% endif %}
- 来源:{{ source_info(item.source_type,item.source_url) }}
+ 来源:{{ source_type(item.source_type) }}
作者:{{ item.owner.name }}
创建:{{ date('Y-m-d',item.create_time) }}
diff --git a/app/Http/Admin/Views/article/review.volt b/app/Http/Admin/Views/article/review.volt
index f24ca97d..67187d96 100644
--- a/app/Http/Admin/Views/article/review.volt
+++ b/app/Http/Admin/Views/article/review.volt
@@ -2,20 +2,34 @@
{% block content %}
+ {{ partial('macros/article') }}
+
+ {% set owner_url = url({'for':'home.user.show','id':article.owner.id}) %}
+
{{ article.title }}
+
{{ article.content }}
{% if article.tags %}
{% for item in article.tags %}
- {{ item['name'] }}
+ {{ item.name }}
{% endfor %}
{% endif %}
+ {% if article.source_url %}
+
+ {% endif %}