mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-24 20:06:09 +08:00
单页和帮助增加浏览属性
This commit is contained in:
parent
7153d4e5ef
commit
a3cb6d757a
@ -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');
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
<col width="10%">
|
||||
<col width="10%">
|
||||
<col width="12%">
|
||||
@ -31,6 +32,7 @@
|
||||
<th>编号</th>
|
||||
<th>标题</th>
|
||||
<th>分类</th>
|
||||
<th>浏览</th>
|
||||
<th>排序</th>
|
||||
<th>发布</th>
|
||||
<th>操作</th>
|
||||
@ -48,6 +50,7 @@
|
||||
<td>{{ item.id }}</td>
|
||||
<td><a href="{{ edit_url }}">{{ item.title }}</a></td>
|
||||
<td><a href="{{ list_url }}">{{ item.category.name }}</a></td>
|
||||
<td>{{ item.view_count }}</td>
|
||||
<td class="center"><input class="layui-input kg-priority" type="text" name="priority" title="数值越小排序越靠前" value="{{ item.priority }}" data-url="{{ update_url }}"></td>
|
||||
<td class="center"><input type="checkbox" name="published" value="1" lay-skin="switch" lay-text="是|否" lay-filter="published" data-url="{{ update_url }}" {% if item.published == 1 %}checked="checked"{% endif %}></td>
|
||||
<td class="center">
|
||||
|
@ -9,7 +9,7 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>版权所有</td>
|
||||
<td><a href="https://koogua.com" target="_blank">深圳市酷瓜软件有限公司</a></td>
|
||||
<td><a href="https://www.koogua.com" target="_blank">深圳市酷瓜软件有限公司</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>产品经理</td>
|
||||
|
@ -40,8 +40,8 @@
|
||||
<th>编号</th>
|
||||
<th>标题</th>
|
||||
<th>别名</th>
|
||||
<th>浏览</th>
|
||||
<th>创建时间</th>
|
||||
<th>更新时间</th>
|
||||
<th>发布</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
@ -57,8 +57,8 @@
|
||||
<td>{{ item.id }}</td>
|
||||
<td><a href="{{ edit_url }}">{{ item.title }}</a></td>
|
||||
<td>{{ alias_tips(item.alias) }}</td>
|
||||
<td>{{ item.view_count }}</td>
|
||||
<td>{{ date('Y-m-d H:i:s',item.create_time) }}</td>
|
||||
<td>{{ date('Y-m-d H:i:s',item.update_time) }}</td>
|
||||
<td><input type="checkbox" name="published" value="1" lay-skin="switch" lay-text="是|否" lay-filter="published" data-url="{{ update_url }}" {% if item.published == 1 %}checked="checked"{% endif %}>
|
||||
</td>
|
||||
<td class="center">
|
||||
|
41
app/Listeners/Help.php
Normal file
41
app/Listeners/Help.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Models\Help as HelpModel;
|
||||
use Phalcon\Events\Event as PhEvent;
|
||||
|
||||
class Help extends Listener
|
||||
{
|
||||
|
||||
public function afterCreate(PhEvent $event, $source, HelpModel $help)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function afterUpdate(PhEvent $event, $source, HelpModel $help)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function afterDelete(PhEvent $event, $source, HelpModel $help)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function afterRestore(PhEvent $event, $source, HelpModel $help)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function afterView(PhEvent $event, $source, HelpModel $help)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
41
app/Listeners/Page.php
Normal file
41
app/Listeners/Page.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Models\Page as PageModel;
|
||||
use Phalcon\Events\Event as PhEvent;
|
||||
|
||||
class Page extends Listener
|
||||
{
|
||||
|
||||
public function afterCreate(PhEvent $event, $source, PageModel $page)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function afterUpdate(PhEvent $event, $source, PageModel $page)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function afterDelete(PhEvent $event, $source, PageModel $page)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function afterRestore(PhEvent $event, $source, PageModel $page)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function afterView(PhEvent $event, $source, PageModel $page)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -69,6 +69,13 @@ class Help extends Model
|
||||
*/
|
||||
public $deleted = 0;
|
||||
|
||||
/**
|
||||
* 浏览量
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $view_count = 0;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*
|
||||
|
@ -62,6 +62,13 @@ class Page extends Model
|
||||
*/
|
||||
public $deleted = 0;
|
||||
|
||||
/**
|
||||
* 浏览量
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $view_count = 0;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*
|
||||
|
@ -32,6 +32,7 @@ class HelpInfo extends LogicService
|
||||
'content' => $help->content,
|
||||
'published' => $help->published,
|
||||
'deleted' => $help->deleted,
|
||||
'view_count' => $help->view_count,
|
||||
'create_time' => $help->create_time,
|
||||
'update_time' => $help->update_time,
|
||||
];
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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,
|
||||
];
|
||||
|
56
db/migrations/20221021035953.php
Normal file
56
db/migrations/20221021035953.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2022 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class V20221021035953 extends AbstractMigration
|
||||
{
|
||||
|
||||
public function up()
|
||||
{
|
||||
$this->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();
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user