mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-24 20:06:09 +08:00
1.重写view provider,数组赋值自动转对象
2.重写response provider,优化json输出格式
This commit is contained in:
parent
b1aca59389
commit
43adee9ceb
@ -7,9 +7,9 @@ use Phalcon\Mvc\User\Component;
|
||||
class Builder extends Component
|
||||
{
|
||||
|
||||
public function arrayToObject($array)
|
||||
public function objects(array $items)
|
||||
{
|
||||
return kg_array_object($array);
|
||||
return kg_array_object($items);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ namespace App\Caches;
|
||||
|
||||
use Phalcon\Cache\Backend\Redis as RedisCache;
|
||||
use Phalcon\Mvc\User\Component;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
abstract class Cache extends Component
|
||||
{
|
||||
@ -44,10 +43,6 @@ abstract class Cache extends Component
|
||||
$content = $this->cache->get($key);
|
||||
}
|
||||
|
||||
if (is_array($content)) {
|
||||
$content = new Collection($content);
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
@ -7,13 +7,12 @@ use App\Services\Auth\Admin as AdminAuth;
|
||||
use App\Traits\Response as ResponseTrait;
|
||||
use App\Traits\Security as SecurityTrait;
|
||||
use Phalcon\Mvc\Dispatcher;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class Controller extends \Phalcon\Mvc\Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
* @var array
|
||||
*/
|
||||
protected $authUser;
|
||||
|
||||
@ -45,7 +44,7 @@ class Controller extends \Phalcon\Mvc\Controller
|
||||
/**
|
||||
* 管理员忽略权限检查
|
||||
*/
|
||||
if ($this->authUser->root) {
|
||||
if ($this->authUser['root'] == 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -74,7 +73,7 @@ class Controller extends \Phalcon\Mvc\Controller
|
||||
/**
|
||||
* 执行路由权限检查
|
||||
*/
|
||||
if (!in_array($route->getName(), $this->authUser->routes)) {
|
||||
if (!in_array($route->getName(), $this->authUser['routes'])) {
|
||||
$dispatcher->forward([
|
||||
'controller' => 'public',
|
||||
'action' => 'forbidden',
|
||||
@ -96,8 +95,8 @@ class Controller extends \Phalcon\Mvc\Controller
|
||||
|
||||
$audit = new AuditModel();
|
||||
|
||||
$audit->user_id = $this->authUser->id;
|
||||
$audit->user_name = $this->authUser->name;
|
||||
$audit->user_id = $this->authUser['id'];
|
||||
$audit->user_name = $this->authUser['name'];
|
||||
$audit->user_ip = $this->request->getClientAddress();
|
||||
$audit->req_route = $this->router->getMatchedRoute()->getName();
|
||||
$audit->req_path = $this->request->getServer('REQUEST_URI');
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
namespace App\Http\Admin;
|
||||
|
||||
use App\Library\Mvc\View as MyView;
|
||||
use App\Services\Auth\Admin as AdminAuth;
|
||||
use Phalcon\DiInterface;
|
||||
use Phalcon\Mvc\ModuleDefinitionInterface;
|
||||
use Phalcon\Mvc\View;
|
||||
|
||||
class Module implements ModuleDefinitionInterface
|
||||
{
|
||||
@ -18,7 +18,7 @@ class Module implements ModuleDefinitionInterface
|
||||
public function registerServices(DiInterface $di)
|
||||
{
|
||||
$di->setShared('view', function () {
|
||||
$view = new View();
|
||||
$view = new MyView();
|
||||
$view->setViewsDir(__DIR__ . '/Views');
|
||||
$view->registerEngines([
|
||||
'.volt' => 'volt',
|
||||
|
@ -27,7 +27,7 @@ class AuthMenu extends Component
|
||||
$menus = [];
|
||||
|
||||
foreach ($this->authNodes as $node) {
|
||||
if ($this->authUser->id || in_array($node['id'], $this->owned1stLevelIds)) {
|
||||
if (($this->authUser['root'] == 1) || in_array($node['id'], $this->owned1stLevelIds)) {
|
||||
$menus[] = [
|
||||
'id' => $node['id'],
|
||||
'title' => $node['title'],
|
||||
@ -45,8 +45,8 @@ class AuthMenu extends Component
|
||||
foreach ($this->authNodes as $key => $level) {
|
||||
foreach ($level['children'] as $key2 => $level2) {
|
||||
foreach ($level2['children'] as $key3 => $level3) {
|
||||
$hasRight = $this->authUser->root || in_array($level3['id'], $this->owned3rdLevelIds);
|
||||
if ($level3['type'] == 'menu' && $hasRight) {
|
||||
$allowed = ($this->authUser['root'] == 1) || in_array($level3['id'], $this->owned3rdLevelIds);
|
||||
if ($level3['type'] == 'menu' && $allowed) {
|
||||
$menus[$key]['id'] = $level['id'];
|
||||
$menus[$key]['title'] = $level['title'];
|
||||
$menus[$key]['children'][$key2]['id'] = $level2['id'];
|
||||
@ -76,7 +76,7 @@ class AuthMenu extends Component
|
||||
|
||||
foreach ($routeIdMapping as $key => $value) {
|
||||
$ids = explode('-', $value);
|
||||
if (in_array($key, $this->authUser->routes)) {
|
||||
if (in_array($key, $this->authUser['routes'])) {
|
||||
$owned1stLevelIds[] = $ids[0];
|
||||
$owned2ndLevelIds[] = $ids[0] . '-' . $ids[1];
|
||||
$owned3rdLevelIds[] = $value;
|
||||
|
@ -39,11 +39,9 @@ class ChapterContent extends Service
|
||||
|
||||
public function getPlayUrls($chapterId)
|
||||
{
|
||||
$chapterVodService = new ChapterVodService();
|
||||
$service = new ChapterVodService();
|
||||
|
||||
$playUrls = $chapterVodService->getPlayUrls($chapterId);
|
||||
|
||||
return kg_array_object($playUrls);
|
||||
return $service->getPlayUrls($chapterId);
|
||||
}
|
||||
|
||||
public function updateChapterContent($chapterId)
|
||||
|
@ -140,7 +140,7 @@ class Comment extends Service
|
||||
$pipeB = $builder->handleCourses($pipeA);
|
||||
$pipeC = $builder->handleChapters($pipeB);
|
||||
$pipeD = $builder->handleUsers($pipeC);
|
||||
$pipeE = $builder->arrayToObject($pipeD);
|
||||
$pipeE = $builder->objects($pipeD);
|
||||
|
||||
$pager->items = $pipeE;
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ class Consult extends Service
|
||||
$pipeA = $pager->items->toArray();
|
||||
$pipeB = $builder->handleCourses($pipeA);
|
||||
$pipeC = $builder->handleUsers($pipeB);
|
||||
$pipeD = $builder->arrayToObject($pipeC);
|
||||
$pipeD = $builder->objects($pipeC);
|
||||
|
||||
$pager->items = $pipeD;
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ class Course extends Service
|
||||
|
||||
$pipeA = $pager->items->toArray();
|
||||
$pipeB = $builder->handleCategories($pipeA);
|
||||
$pipeC = $builder->arrayToObject($pipeB);
|
||||
$pipeC = $builder->objects($pipeB);
|
||||
|
||||
$pager->items = $pipeC;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ class Order extends Service
|
||||
$pipeA = $pager->items->toArray();
|
||||
$pipeB = $builder->handleItems($pipeA);
|
||||
$pipeC = $builder->handleUsers($pipeB);
|
||||
$pipeD = $builder->arrayToObject($pipeC);
|
||||
$pipeD = $builder->objects($pipeC);
|
||||
|
||||
$pager->items = $pipeD;
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ use App\Repos\Course as CourseRepo;
|
||||
use App\Repos\CoursePackage as CoursePackageRepo;
|
||||
use App\Repos\Package as PackageRepo;
|
||||
use App\Validators\Package as PackageValidator;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class Package extends Service
|
||||
{
|
||||
@ -140,7 +139,8 @@ class Package extends Service
|
||||
|
||||
public function getGuidingPrice($courses)
|
||||
{
|
||||
$totalMarketPrice = $totalVipPrice = 0;
|
||||
$totalMarketPrice = 0;
|
||||
$totalVipPrice = 0;
|
||||
|
||||
if ($courses) {
|
||||
foreach ($courses as $course) {
|
||||
@ -152,10 +152,10 @@ class Package extends Service
|
||||
$sgtMarketPrice = sprintf('%0.2f', intval($totalMarketPrice * 0.9));
|
||||
$sgtVipPrice = sprintf('%0.2f', intval($totalVipPrice * 0.8));
|
||||
|
||||
return new Collection([
|
||||
return [
|
||||
'market_price' => $sgtMarketPrice,
|
||||
'vip_price' => $sgtVipPrice,
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
public function getXmCourses($id)
|
||||
|
@ -120,7 +120,7 @@ class Refund extends Service
|
||||
$pipeA = $pager->items->toArray();
|
||||
$pipeB = $builder->handleUsers($pipeA);
|
||||
$pipeC = $builder->handleOrders($pipeB);
|
||||
$pipeD = $builder->arrayToObject($pipeC);
|
||||
$pipeD = $builder->objects($pipeC);
|
||||
|
||||
$pager->items = $pipeD;
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ class Review extends Service
|
||||
$pipeA = $pager->items->toArray();
|
||||
$pipeB = $builder->handleCourses($pipeA);
|
||||
$pipeC = $builder->handleUsers($pipeB);
|
||||
$pipeD = $builder->arrayToObject($pipeC);
|
||||
$pipeD = $builder->objects($pipeC);
|
||||
|
||||
$pager->items = $pipeD;
|
||||
}
|
||||
|
@ -13,9 +13,7 @@ class Role extends Service
|
||||
{
|
||||
$authNode = new AuthNode();
|
||||
|
||||
$nodes = $authNode->getNodes();
|
||||
|
||||
return kg_array_object($nodes);
|
||||
return $authNode->getNodes();
|
||||
}
|
||||
|
||||
public function getRoles()
|
||||
|
@ -144,7 +144,7 @@ class Student extends Service
|
||||
$pipeA = $pager->items->toArray();
|
||||
$pipeB = $builder->handleCourses($pipeA);
|
||||
$pipeC = $builder->handleUsers($pipeB);
|
||||
$pipeD = $builder->arrayToObject($pipeC);
|
||||
$pipeD = $builder->objects($pipeC);
|
||||
|
||||
$pager->items = $pipeD;
|
||||
}
|
||||
@ -162,7 +162,7 @@ class Student extends Service
|
||||
$pipeB = $builder->handleCourses($pipeA);
|
||||
$pipeC = $builder->handleChapters($pipeB);
|
||||
$pipeD = $builder->handleUsers($pipeC);
|
||||
$pipeE = $builder->arrayToObject($pipeD);
|
||||
$pipeE = $builder->objects($pipeD);
|
||||
|
||||
$pager->items = $pipeE;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ class Trade extends Service
|
||||
$pipeA = $pager->items->toArray();
|
||||
$pipeB = $builder->handleUsers($pipeA);
|
||||
$pipeC = $builder->handleOrders($pipeB);
|
||||
$pipeD = $builder->arrayToObject($pipeC);
|
||||
$pipeD = $builder->objects($pipeC);
|
||||
|
||||
$pager->items = $pipeD;
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ class User extends Service
|
||||
$pipeA = $pager->items->toArray();
|
||||
$pipeB = $builder->handleAdminRoles($pipeA);
|
||||
$pipeC = $builder->handleEduRoles($pipeB);
|
||||
$pipeD = $builder->arrayToObject($pipeC);
|
||||
$pipeD = $builder->objects($pipeC);
|
||||
|
||||
$pager->items = $pipeD;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{%- macro live_time_info(attrs) %}
|
||||
{% if attrs['start_time'] > 0 %}
|
||||
<p>开始:{{ date('Y-m-d H:i', attrs['start_time']) }}</p>
|
||||
<p>结束:{{ date('Y-m-d H:i', attrs['end_time']) }}</p>
|
||||
<p>开始:{{ date('Y-m-d H:i',attrs['start_time']) }}</p>
|
||||
<p>结束:{{ date('Y-m-d H:i',attrs['end_time']) }}</p>
|
||||
{% else %}
|
||||
N/A
|
||||
{% endif %}
|
||||
|
@ -22,8 +22,8 @@
|
||||
<a href="javascript:"><i class="layui-icon layui-icon-spread-left"></i></a>
|
||||
</div>
|
||||
<ul class="layui-nav layui-layout-left kg-nav-module">
|
||||
{% for item in top_menus|array_object %}
|
||||
<li nav-module="module-{{ item.id }}" class="layui-nav-item">
|
||||
{% for item in top_menus %}
|
||||
<li data-module="module-{{ item.id }}" class="layui-nav-item">
|
||||
<a href="javascript:">{{ item.title }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
@ -45,8 +45,8 @@
|
||||
|
||||
<div class="layui-side layui-bg-black">
|
||||
<div class="layui-side-scroll">
|
||||
{% for key,level in left_menus|array_object %}
|
||||
<ul class="layui-nav layui-nav-tree {% if key != 0 %}layui-hide{% endif %}" nav-module="module-{{ level.id }}" lay-shrink="all">
|
||||
{% for key,level in left_menus %}
|
||||
<ul class="layui-nav layui-nav-tree {% if key != 0 %}layui-hide{% endif %}" lay-shrink="all" data-module="module-{{ level.id }}">
|
||||
{% for key2,level2 in level.children %}
|
||||
<li class="layui-nav-item {% if key2 == 0 %}layui-nav-itemed{% endif %}">
|
||||
<a href="javascript:">{{ level2.title }}</a>
|
||||
|
@ -8,23 +8,25 @@
|
||||
|
||||
{%- macro gender_info(value) %}
|
||||
{% if value == 'male' %}
|
||||
男
|
||||
<span class="layui-badge layui-bg-red">男</span>
|
||||
{% elseif value == 'female' %}
|
||||
女
|
||||
<span class="layui-badge layui-bg-green">女</span>
|
||||
{% elseif value == 'none' %}
|
||||
密
|
||||
<span class="layui-badge layui-bg-gray">密</span>
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{%- macro edu_role_info(user) %}
|
||||
{% if user.edu_role.id %}
|
||||
{{ user.edu_role.name }}
|
||||
{% if user.edu_role.id == 'student' %}
|
||||
<span class="layui-badge layui-bg-gray">学员</span>
|
||||
{% elseif user.edu_role.id == 'teacher' %}
|
||||
<span class="layui-badge layui-bg-blue">讲师</span>
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{%- macro admin_role_info(user) %}
|
||||
{% if user.admin_role.id %}
|
||||
{{ user.admin_role.name }}
|
||||
<span class="layui-badge layui-bg-gray">{{ user.admin_role.name }}</span>
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
namespace App\Http\Html5;
|
||||
|
||||
use App\Library\Mvc\View as MyView;
|
||||
use App\Services\Auth\Html5 as Html5Auth;
|
||||
use Phalcon\DiInterface;
|
||||
use Phalcon\Mvc\ModuleDefinitionInterface;
|
||||
use Phalcon\Mvc\View;
|
||||
|
||||
class Module implements ModuleDefinitionInterface
|
||||
{
|
||||
@ -18,7 +18,7 @@ class Module implements ModuleDefinitionInterface
|
||||
public function registerServices(DiInterface $di)
|
||||
{
|
||||
$di->setShared('view', function () {
|
||||
$view = new View();
|
||||
$view = new MyView();
|
||||
$view->disable();
|
||||
return $view;
|
||||
});
|
||||
|
@ -9,7 +9,6 @@ use App\Services\Auth\Web as WebAuth;
|
||||
use App\Traits\Response as ResponseTrait;
|
||||
use App\Traits\Security as SecurityTrait;
|
||||
use Phalcon\Mvc\Dispatcher;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class Controller extends \Phalcon\Mvc\Controller
|
||||
{
|
||||
@ -17,20 +16,20 @@ class Controller extends \Phalcon\Mvc\Controller
|
||||
/**
|
||||
* @var SiteSeo
|
||||
*/
|
||||
protected $seo;
|
||||
protected $siteSeo;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
* @var array
|
||||
*/
|
||||
protected $site;
|
||||
protected $siteSettings;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
* @var array
|
||||
*/
|
||||
protected $nav;
|
||||
protected $siteNavs;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
* @var array
|
||||
*/
|
||||
protected $authUser;
|
||||
|
||||
@ -45,21 +44,21 @@ class Controller extends \Phalcon\Mvc\Controller
|
||||
|
||||
$this->checkRateLimit();
|
||||
|
||||
$this->seo = $this->getSiteSeo();
|
||||
$this->site = $this->getSiteSettings();
|
||||
$this->nav = $this->getNavList();
|
||||
$this->authUser = $this->getAuthUser();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
$this->seo->setTitle($this->site->title);
|
||||
$this->siteSeo = $this->getSiteSeo();
|
||||
$this->siteNavs = $this->getSiteNavs();
|
||||
$this->siteSettings = $this->getSiteSettings();
|
||||
$this->authUser = $this->getAuthUser();
|
||||
|
||||
$this->view->setVar('seo', $this->seo);
|
||||
$this->view->setVar('site', $this->site);
|
||||
$this->view->setVar('nav', $this->nav);
|
||||
$this->siteSeo->setTitle($this->siteSettings['title']);
|
||||
|
||||
$this->view->setVar('site_seo', $this->siteSeo);
|
||||
$this->view->setVar('site_navs', $this->siteNavs);
|
||||
$this->view->setVar('site_settings', $this->siteSettings);
|
||||
$this->view->setVar('auth_user', $this->authUser);
|
||||
}
|
||||
|
||||
@ -70,21 +69,21 @@ class Controller extends \Phalcon\Mvc\Controller
|
||||
*/
|
||||
$auth = $this->getDI()->get('auth');
|
||||
|
||||
return $auth->getAuthInfo();
|
||||
return $auth->getAuthInfo() ?: [];
|
||||
}
|
||||
|
||||
protected function getNavList()
|
||||
protected function getSiteNavs()
|
||||
{
|
||||
$cache = new NavTreeListCache();
|
||||
|
||||
return $cache->get();
|
||||
return $cache->get() ?: [];
|
||||
}
|
||||
|
||||
protected function getSiteSettings()
|
||||
{
|
||||
$cache = new SettingCache();
|
||||
|
||||
return $cache->get('site');
|
||||
return $cache->get('site') ?: [];
|
||||
}
|
||||
|
||||
protected function getSiteSeo()
|
||||
|
@ -10,8 +10,8 @@ class IndexController extends Controller
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$this->seo->setKeywords($this->site->keywords);
|
||||
$this->seo->setDescription($this->site->description);
|
||||
$this->siteSeo->setKeywords($this->siteSettings['keywords']);
|
||||
$this->siteSeo->setDescription($this->siteSettings['description']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
namespace App\Http\Web;
|
||||
|
||||
use App\Library\Mvc\View as MyView;
|
||||
use App\Services\Auth\Web as WebAuth;
|
||||
use Phalcon\DiInterface;
|
||||
use Phalcon\Mvc\ModuleDefinitionInterface;
|
||||
use Phalcon\Mvc\View;
|
||||
|
||||
class Module implements ModuleDefinitionInterface
|
||||
{
|
||||
@ -18,7 +18,7 @@ class Module implements ModuleDefinitionInterface
|
||||
public function registerServices(DiInterface $di)
|
||||
{
|
||||
$di->setShared('view', function () {
|
||||
$view = new View();
|
||||
$view = new MyView();
|
||||
$view->setViewsDir(__DIR__ . '/Views');
|
||||
$view->registerEngines([
|
||||
'.volt' => 'volt',
|
||||
|
@ -3,9 +3,9 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<meta name="keywords" content="{{ seo.getKeywords() }}">
|
||||
<meta name="description" content="{{ seo.getDescription() }}">
|
||||
<title>{{ seo.getTitle() }}</title>
|
||||
<meta name="keywords" content="{{ site_seo.getKeywords() }}">
|
||||
<meta name="description" content="{{ site_seo.getDescription() }}">
|
||||
<title>{{ site_seo.getTitle() }}</title>
|
||||
{{ icon_link("favicon.ico") }}
|
||||
{{ css_link("lib/layui/css/layui.css") }}
|
||||
{{ css_link("web/css/common.css") }}
|
||||
|
15
app/Library/Http/Response.php
Normal file
15
app/Library/Http/Response.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Http;
|
||||
|
||||
class Response extends \Phalcon\Http\Response
|
||||
{
|
||||
|
||||
public function setJsonContent($content, $jsonOptions = 0, $depth = 512)
|
||||
{
|
||||
$jsonOptions = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION;
|
||||
|
||||
parent::setJsonContent($content, $jsonOptions, $depth);
|
||||
}
|
||||
|
||||
}
|
28
app/Library/Mvc/View.php
Normal file
28
app/Library/Mvc/View.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Mvc;
|
||||
|
||||
class View extends \Phalcon\Mvc\View
|
||||
{
|
||||
|
||||
public function setVars(array $params, $merge = true)
|
||||
{
|
||||
foreach ($params as $key => $param) {
|
||||
if (is_array($param)) {
|
||||
$params[$key] = kg_array_object($param);
|
||||
}
|
||||
}
|
||||
|
||||
parent::setVars($params, $merge);
|
||||
}
|
||||
|
||||
public function setVar($key, $value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
$value = kg_array_object($value);
|
||||
}
|
||||
|
||||
parent::setVar($key, $value);
|
||||
}
|
||||
|
||||
}
|
@ -5,7 +5,6 @@ namespace App\Models;
|
||||
use App\Caches\MaxCourseId as MaxCourseIdCache;
|
||||
use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
use Phalcon\Text;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class Course extends Model
|
||||
{
|
||||
@ -326,43 +325,43 @@ class Course extends Model
|
||||
|
||||
public static function modelTypes()
|
||||
{
|
||||
return new Collection([
|
||||
return [
|
||||
self::MODEL_VOD => '点播',
|
||||
self::MODEL_LIVE => '直播',
|
||||
self::MODEL_READ => '图文',
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
public static function levelTypes()
|
||||
{
|
||||
return new Collection([
|
||||
return [
|
||||
self::LEVEL_ENTRY => '入门',
|
||||
self::LEVEL_JUNIOR => '初级',
|
||||
self::LEVEL_MEDIUM => '中级',
|
||||
self::LEVEL_SENIOR => '高级',
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
public static function studyExpiryOptions()
|
||||
{
|
||||
return new Collection([
|
||||
return [
|
||||
1 => '1个月',
|
||||
3 => '3个月',
|
||||
6 => '6个月',
|
||||
12 => '12个月',
|
||||
36 => '36个月',
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
public static function refundExpiryOptions()
|
||||
{
|
||||
return new Collection([
|
||||
return [
|
||||
7 => '7天',
|
||||
14 => '14天',
|
||||
30 => '30天',
|
||||
90 => '90天',
|
||||
180 => '180天',
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class Nav extends Model
|
||||
{
|
||||
@ -147,18 +146,18 @@ class Nav extends Model
|
||||
|
||||
public static function positionTypes()
|
||||
{
|
||||
return new Collection([
|
||||
return [
|
||||
self::POSITION_TOP => '顶部',
|
||||
self::POSITION_BOTTOM => '底部',
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
public static function targetTypes()
|
||||
{
|
||||
return new Collection([
|
||||
return [
|
||||
self::TARGET_BLANK => '新窗口',
|
||||
self::TARGET_SELF => '原窗口',
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class Order extends Model
|
||||
{
|
||||
@ -180,32 +179,32 @@ class Order extends Model
|
||||
|
||||
public static function itemTypes()
|
||||
{
|
||||
return new Collection([
|
||||
return [
|
||||
self::ITEM_COURSE => '课程',
|
||||
self::ITEM_PACKAGE => '套餐',
|
||||
self::ITEM_REWARD => '赞赏',
|
||||
self::ITEM_VIP => '会员',
|
||||
self::ITEM_TEST => '测试',
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
public static function sourceTypes()
|
||||
{
|
||||
return new Collection([
|
||||
return [
|
||||
self::SOURCE_DESKTOP => 'desktop',
|
||||
self::SOURCE_ANDROID => 'android',
|
||||
self::SOURCE_IOS => 'ios',
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
public static function statusTypes()
|
||||
{
|
||||
return new Collection([
|
||||
return [
|
||||
self::STATUS_PENDING => '待支付',
|
||||
self::STATUS_FINISHED => '已完成',
|
||||
self::STATUS_CLOSED => '已关闭',
|
||||
self::STATUS_REFUNDED => '已退款',
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class Refund extends Model
|
||||
{
|
||||
@ -145,14 +144,14 @@ class Refund extends Model
|
||||
|
||||
public static function statusTypes()
|
||||
{
|
||||
return new Collection([
|
||||
return [
|
||||
self::STATUS_PENDING => '待处理',
|
||||
self::STATUS_CANCELED => '已取消',
|
||||
self::STATUS_APPROVED => '已审核',
|
||||
self::STATUS_REFUSED => '已拒绝',
|
||||
self::STATUS_FINISHED => '已完成',
|
||||
self::STATUS_FAILED => '已失败',
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class Role extends Model
|
||||
{
|
||||
@ -129,20 +128,20 @@ class Role extends Model
|
||||
|
||||
public static function types()
|
||||
{
|
||||
return new Collection([
|
||||
return [
|
||||
self::TYPE_SYSTEM => '内置',
|
||||
self::TYPE_CUSTOM => '自定',
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
public static function sysRoleTypes()
|
||||
{
|
||||
return new Collection([
|
||||
return [
|
||||
self::ROLE_ROOT => '管理人员',
|
||||
self::ROLE_OPERATOR => '运营人员',
|
||||
self::ROLE_EDITOR => '编辑人员',
|
||||
self::ROLE_FINANCE => '财务人员',
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ namespace App\Models;
|
||||
|
||||
use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
use Phalcon\Text;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class Slide extends Model
|
||||
{
|
||||
@ -146,11 +145,11 @@ class Slide extends Model
|
||||
|
||||
public static function targetTypes()
|
||||
{
|
||||
return new Collection([
|
||||
return [
|
||||
self::TARGET_COURSE => '课程',
|
||||
self::TARGET_PAGE => '单页',
|
||||
self::TARGET_LINK => '链接',
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class Trade extends Model
|
||||
{
|
||||
@ -142,20 +141,20 @@ class Trade extends Model
|
||||
|
||||
public static function channelTypes()
|
||||
{
|
||||
return new Collection([
|
||||
return [
|
||||
self::CHANNEL_ALIPAY => '支付宝',
|
||||
self::CHANNEL_WXPAY => '微信',
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
public static function statusTypes()
|
||||
{
|
||||
return new Collection([
|
||||
return [
|
||||
self::STATUS_PENDING => '待支付',
|
||||
self::STATUS_FINISHED => '已完成',
|
||||
self::STATUS_CLOSED => '已关闭',
|
||||
self::STATUS_REFUNDED => '已退款',
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ namespace App\Models;
|
||||
use App\Caches\MaxUserId as MaxUserIdCache;
|
||||
use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
use Phalcon\Text;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class User extends Model
|
||||
{
|
||||
@ -209,19 +208,19 @@ class User extends Model
|
||||
|
||||
public static function genderTypes()
|
||||
{
|
||||
return new Collection([
|
||||
return [
|
||||
self::GENDER_MALE => '男',
|
||||
self::GENDER_FEMALE => '女',
|
||||
self::GENDER_NONE => '保密',
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
public static function eduRoleTypes()
|
||||
{
|
||||
return new Collection([
|
||||
return [
|
||||
self::EDU_ROLE_STUDENT => '学员',
|
||||
self::EDU_ROLE_TEACHER => '讲师',
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
19
app/Providers/Response.php
Normal file
19
app/Providers/Response.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Library\Http\Response as MyResponse;
|
||||
|
||||
class Response extends Provider
|
||||
{
|
||||
|
||||
protected $serviceName = 'view';
|
||||
|
||||
public function register()
|
||||
{
|
||||
$this->di->setShared($this->serviceName, function () {
|
||||
return new MyResponse();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
19
app/Providers/View.php
Normal file
19
app/Providers/View.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Library\Mvc\View as MyView;
|
||||
|
||||
class View extends Provider
|
||||
{
|
||||
|
||||
protected $serviceName = 'view';
|
||||
|
||||
public function register()
|
||||
{
|
||||
$this->di->setShared($this->serviceName, function () {
|
||||
return new MyView();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -50,14 +50,6 @@ class Volt extends Provider
|
||||
return 'kg_can(' . $resolvedArgs . ')';
|
||||
});
|
||||
|
||||
$compiler->addFilter('array_object', function ($resolvedArgs) {
|
||||
return 'kg_array_object(' . $resolvedArgs . ')';
|
||||
});
|
||||
|
||||
$compiler->addFilter('object_array', function ($resolvedArgs) {
|
||||
return 'kg_object_array(' . $resolvedArgs . ')';
|
||||
});
|
||||
|
||||
$compiler->addFilter('play_duration', function ($resolvedArgs) {
|
||||
return 'kg_play_duration(' . $resolvedArgs . ')';
|
||||
});
|
||||
|
@ -9,6 +9,9 @@ abstract class Auth extends Service
|
||||
|
||||
abstract function saveAuthInfo(UserModel $user);
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
abstract function getAuthInfo();
|
||||
|
||||
abstract function clearAuthInfo();
|
||||
|
@ -6,7 +6,6 @@ use App\Models\Role as RoleModel;
|
||||
use App\Models\User as UserModel;
|
||||
use App\Repos\Role as RoleRepo;
|
||||
use App\Services\Auth as AuthService;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class Admin extends AuthService
|
||||
{
|
||||
@ -17,7 +16,9 @@ class Admin extends AuthService
|
||||
|
||||
$role = $roleRepo->findById($user->admin_role);
|
||||
|
||||
$root = $role->id == RoleModel::ROLE_ROOT;
|
||||
$root = $role->id == RoleModel::ROLE_ROOT ? 1 : 0;
|
||||
|
||||
$authKey = $this->getAuthKey();
|
||||
|
||||
$authInfo = [
|
||||
'id' => $user->id,
|
||||
@ -26,8 +27,6 @@ class Admin extends AuthService
|
||||
'root' => $root,
|
||||
];
|
||||
|
||||
$authKey = $this->getAuthKey();
|
||||
|
||||
$this->session->set($authKey, $authInfo);
|
||||
}
|
||||
|
||||
@ -44,9 +43,7 @@ class Admin extends AuthService
|
||||
|
||||
$authInfo = $this->session->get($authKey);
|
||||
|
||||
if (!$authInfo) return null;
|
||||
|
||||
return new Collection($authInfo);
|
||||
return $authInfo ?: null;
|
||||
}
|
||||
|
||||
public function getAuthKey()
|
||||
|
@ -7,7 +7,6 @@ use App\Models\AccessToken as AccessTokenModel;
|
||||
use App\Models\RefreshToken as RefreshTokenModel;
|
||||
use App\Models\User as UserModel;
|
||||
use App\Services\Auth as AuthService;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class Api extends AuthService
|
||||
{
|
||||
@ -37,11 +36,11 @@ class Api extends AuthService
|
||||
|
||||
$cache->save($key, $authInfo, $config->access_token->lifetime);
|
||||
|
||||
return new Collection([
|
||||
return [
|
||||
'access_token' => $accessToken->id,
|
||||
'refresh_token' => $refreshToken->id,
|
||||
'expiry_time' => $accessToken->expiry_time,
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
public function clearAuthInfo()
|
||||
@ -67,9 +66,7 @@ class Api extends AuthService
|
||||
|
||||
$authInfo = $cache->get($key);
|
||||
|
||||
if (!$authInfo) return null;
|
||||
|
||||
return new Collection($authInfo);
|
||||
return $authInfo ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,7 +4,6 @@ namespace App\Services\Auth;
|
||||
|
||||
use App\Models\User as UserModel;
|
||||
use App\Services\Auth as AuthService;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class Html5 extends AuthService
|
||||
{
|
||||
@ -34,14 +33,12 @@ class Html5 extends AuthService
|
||||
|
||||
$authInfo = $this->session->get($authKey);
|
||||
|
||||
if (!$authInfo) return null;
|
||||
|
||||
return new Collection($authInfo);
|
||||
return $authInfo ?: null;
|
||||
}
|
||||
|
||||
public function getAuthKey()
|
||||
{
|
||||
return 'html5_auth_info';
|
||||
return 'h5_auth_info';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ namespace App\Services\Auth;
|
||||
|
||||
use App\Models\User as UserModel;
|
||||
use App\Services\Auth as AuthService;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class Web extends AuthService
|
||||
{
|
||||
@ -13,10 +12,10 @@ class Web extends AuthService
|
||||
{
|
||||
$authKey = $this->getAuthKey();
|
||||
|
||||
$authInfo = new Collection([
|
||||
$authInfo = [
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
]);
|
||||
];
|
||||
|
||||
$this->session->set($authKey, $authInfo);
|
||||
}
|
||||
@ -34,9 +33,7 @@ class Web extends AuthService
|
||||
|
||||
$authInfo = $this->session->get($authKey);
|
||||
|
||||
if (!$authInfo) return null;
|
||||
|
||||
return new Collection($authInfo);
|
||||
return $authInfo ?: null;
|
||||
}
|
||||
|
||||
public function getAuthKey()
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace App\Services\Search;
|
||||
|
||||
use Phalcon\Mvc\User\Component;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class CourseHandler extends Component
|
||||
{
|
||||
@ -36,7 +35,7 @@ class CourseHandler extends Component
|
||||
* @param string $query
|
||||
* @param int $limit
|
||||
* @param int $offset
|
||||
* @return Collection
|
||||
* @return array
|
||||
* @throws \XSException
|
||||
*/
|
||||
public function search($query, $limit = 15, $offset = 0)
|
||||
@ -63,10 +62,10 @@ class CourseHandler extends Component
|
||||
$items[] = $item;
|
||||
}
|
||||
|
||||
return new Collection([
|
||||
return [
|
||||
'total' => $total,
|
||||
'items' => $items,
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7,7 +7,6 @@ use App\Repos\User as UserRepo;
|
||||
use App\Services\Auth as AuthService;
|
||||
use App\Validators\Validator as AppValidator;
|
||||
use Phalcon\Di;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
trait Auth
|
||||
{
|
||||
@ -25,7 +24,7 @@ trait Auth
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
return $userRepo->findById($authUser->id);
|
||||
return $userRepo->findById($authUser['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,7 +40,7 @@ trait Auth
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
return $userRepo->findById($authUser->id);
|
||||
return $userRepo->findById($authUser['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,7 +57,7 @@ trait Auth
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|null
|
||||
* @return array|null
|
||||
*/
|
||||
public function getAuthUser()
|
||||
{
|
||||
|
@ -12,10 +12,12 @@ use App\Providers\EventsManager as EventsManagerProvider;
|
||||
use App\Providers\Logger as LoggerProvider;
|
||||
use App\Providers\MetaData as MetaDataProvider;
|
||||
use App\Providers\Provider as AppProvider;
|
||||
use App\Providers\Response as ResponseProvider;
|
||||
use App\Providers\Router as RouterProvider;
|
||||
use App\Providers\Security as SecurityProvider;
|
||||
use App\Providers\Session as SessionProvider;
|
||||
use App\Providers\Url as UrlProvider;
|
||||
use App\Providers\View as ViewProvider;
|
||||
use App\Providers\Volt as VoltProvider;
|
||||
use Phalcon\Di\FactoryDefault;
|
||||
use Phalcon\Loader;
|
||||
@ -72,10 +74,12 @@ class HttpKernel extends Kernel
|
||||
EventsManagerProvider::class,
|
||||
LoggerProvider::class,
|
||||
MetaDataProvider::class,
|
||||
ResponseProvider::class,
|
||||
RouterProvider::class,
|
||||
SecurityProvider::class,
|
||||
SessionProvider::class,
|
||||
UrlProvider::class,
|
||||
ViewProvider::class,
|
||||
VoltProvider::class,
|
||||
];
|
||||
|
||||
|
@ -4,13 +4,12 @@ layui.use(['jquery', 'element'], function () {
|
||||
|
||||
$('.kg-nav-module > li').on('click', function () {
|
||||
|
||||
var navModule = $(this).attr('nav-module');
|
||||
var module = $(this).attr('data-module');
|
||||
|
||||
$('.layui-nav-tree').each(function () {
|
||||
if ($(this).attr('nav-module') == navModule) {
|
||||
if ($(this).attr('data-module') === module) {
|
||||
$(this).removeClass('layui-hide');
|
||||
var href = $(this).find('a[target=content]:first').attr('href');
|
||||
window.frames['content'].location.href = href;
|
||||
window.frames['content'].location.href = $(this).find('a[target=content]:first').attr('href');
|
||||
} else {
|
||||
$(this).addClass('layui-hide');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user