diff --git a/app/Console/Tasks/SyncAppInfoTask.php b/app/Console/Tasks/SyncAppInfoTask.php index 7e118ed9..cbca2b44 100644 --- a/app/Console/Tasks/SyncAppInfoTask.php +++ b/app/Console/Tasks/SyncAppInfoTask.php @@ -15,7 +15,7 @@ class SyncAppInfoTask extends Task public function mainAction() { - $url = 'https://koogua.com/api/instance/collect'; + $url = 'https://www.koogua.com/api/instance/collect'; $site = $this->getSettings('site'); diff --git a/app/Http/Admin/Views/help/list.volt b/app/Http/Admin/Views/help/list.volt index 34b3aa4f..6f1af71c 100644 --- a/app/Http/Admin/Views/help/list.volt +++ b/app/Http/Admin/Views/help/list.volt @@ -22,6 +22,7 @@ + @@ -31,6 +32,7 @@ 编号 标题 分类 + 浏览 排序 发布 操作 @@ -48,6 +50,7 @@ {{ item.id }} {{ item.title }} {{ item.category.name }} + {{ item.view_count }} diff --git a/app/Http/Admin/Views/index/main_team_info.volt b/app/Http/Admin/Views/index/main_team_info.volt index 85c36e01..549be66c 100644 --- a/app/Http/Admin/Views/index/main_team_info.volt +++ b/app/Http/Admin/Views/index/main_team_info.volt @@ -9,7 +9,7 @@ 版权所有 - 深圳市酷瓜软件有限公司 + 深圳市酷瓜软件有限公司 产品经理 diff --git a/app/Http/Admin/Views/page/list.volt b/app/Http/Admin/Views/page/list.volt index 8904c68c..10bff784 100644 --- a/app/Http/Admin/Views/page/list.volt +++ b/app/Http/Admin/Views/page/list.volt @@ -40,8 +40,8 @@ 编号 标题 别名 + 浏览 创建时间 - 更新时间 发布 操作 @@ -57,8 +57,8 @@ {{ item.id }} {{ item.title }} {{ alias_tips(item.alias) }} + {{ item.view_count }} {{ date('Y-m-d H:i:s',item.create_time) }} - {{ date('Y-m-d H:i:s',item.update_time) }} diff --git a/app/Listeners/Help.php b/app/Listeners/Help.php new file mode 100644 index 00000000..0f20eddd --- /dev/null +++ b/app/Listeners/Help.php @@ -0,0 +1,41 @@ + $help->content, 'published' => $help->published, 'deleted' => $help->deleted, + 'view_count' => $help->view_count, 'create_time' => $help->create_time, 'update_time' => $help->update_time, ]; diff --git a/app/Services/Logic/Page/PageInfo.php b/app/Services/Logic/Page/PageInfo.php index 08278bde..86af7e8e 100644 --- a/app/Services/Logic/Page/PageInfo.php +++ b/app/Services/Logic/Page/PageInfo.php @@ -20,6 +20,10 @@ class PageInfo extends LogicService { $page = $this->checkPage($id); + $this->incrPageViewCount($page); + + $this->eventsManager->fire('Page:afterView', $this, $page); + return $this->handlePage($page); } @@ -32,9 +36,17 @@ class PageInfo extends LogicService 'content' => $page->content, 'published' => $page->published, 'deleted' => $page->deleted, + 'view_count' => $page->view_count, 'create_time' => $page->create_time, 'update_time' => $page->update_time, ]; } + protected function incrPageViewCount(PageModel $page) + { + $page->view_count += 1; + + $page->update(); + } + } diff --git a/config/events.php b/config/events.php index b0f4dc30..51da3304 100644 --- a/config/events.php +++ b/config/events.php @@ -10,6 +10,8 @@ use App\Listeners\Answer; use App\Listeners\Article; use App\Listeners\Comment; use App\Listeners\Consult; +use App\Listeners\Help; +use App\Listeners\Page; use App\Listeners\Question; use App\Listeners\Report; use App\Listeners\Review; @@ -18,15 +20,17 @@ use App\Listeners\Trade; use App\Listeners\UserDailyCounter; return [ - 'UserDailyCounter' => UserDailyCounter::class, 'Account' => Account::class, 'Answer' => Answer::class, 'Article' => Article::class, 'Comment' => Comment::class, 'Consult' => Consult::class, + 'Help' => Help::class, + 'Page' => Page::class, 'Question' => Question::class, 'Report' => Report::class, 'Review' => Review::class, - 'Trade' => Trade::class, 'Site' => Site::class, + 'Trade' => Trade::class, + 'UserDailyCounter' => UserDailyCounter::class, ]; diff --git a/db/migrations/20221021035953.php b/db/migrations/20221021035953.php new file mode 100644 index 00000000..4c7c79a1 --- /dev/null +++ b/db/migrations/20221021035953.php @@ -0,0 +1,56 @@ +alterPageTable(); + $this->alterHelpTable(); + } + + protected function alterPageTable() + { + $table = $this->table('kg_page'); + + if ($table->hasColumn('view_count') == false) { + $table->addColumn('view_count', 'integer', [ + 'null' => false, + 'default' => '0', + 'limit' => MysqlAdapter::INT_REGULAR, + 'signed' => false, + 'comment' => '浏览数', + 'after' => 'deleted', + ]); + } + + $table->save(); + } + + protected function alterHelpTable() + { + $table = $this->table('kg_help'); + + if ($table->hasColumn('view_count') == false) { + $table->addColumn('view_count', 'integer', [ + 'null' => false, + 'default' => '0', + 'limit' => MysqlAdapter::INT_REGULAR, + 'signed' => false, + 'comment' => '浏览数', + 'after' => 'deleted', + ]); + } + + $table->save(); + } + +}