1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-07-07 01:11:10 +08:00

修正在php7.3下的类继承问题

This commit is contained in:
xiaochong0302 2020-07-07 20:44:26 +08:00
parent 401ec0793a
commit 680089e06f
86 changed files with 605 additions and 167 deletions

View File

@ -0,0 +1,78 @@
<?php
namespace App\Builders;
use App\Repos\Course as CourseRepo;
use App\Repos\Topic as TopicRepo;
class CourseTopicList extends Builder
{
public function handleCourses($relations)
{
$courses = $this->getCourses($relations);
foreach ($relations as $key => $value) {
$relations[$key]['course'] = $courses[$value['course_id']] ?? new \stdClass();
}
return $relations;
}
public function handleTopics($relations)
{
$topics = $this->getTopics($relations);
foreach ($relations as $key => $value) {
$relations[$key]['topic'] = $topics[$value['topic_id']] ?? new \stdClass();
}
return $relations;
}
public function getCourses($relations)
{
$ids = kg_array_column($relations, 'course_id');
$courseRepo = new CourseRepo();
$columns = [
'id', 'title', 'cover',
'market_price', 'vip_price',
'rating', 'model', 'level', 'attrs',
'user_count', 'lesson_count',
];
$courses = $courseRepo->findByIds($ids, $columns);
$baseUrl = kg_ci_base_url();
$result = [];
foreach ($courses->toArray() as $course) {
$course['cover'] = $baseUrl . $course['cover'];
$course['attrs'] = json_decode($course['attrs'], true);
$result[$course['id']] = $course;
}
return $result;
}
public function getTopics($relations)
{
$ids = kg_array_column($relations, 'topic_id');
$topicRepo = new TopicRepo();
$topics = $topicRepo->findByIds($ids, ['id', 'title', 'summary']);
$result = [];
foreach ($topics->toArray() as $topic) {
$result[$topic['id']] = $topic;
}
return $result;
}
}

View File

@ -30,23 +30,20 @@ class CourseController extends Controller
{
$service = new CourseQueryService();
$params = $service->getQueryParams();
$pagerUrl = $this->url->get(['for' => 'web.course.pager'], $params);
$topCategories = $service->handleTopCategories();
$subCategories = $service->handleSubCategories();
$models = $service->handleModels();
$levels = $service->handleLevels();
$sorts = $service->handleSorts();
$params = $service->getParams();
$this->view->setVar('pager_url', $pagerUrl);
$this->view->setVar('top_categories', $topCategories);
$this->view->setVar('sub_categories', $subCategories);
$this->view->setVar('models', $models);
$this->view->setVar('levels', $levels);
$this->view->setVar('sorts', $sorts);
$this->view->setVar('params', $params);
}
/**
@ -114,13 +111,11 @@ class CourseController extends Controller
*/
public function consultsAction($id)
{
$target = $this->request->get('target', 'trim', 'tab-consults');
$service = new CourseConsultListService();
$pager = $service->handle($id);
$pager->items = kg_array_object($pager->items);
$pager->target = $target;
$pager->target = 'tab-consults';
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
$this->view->setVar('pager', $pager);
@ -131,13 +126,11 @@ class CourseController extends Controller
*/
public function reviewsAction($id)
{
$target = $this->request->get('target', 'trim', 'tab-reviews');
$service = new CourseReviewListService();
$pager = $service->handle($id);
$pager->items = kg_array_object($pager->items);
$pager->target = $target;
$pager->target = 'tab-reviews';
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
$this->view->setVar('pager', $pager);

View File

@ -0,0 +1,38 @@
<?php
namespace App\Http\Web\Controllers;
use App\Services\Frontend\Help\HelpInfo as HelpInfoService;
use App\Services\Frontend\Help\HelpList as HelpListService;
/**
* @RoutePrefix("/help")
*/
class HelpController extends Controller
{
/**
* @Get("/", name="web.help.index")
*/
public function indexAction()
{
$service = new HelpListService();
$helps = $service->handle();
$this->view->setVar('helps', $helps);
}
/**
* @Get("/{id:[0-9]+}", name="web.help.show")
*/
public function showAction($id)
{
$service = new HelpInfoService();
$help = $service->handle($id);
$this->view->setVar('help', $help);
}
}

View File

@ -2,7 +2,7 @@
namespace App\Http\Web\Controllers;
use App\Services\Frontend\Page\PageInfo as PageInfoService;
use App\Services\Frontend\Page\HelpInfo as PageInfoService;
/**
* @RoutePrefix("/page")

View File

@ -3,6 +3,7 @@
namespace App\Http\Web\Controllers;
use App\Services\Frontend\Teacher\TeacherList as TeacherListService;
use Phalcon\Mvc\View;
/**
* @RoutePrefix("/teacher")
@ -11,18 +12,26 @@ class TeacherController extends Controller
{
/**
* @Get("/list", name="web.teacher")
* @Get("/list", name="web.teacher.list")
*/
public function listAction()
{
$_REQUEST['limit'] = 12;
}
/**
* @Get("/pager", name="web.teacher.pager")
*/
public function pagerAction()
{
$service = new TeacherListService();
$pager = $service->handle();
$pager->items = kg_array_object($pager->items);
$pager->target = 'teacher-list';
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
$this->view->pick('teacher/list_pager');
$this->view->setVar('pager', $pager);
}

View File

@ -4,6 +4,7 @@ namespace App\Http\Web\Controllers;
use App\Services\Frontend\Topic\CourseList as TopicCourseListService;
use App\Services\Frontend\Topic\TopicInfo as TopicInfoService;
use Phalcon\Mvc\View;
/**
* @RoutePrefix("/topic")
@ -20,12 +21,24 @@ class TopicController extends Controller
$topic = $service->handle($id);
$this->view->setVar('topic', $topic);
}
/**
* @Get("/{id:[0-9]+}/courses", name="web.topic.courses")
*/
public function coursesAction($id)
{
$target = $this->request->get('target', 'trim', 'course-list');
$service = new TopicCourseListService();
$courses = $service->handle($id);
$pager = $service->handle($id);
$pager->items = kg_array_object($pager->items);
$pager->target = $target;
$this->view->setVar('topic', $topic);
$this->view->setVar('courses', $courses);
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
$this->view->setVar('pager', $pager);
}
}

View File

@ -31,13 +31,11 @@ class UserController extends Controller
*/
public function coursesAction($id)
{
$target = $this->request->get('target', 'trim', 'tab-courses');
$service = new UserCourseListService();
$pager = $service->handle($id);
$pager->items = kg_array_object($pager->items);
$pager->target = $target;
$pager->target = 'tab-courses';
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
$this->view->setVar('pager', $pager);
@ -48,13 +46,11 @@ class UserController extends Controller
*/
public function favoritesAction($id)
{
$target = $this->request->get('target', 'trim', 'tab-favorites');
$service = new UserFavoriteListService();
$pager = $service->handle($id);
$pager->items = kg_array_object($pager->items);
$pager->target = $target;
$pager->target = 'tab-favorites';
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
$this->view->setVar('pager', $pager);
@ -65,13 +61,11 @@ class UserController extends Controller
*/
public function friendsAction($id)
{
$target = $this->request->get('target', 'trim', 'tab-friends');
$service = new UserFriendListService();
$pager = $service->handle($id);
$pager->items = kg_array_object($pager->items);
$pager->target = $target;
$pager->target = 'tab-friends';
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
$this->view->setVar('pager', $pager);

View File

@ -30,13 +30,11 @@ class VipController extends Controller
*/
public function coursesAction()
{
$target = $this->request->get('target', 'trim', 'tab-courses');
$service = new VipCourseListService();
$pager = $service->handle();
$pager->items = kg_array_object($pager->items);
$pager->target = $target;
$pager->target = 'tab-courses';
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
$this->view->setVar('pager', $pager);
@ -47,13 +45,11 @@ class VipController extends Controller
*/
public function usersAction()
{
$target = $this->request->get('target', 'trim', 'tab-users');
$service = new VipUserListService();
$pager = $service->handle();
$pager->items = kg_array_object($pager->items);
$pager->target = $target;
$pager->target = 'tab-users';
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
$this->view->setVar('pager', $pager);

View File

@ -18,7 +18,7 @@ class CourseQuery extends Service
public function handleTopCategories()
{
$params = $this->getQueryParams();
$params = $this->getParams();
if (isset($params['tc'])) {
unset($params['tc']);
@ -33,7 +33,7 @@ class CourseQuery extends Service
$defaultItem = [
'id' => 'all',
'name' => '全部',
'url' => $baseUrl . $this->buildQueryParams($params),
'url' => $baseUrl . $this->buildParams($params),
];
$result = [];
@ -49,7 +49,7 @@ class CourseQuery extends Service
$result[] = [
'id' => $category['id'],
'name' => $category['name'],
'url' => $baseUrl . $this->buildQueryParams($params),
'url' => $baseUrl . $this->buildParams($params),
];
}
@ -58,7 +58,7 @@ class CourseQuery extends Service
public function handleSubCategories()
{
$params = $this->getQueryParams();
$params = $this->getParams();
if (empty($params['tc'])) {
return [];
@ -81,7 +81,7 @@ class CourseQuery extends Service
$defaultItem = [
'id' => 'all',
'name' => '全部',
'url' => $baseUrl . $this->buildQueryParams($params),
'url' => $baseUrl . $this->buildParams($params),
];
$result = [];
@ -93,7 +93,7 @@ class CourseQuery extends Service
$result[] = [
'id' => $category['id'],
'name' => $category['name'],
'url' => $baseUrl . $this->buildQueryParams($params),
'url' => $baseUrl . $this->buildParams($params),
];
}
@ -102,7 +102,7 @@ class CourseQuery extends Service
public function handleModels()
{
$params = $this->getQueryParams();
$params = $this->getParams();
if (isset($params['model'])) {
unset($params['model']);
@ -111,7 +111,7 @@ class CourseQuery extends Service
$defaultItem = [
'id' => 'all',
'name' => '全部',
'url' => $this->baseUrl . $this->buildQueryParams($params),
'url' => $this->baseUrl . $this->buildParams($params),
];
$result = [];
@ -125,7 +125,7 @@ class CourseQuery extends Service
$result[] = [
'id' => $key,
'name' => $value,
'url' => $this->baseUrl . $this->buildQueryParams($params),
'url' => $this->baseUrl . $this->buildParams($params),
];
}
@ -134,7 +134,7 @@ class CourseQuery extends Service
public function handleLevels()
{
$params = $this->getQueryParams();
$params = $this->getParams();
if (isset($params['level'])) {
unset($params['level']);
@ -143,7 +143,7 @@ class CourseQuery extends Service
$defaultItem = [
'id' => 'all',
'name' => '全部',
'url' => $this->baseUrl . $this->buildQueryParams($params),
'url' => $this->baseUrl . $this->buildParams($params),
];
$result = [];
@ -157,7 +157,7 @@ class CourseQuery extends Service
$result[] = [
'id' => $key,
'name' => $value,
'url' => $this->baseUrl . $this->buildQueryParams($params),
'url' => $this->baseUrl . $this->buildParams($params),
];
}
@ -166,7 +166,7 @@ class CourseQuery extends Service
public function handleSorts()
{
$params = $this->getQueryParams();
$params = $this->getParams();
$result = [];
@ -177,7 +177,7 @@ class CourseQuery extends Service
$result[] = [
'id' => $key,
'name' => $value,
'url' => $this->baseUrl . $this->buildQueryParams($params),
'url' => $this->baseUrl . $this->buildParams($params),
];
}
@ -197,20 +197,20 @@ class CourseQuery extends Service
$result['top'] = [
'name' => $topCategory->name,
'url' => $this->baseUrl . $this->buildQueryParams($topParams),
'url' => $this->baseUrl . $this->buildParams($topParams),
];
$subParams = ['tc' => $topCategory->id, 'sc' => $subCategory->id];
$result['sub'] = [
'name' => $subCategory->name,
'url' => $this->baseUrl . $this->buildQueryParams($subParams),
'url' => $this->baseUrl . $this->buildParams($subParams),
];
return $result;
}
public function getQueryParams()
public function getParams()
{
$query = $this->request->getQuery();
@ -246,7 +246,7 @@ class CourseQuery extends Service
return $params;
}
protected function buildQueryParams($params)
protected function buildParams($params)
{
return $params ? '?' . http_build_query($params) : '';
}

View File

@ -11,7 +11,7 @@
<div class="layui-tab layui-tab-brief login-tab">
<ul class="layui-tab-title login-tab-title">
<li class="layui-this">密码登录</li>
<li>验证登录</li>
<li>验证登录</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">

View File

@ -4,6 +4,8 @@
{{ partial('course/list_filter') }}
{% set pager_url = url({'for':'web.course.pager'}, params) %}
<div id="course-list" data-url="{{ pager_url }}"></div>
{% endblock %}

View File

@ -0,0 +1,14 @@
{% extends 'templates/full.volt' %}
{% block content %}
<div class="layui-collapse">
{% for help in helps %}
<div class="layui-colla-item">
<h2 class="layui-colla-title">{{ help.title }}</h2>
<div class="layui-colla-content layui-show">{{ help.content }}</div>
</div>
{% endfor %}
</div>
{% endblock %}

View File

@ -0,0 +1,9 @@
{% extends 'templates/full.volt' %}
{% block content %}
<h3 class="page-title">{{ page.title }}</h3>
<div class="page-content container">{{ page.content }}</div>
{% endblock %}

View File

@ -2,33 +2,19 @@
{% block content %}
{% set pager_url = url({'for':'web.teacher.pager'}) %}
<div class="layui-breadcrumb breadcrumb">
<a href="/">首页</a>
<a><cite>名师</cite></a>
</div>
{% if pager.total_pages > 0 %}
<div class="teach-user-list clearfix">
<div class="layui-row layui-col-space20">
{% for item in pager.items %}
{% set user_title = item.title ? item.title : '小小教书匠' %}
{% set user_about = item.about ? item.about|e : '这个人很懒,什么都没留下' %}
{% set user_url = url({'for':'web.teacher.show','id':item.id}) %}
<div class="layui-col-md3">
<div class="user-card">
<div class="avatar">
<a href="{{ user_url }}" title="{{ user_about }}"><img src="{{ item.avatar }}" alt="{{ item.name }}"></a>
</div>
<div class="name layui-elip">
<a href="{{ user_url }}">{{ item.name }}</a>
</div>
<div class="title layui-elip">{{ user_title }}</div>
</div>
</div>
{% endfor %}
</div>
</div>
{{ partial('partials/pager') }}
{% endif %}
<div id="teacher-list" data-url="{{ pager_url }}"></div>
{% endblock %}
{% block include_js %}
{{ js_include('web/js/teacher.list.js') }}
{% endblock %}

View File

@ -0,0 +1,23 @@
{% if pager.total_pages > 0 %}
<div class="teach-user-list clearfix">
<div class="layui-row layui-col-space20">
{% for item in pager.items %}
{% set user_title = item.title ? item.title : '小小教书匠' %}
{% set user_about = item.about ? item.about|e : '这个人很懒,什么都没留下' %}
{% set user_url = url({'for':'web.teacher.show','id':item.id}) %}
<div class="layui-col-md3">
<div class="user-card">
<div class="avatar">
<a href="{{ user_url }}" title="{{ user_about }}"><img src="{{ item.avatar }}" alt="{{ item.name }}"></a>
</div>
<div class="name layui-elip">
<a href="{{ user_url }}">{{ item.name }}</a>
</div>
<div class="title layui-elip">{{ user_title }}</div>
</div>
</div>
{% endfor %}
</div>
</div>
{{ partial('partials/pager_ajax') }}
{% endif %}

View File

@ -0,0 +1,14 @@
{{ partial('partials/macro_course') }}
{% if pager.total_pages > 0 %}
<div class="course-list clearfix">
<div class="layui-row layui-col-space20">
{% for item in pager.items %}
<div class="layui-col-md3">
{{ course_card(item) }}
</div>
{% endfor %}
</div>
</div>
{{ partial('partials/pager_ajax') }}
{% endif %}

View File

@ -0,0 +1,19 @@
{% extends 'templates/full.volt' %}
{% block content %}
{% set courses_url = url({'for':'web.topic.courses','id':topic.id}) %}
<div class="topic-info container">
<h3 class="title" title="{{ topic.summary|e }}">{{ topic.title }}</h3>
</div>
<div id="course-list" data-url="{{ courses_url }}"></div>
{% endblock %}
{% block include_js %}
{{ js_include('web/js/topic.show.js') }}
{% endblock %}

View File

@ -16,8 +16,8 @@ class Redis extends \Phalcon\Cache\Backend\Redis
/**
* {@inheritdoc}
*
* @param string $keyName
* @param int $lifetime
* @param string $keyName
* @param int $lifetime
* @return mixed|null
*/
public function get($keyName, $lifetime = null)
@ -49,15 +49,15 @@ class Redis extends \Phalcon\Cache\Backend\Redis
/**
* {@inheritdoc}
*
* @param string $keyName
* @param string $content
* @param int $lifetime
* @param bool $stopBuffer
* @param string $keyName
* @param string $content
* @param int $lifetime
* @param bool $stopBuffer
* @return bool
*
* @throws Exception
*/
public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true)
public function save($keyName = null, $content = null, $lifetime = null, bool $stopBuffer = true): bool
{
if ($keyName === null) {
$lastKey = $this->_lastKey;
@ -127,10 +127,10 @@ class Redis extends \Phalcon\Cache\Backend\Redis
/**
* {@inheritdoc}
*
* @param string $keyName
* @param string $keyName
* @return bool
*/
public function delete($keyName)
public function delete($keyName): bool
{
$redis = $this->getRedis();
@ -142,10 +142,10 @@ class Redis extends \Phalcon\Cache\Backend\Redis
/**
* {@inheritdoc}
*
* @param string $prefix
* @param string $prefix
* @return array
*/
public function queryKeys($prefix = null)
public function queryKeys($prefix = null): array
{
$result = [];
@ -167,11 +167,11 @@ class Redis extends \Phalcon\Cache\Backend\Redis
/**
* {@inheritdoc}
*
* @param string $keyName
* @param string $lifetime
* @param string $keyName
* @param string $lifetime
* @return bool
*/
public function exists($keyName = null, $lifetime = null)
public function exists($keyName = null, $lifetime = null): bool
{
$redis = $this->getRedis();
@ -191,7 +191,7 @@ class Redis extends \Phalcon\Cache\Backend\Redis
* @param int $value
* @return int
*/
public function increment($keyName = null, $value = 1)
public function increment($keyName = null, $value = 1): int
{
$redis = $this->getRedis();
@ -211,7 +211,7 @@ class Redis extends \Phalcon\Cache\Backend\Redis
* @param int $value
* @return int
*/
public function decrement($keyName = null, $value = 1)
public function decrement($keyName = null, $value = 1): int
{
$redis = $this->getRedis();
@ -229,7 +229,7 @@ class Redis extends \Phalcon\Cache\Backend\Redis
*
* @return bool
*/
public function flush()
public function flush(): bool
{
}

View File

@ -8,7 +8,7 @@ class Request extends \Phalcon\Http\Request
/**
* @return bool
*/
public function isAjax()
public function isAjax(): bool
{
if (parent::isAjax()) {
return true;
@ -26,7 +26,7 @@ class Request extends \Phalcon\Http\Request
/**
* @return bool
*/
public function isApi()
public function isApi(): bool
{
$url = $this->get('_url');

View File

@ -2,14 +2,16 @@
namespace App\Library\Http;
use Phalcon\Http\ResponseInterface;
class Response extends \Phalcon\Http\Response
{
public function setJsonContent($content, $jsonOptions = 0, $depth = 512)
public function setJsonContent($content, $jsonOptions = 0, $depth = 512): ResponseInterface
{
$jsonOptions = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION;
parent::setJsonContent($content, $jsonOptions, $depth);
return parent::setJsonContent($content, $jsonOptions, $depth);
}
}

View File

@ -2,10 +2,12 @@
namespace App\Library\Mvc;
class View extends \Phalcon\Mvc\View
use Phalcon\Mvc\View as PhView;
class View extends PhView
{
public function setVars(array $params, $merge = true)
public function setVars(array $params, bool $merge = true): PhView
{
foreach ($params as $key => $param) {
if (is_array($param)) {
@ -13,16 +15,16 @@ class View extends \Phalcon\Mvc\View
}
}
parent::setVars($params, $merge);
return parent::setVars($params, $merge);
}
public function setVar($key, $value)
public function setVar(string $key, $value): PhView
{
if (is_array($value)) {
$value = kg_array_object($value);
}
parent::setVar($key, $value);
return parent::setVar($key, $value);
}
}

View File

@ -4,6 +4,7 @@ namespace App\Library\Paginator\Adapter;
use App\Library\Paginator\Query;
use Phalcon\Paginator\Adapter\QueryBuilder as BaseQueryBuilder;
use stdClass;
class QueryBuilder extends BaseQueryBuilder
{
@ -12,7 +13,7 @@ class QueryBuilder extends BaseQueryBuilder
protected $params = [];
public function paginate()
public function paginate(): stdClass
{
$pager = parent::paginate();

View File

@ -47,7 +47,7 @@ class AccessToken extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_access_token';
}

View File

@ -63,7 +63,7 @@ class Account extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_account';
}

View File

@ -61,7 +61,7 @@ class Audit extends Model
*/
public $create_time;
public function getSource()
public function getSource(): string
{
return 'kg_audit';
}

View File

@ -92,7 +92,7 @@ class Category extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_category';
}

View File

@ -174,7 +174,7 @@ class Chapter extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_chapter';
}

View File

@ -61,7 +61,7 @@ class ChapterLive extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_chapter_live';
}

View File

@ -60,7 +60,7 @@ class ChapterRead extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_chapter_read';
}

View File

@ -91,7 +91,7 @@ class ChapterUser extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_chapter_user';
}

View File

@ -56,7 +56,7 @@ class ChapterVod extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_chapter_vod';
}

View File

@ -63,7 +63,7 @@ class ChapterVote extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_chapter_vote';
}

View File

@ -107,7 +107,7 @@ class Comment extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_comment';
}

View File

@ -63,7 +63,7 @@ class CommentVote extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_comment_vote';
}

View File

@ -91,7 +91,7 @@ class Consult extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_consult';
}

View File

@ -56,7 +56,7 @@ class ConsultVote extends Model
*/
public $create_time;
public function getSource()
public function getSource(): string
{
return 'kg_consult_vote';
}

View File

@ -42,7 +42,7 @@ class ContentImage extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_content_image';
}

View File

@ -241,7 +241,7 @@ class Course extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_course';
}

View File

@ -33,7 +33,7 @@ class CourseCategory extends Model
*/
public $create_time;
public function getSource()
public function getSource(): string
{
return 'kg_course_category';
}

View File

@ -49,7 +49,7 @@ class CourseFavorite extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_course_favorite';
}

View File

@ -33,7 +33,7 @@ class CoursePackage extends Model
*/
public $create_time;
public function getSource()
public function getSource(): string
{
return 'kg_course_package';
}

View File

@ -33,7 +33,7 @@ class CourseRelated extends Model
*/
public $create_time;
public function getSource()
public function getSource(): string
{
return 'kg_course_related';
}

View File

@ -33,7 +33,7 @@ class CourseTopic extends Model
*/
public $create_time;
public function getSource()
public function getSource(): string
{
return 'kg_course_topic';
}

View File

@ -111,7 +111,7 @@ class CourseUser extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_course_user';
}

View File

@ -64,7 +64,7 @@ class Help extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_help';
}

View File

@ -56,7 +56,7 @@ class ImFriendGroup extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_im_friend_group';
}

View File

@ -70,7 +70,7 @@ class ImFriendMessage extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_im_friend_message';
}

View File

@ -61,7 +61,7 @@ class ImFriendUser extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_im_friend_user';
}

View File

@ -78,7 +78,7 @@ class ImGroup extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_im_group';
}

View File

@ -56,7 +56,7 @@ class ImGroupMessage extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_im_group_message';
}

View File

@ -54,7 +54,7 @@ class ImGroupUser extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_im_group_user';
}

View File

@ -94,7 +94,7 @@ class ImSystemMessage extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_im_system_message';
}

View File

@ -79,7 +79,7 @@ class ImUser extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_im_user';
}

View File

@ -111,7 +111,7 @@ class Learning extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_learning';
}

View File

@ -117,7 +117,7 @@ class Nav extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_nav';
}

View File

@ -137,7 +137,7 @@ class Order extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_order';
}

View File

@ -33,7 +33,7 @@ class OrderStatus extends Model
*/
public $create_time;
public function getSource()
public function getSource(): string
{
return 'kg_order_status';
}

View File

@ -78,7 +78,7 @@ class Package extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_package';
}

View File

@ -50,7 +50,7 @@ class Page extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_page';
}

View File

@ -47,7 +47,7 @@ class RefreshToken extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_refresh_token';
}

View File

@ -108,7 +108,7 @@ class Refund extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_refund';
}

View File

@ -33,7 +33,7 @@ class RefundStatus extends Model
*/
public $create_time;
public function getSource()
public function getSource(): string
{
return 'kg_refund_status';
}

View File

@ -91,7 +91,7 @@ class Review extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_review';
}

View File

@ -56,7 +56,7 @@ class ReviewVote extends Model
*/
public $create_time;
public function getSource()
public function getSource(): string
{
return 'kg_review_vote';
}

View File

@ -49,7 +49,7 @@ class Reward extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_reward';
}

View File

@ -84,7 +84,7 @@ class Role extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_role';
}

View File

@ -33,7 +33,7 @@ class Setting extends Model
*/
public $item_value;
public function getSource()
public function getSource(): string
{
return 'kg_setting';
}

View File

@ -99,7 +99,7 @@ class Slide extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_slide';
}

View File

@ -89,7 +89,7 @@ class Task extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_task';
}

View File

@ -64,7 +64,7 @@ class Topic extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_topic';
}

View File

@ -105,7 +105,7 @@ class Trade extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_trade';
}

View File

@ -33,7 +33,7 @@ class TradeStatus extends Model
*/
public $create_time;
public function getSource()
public function getSource(): string
{
return 'kg_trade_status';
}

View File

@ -141,7 +141,7 @@ class User extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_user';
}

View File

@ -56,7 +56,7 @@ class Vip extends Model
*/
public $update_time;
public function getSource()
public function getSource(): string
{
return 'kg_vip';
}

View File

@ -2,6 +2,7 @@
namespace App\Repos;
use App\Library\Paginator\Adapter\QueryBuilder as PagerQueryBuilder;
use App\Models\CourseTopic as CourseTopicModel;
use Phalcon\Mvc\Model;
use Phalcon\Mvc\Model\Resultset;
@ -10,6 +11,40 @@ use Phalcon\Mvc\Model\ResultsetInterface;
class CourseTopic extends Repository
{
public function paginate($where = [], $sort = 'latest', $page = 1, $limit = 15)
{
$builder = $this->modelsManager->createBuilder();
$builder->from(CourseTopicModel::class);
$builder->where('1 = 1');
if (!empty($where['course_id'])) {
$builder->andWhere('course_id = :course_id:', ['course_id' => $where['course_id']]);
}
if (!empty($where['topic_id'])) {
$builder->andWhere('topic_id = :topic_id:', ['topic_id' => $where['topic_id']]);
}
switch ($sort) {
default:
$orderBy = 'id DESC';
break;
}
$builder->orderBy($orderBy);
$pager = new PagerQueryBuilder([
'builder' => $builder,
'page' => $page,
'limit' => $limit,
]);
return $pager->paginate();
}
/**
* @param int $courseId
* @param int $topicId

View File

@ -2,6 +2,7 @@
namespace App\Repos;
use App\Library\Paginator\Adapter\QueryBuilder as PagerQueryBuilder;
use App\Models\Help as HelpModel;
use Phalcon\Mvc\Model;
use Phalcon\Mvc\Model\Resultset;
@ -10,6 +11,43 @@ use Phalcon\Mvc\Model\ResultsetInterface;
class Help extends Repository
{
public function paginate($where = [], $sort = 'latest', $page = 1, $limit = 15)
{
$builder = $this->modelsManager->createBuilder();
$builder->from(HelpModel::class);
$builder->where('1 = 1');
if (!empty($where['title'])) {
$builder->andWhere('title LIKE :title:', ['title' => "%{$where['title']}%"]);
}
if (isset($where['published'])) {
$builder->andWhere('published = :published:', ['published' => $where['published']]);
}
if (isset($where['deleted'])) {
$builder->andWhere('deleted = :deleted:', ['deleted' => $where['deleted']]);
}
switch ($sort) {
default:
$orderBy = 'id DESC';
break;
}
$builder->orderBy($orderBy);
$pager = new PagerQueryBuilder([
'builder' => $builder,
'page' => $page,
'limit' => $limit,
]);
return $pager->paginate();
}
/**
* @param int $id
* @return HelpModel|Model|bool

View File

@ -19,6 +19,10 @@ class Page extends Repository
$builder->where('1 = 1');
if (!empty($where['title'])) {
$builder->andWhere('title LIKE :title:', ['title' => "%{$where['title']}%"]);
}
if (isset($where['published'])) {
$builder->andWhere('published = :published:', ['published' => $where['published']]);
}

View File

@ -21,8 +21,8 @@ class Topic extends Repository
$builder->where('1 = 1');
if (!empty($where['user_id'])) {
$builder->andWhere('user_id = :user_id:', ['user_id' => $where['user_id']]);
if (!empty($where['title'])) {
$builder->andWhere('title LIKE :title:', ['title' => "%{$where['title']}%"]);
}
if (isset($where['published'])) {

View File

@ -0,0 +1,30 @@
<?php
namespace App\Services\Frontend\Help;
use App\Models\Help as HelpModel;
use App\Services\Frontend\HelpTrait;
use App\Services\Frontend\Service as FrontendService;
class HelpInfo extends FrontendService
{
use HelpTrait;
public function handle($id)
{
$help = $this->checkHelpCache($id);
return $this->handleHelp($help);
}
protected function handleHelp(HelpModel $help)
{
return [
'id' => $help->id,
'title' => $help->title,
'content' => $help->content,
];
}
}

View File

@ -0,0 +1,45 @@
<?php
namespace App\Services\Frontend\Help;
use App\Models\Help as HelpModel;
use App\Repos\Help as HelpRepo;
use App\Services\Frontend\Service as FrontendService;
class HelpList extends FrontendService
{
public function handle()
{
$helpRepo = new HelpRepo();
$params = ['published' => 1];
$helps = $helpRepo->findAll($params);
if ($helps->count() > 0) {
return $this->handleHelps($helps);
}
}
/**
* @param HelpModel[] $helps
* @return array
*/
protected function handleHelps($helps)
{
$items = [];
foreach ($helps as $help) {
$items[] = [
'id' => $help->id,
'title' => $help->title,
'content' => $help->content,
];
}
return $items;
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Services\Frontend;
use App\Validators\Help as HelpValidator;
trait HelpTrait
{
public function checkHelp($id)
{
$validator = new HelpValidator();
return $validator->checkHelp($id);
}
public function checkHelpCache($id)
{
$validator = new HelpValidator();
return $validator->checkHelpCache($id);
}
}

View File

@ -2,7 +2,9 @@
namespace App\Services\Frontend\Topic;
use App\Caches\TopicCourseList as TopicCourseListCache;
use App\Builders\CourseTopicList as CourseTopicListBuilder;
use App\Library\Paginator\Query as PagerQuery;
use App\Repos\CourseTopic as CourseTopicRepo;
use App\Services\Frontend\Service as FrontendService;
use App\Services\Frontend\TopicTrait;
@ -15,11 +17,34 @@ class CourseList extends FrontendService
{
$topic = $this->checkTopicCache($id);
$cache = new TopicCourseListCache();
$pagerQuery = new PagerQuery();
$result = $cache->get($topic->id);
$sort = $pagerQuery->getSort();
$page = $pagerQuery->getPage();
$limit = $pagerQuery->getLimit();
return $result ?: [];
$params = ['topic_id' => $topic->id];
$courseTopicRepo = new CourseTopicRepo();
$pager = $courseTopicRepo->paginate($params, $sort, $page, $limit);
return $this->handleCourses($pager);
}
protected function handleCourses($pager)
{
if ($pager->total_items == 0) {
return $pager;
}
$builder = new CourseTopicListBuilder();
$relations = $pager->items->toArray();
$pager->items = $builder->getCourses($relations);
return $pager;
}
}

View File

@ -23,8 +23,7 @@ class TopicInfo extends FrontendService
return [
'id' => $topic->id,
'title' => $topic->title,
'summary' => $topic->about,
'course_count' => $topic->course_count,
'summary' => $topic->summary,
];
}

View File

@ -54,7 +54,7 @@
.container {
padding: 20px;
margin-bottom: 15px;
margin-bottom: 20px;
background-color: #fff;
border-radius: 2px;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
@ -284,6 +284,36 @@
margin-bottom: 5px;
}
.page-title {
padding-bottom: 10px;
margin-bottom: 20px;
border-bottom: 1px solid #d3d3d3;
text-align: center;
color: #666;
}
.page-content {
min-height: 450px;
color: #666;
}
.topic-info {
margin-bottom: 20px;
}
.topic-info .title {
text-align: center;
}
.topic-info .summary {
padding: 15px 0;
color: #666;
}
.course-list {
margin-bottom: 20px;
}
.course-card {
float: left;
width: 100%;
@ -376,10 +406,6 @@
margin-right: 20px;
}
.course-list {
margin-bottom: 20px;
}
.course-meta .cover {
float: left;
margin-right: 10px;

View File

@ -0,0 +1,10 @@
layui.use(['jquery', 'helper'], function () {
var $ = layui.jquery;
var helper = layui.helper;
var $teacherList = $('#teacher-list');
helper.ajaxLoadHtml($teacherList.data('url'), $teacherList.attr('id'));
});

View File

@ -0,0 +1,9 @@
layui.use(['jquery', 'helper'], function () {
var $ = layui.jquery;
var helper = layui.helper;
var $courseList = $('#course-list');
helper.ajaxLoadHtml($courseList.data('url'), $courseList.attr('id'));
});