1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-29 13:51:37 +08:00

后台Config->Setting

This commit is contained in:
xiaochong0302 2020-04-10 19:27:09 +08:00
parent c7b2fdac66
commit d1c9dfa46f
43 changed files with 324 additions and 336 deletions

View File

@ -2,9 +2,9 @@
namespace App\Caches; namespace App\Caches;
use App\Repos\Config as ConfigRepo; use App\Repos\Setting as SettingRepo;
class SectionConfig extends Cache class Setting extends Cache
{ {
protected $lifetime = 365 * 86400; protected $lifetime = 365 * 86400;
@ -16,14 +16,14 @@ class SectionConfig extends Cache
public function getKey($id = null) public function getKey($id = null)
{ {
return "section_config:{$id}"; return "setting:{$id}";
} }
public function getContent($id = null) public function getContent($id = null)
{ {
$configRepo = new ConfigRepo(); $settingRepo = new SettingRepo();
$items = $configRepo->findAll(['section' => $id]); $items = $settingRepo->findAll(['section' => $id]);
if ($items->count() == 0) { if ($items->count() == 0) {
return []; return [];

View File

@ -4,8 +4,8 @@ namespace App\Http\Admin\Controllers;
use App\Http\Admin\Services\Chapter as ChapterService; use App\Http\Admin\Services\Chapter as ChapterService;
use App\Http\Admin\Services\ChapterContent as ChapterContentService; use App\Http\Admin\Services\ChapterContent as ChapterContentService;
use App\Http\Admin\Services\Config as ConfigService;
use App\Http\Admin\Services\Course as CourseService; use App\Http\Admin\Services\Course as CourseService;
use App\Http\Admin\Services\Setting as SettingService;
use App\Models\Course as CourseModel; use App\Models\Course as CourseModel;
/** /**
@ -86,11 +86,11 @@ class ChapterController extends Controller
$contentService = new ChapterContentService(); $contentService = new ChapterContentService();
$chapterService = new ChapterService(); $chapterService = new ChapterService();
$courseService = new CourseService(); $courseService = new CourseService();
$configService = new ConfigService(); $settingService = new SettingService();
$chapter = $chapterService->getChapter($id); $chapter = $chapterService->getChapter($id);
$course = $courseService->getCourse($chapter->course_id); $course = $courseService->getCourse($chapter->course_id);
$storage = $configService->getSectionConfig('storage'); $storage = $settingService->getSectionSettings('storage');
$this->view->setVar('storage', $storage); $this->view->setVar('storage', $storage);
$this->view->setVar('chapter', $chapter); $this->view->setVar('chapter', $chapter);

View File

@ -48,7 +48,7 @@ class Controller extends \Phalcon\Mvc\Controller
/** /**
* 管理员忽略权限检查 * 管理员忽略权限检查
*/ */
if ($this->authUser['root'] == 1) { if ($this->authUser->root) {
return true; return true;
} }
@ -77,7 +77,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([ $dispatcher->forward([
'controller' => 'public', 'controller' => 'public',
'action' => 'forbidden', 'action' => 'forbidden',
@ -99,8 +99,8 @@ class Controller extends \Phalcon\Mvc\Controller
$audit = new AuditModel(); $audit = new AuditModel();
$audit->user_id = $this->authUser['id']; $audit->user_id = $this->authUser->id;
$audit->user_name = $this->authUser['name']; $audit->user_name = $this->authUser->name;
$audit->user_ip = $this->request->getClientAddress(); $audit->user_ip = $this->request->getClientAddress();
$audit->req_route = $this->router->getMatchedRoute()->getName(); $audit->req_route = $this->router->getMatchedRoute()->getName();
$audit->req_path = $this->request->getServer('REQUEST_URI'); $audit->req_path = $this->request->getServer('REQUEST_URI');

View File

@ -2,8 +2,8 @@
namespace App\Http\Admin\Controllers; namespace App\Http\Admin\Controllers;
use App\Http\Admin\Services\Config as ConfigService;
use App\Http\Admin\Services\Session as SessionService; use App\Http\Admin\Services\Session as SessionService;
use App\Http\Admin\Services\Setting as SettingService;
use App\Traits\Response as ResponseTrait; use App\Traits\Response as ResponseTrait;
use App\Traits\Security as SecurityTrait; use App\Traits\Security as SecurityTrait;
@ -40,9 +40,9 @@ class SessionController extends \Phalcon\Mvc\Controller
return $this->jsonSuccess(['location' => $location]); return $this->jsonSuccess(['location' => $location]);
} }
$configService = new ConfigService(); $settingService = new SettingService();
$captcha = $configService->getSectionConfig('captcha'); $captcha = $settingService->getSectionSettings('captcha');
$this->view->pick('public/login'); $this->view->pick('public/login');

View File

@ -2,134 +2,134 @@
namespace App\Http\Admin\Controllers; namespace App\Http\Admin\Controllers;
use App\Http\Admin\Services\Config as ConfigService; use App\Http\Admin\Services\Setting as SettingService;
/** /**
* @RoutePrefix("/admin/config") * @RoutePrefix("/admin/setting")
*/ */
class ConfigController extends Controller class SettingController extends Controller
{ {
/** /**
* @Route("/site", name="admin.config.site") * @Route("/site", name="admin.setting.site")
*/ */
public function siteAction() public function siteAction()
{ {
$section = 'site'; $section = 'site';
$configService = new ConfigService(); $settingService = new SettingService();
if ($this->request->isPost()) { if ($this->request->isPost()) {
$data = $this->request->getPost(); $data = $this->request->getPost();
$configService->updateSectionConfig($section, $data); $settingService->updateSectionSettings($section, $data);
return $this->jsonSuccess(['msg' => '更新配置成功']); return $this->jsonSuccess(['msg' => '更新配置成功']);
} else { } else {
$site = $configService->getSectionConfig($section); $site = $settingService->getSectionSettings($section);
$this->view->setVar('site', $site); $this->view->setVar('site', $site);
} }
} }
/** /**
* @Route("/secret", name="admin.config.secret") * @Route("/secret", name="admin.setting.secret")
*/ */
public function secretAction() public function secretAction()
{ {
$section = 'secret'; $section = 'secret';
$configService = new ConfigService(); $settingService = new SettingService();
if ($this->request->isPost()) { if ($this->request->isPost()) {
$data = $this->request->getPost(); $data = $this->request->getPost();
$configService->updateStorageConfig($section, $data); $settingService->updateStorageSettings($section, $data);
return $this->jsonSuccess(['msg' => '更新配置成功']); return $this->jsonSuccess(['msg' => '更新配置成功']);
} else { } else {
$secret = $configService->getSectionConfig($section); $secret = $settingService->getSectionSettings($section);
$this->view->setVar('secret', $secret); $this->view->setVar('secret', $secret);
} }
} }
/** /**
* @Route("/storage", name="admin.config.storage") * @Route("/storage", name="admin.setting.storage")
*/ */
public function storageAction() public function storageAction()
{ {
$section = 'storage'; $section = 'storage';
$configService = new ConfigService(); $settingService = new SettingService();
if ($this->request->isPost()) { if ($this->request->isPost()) {
$data = $this->request->getPost(); $data = $this->request->getPost();
$configService->updateStorageConfig($section, $data); $settingService->updateStorageSettings($section, $data);
return $this->jsonSuccess(['msg' => '更新配置成功']); return $this->jsonSuccess(['msg' => '更新配置成功']);
} else { } else {
$storage = $configService->getSectionConfig($section); $storage = $settingService->getSectionSettings($section);
$this->view->setVar('storage', $storage); $this->view->setVar('storage', $storage);
} }
} }
/** /**
* @Route("/vod", name="admin.config.vod") * @Route("/vod", name="admin.setting.vod")
*/ */
public function vodAction() public function vodAction()
{ {
$section = 'vod'; $section = 'vod';
$configService = new ConfigService(); $settingService = new SettingService();
if ($this->request->isPost()) { if ($this->request->isPost()) {
$data = $this->request->getPost(); $data = $this->request->getPost();
$configService->updateVodConfig($section, $data); $settingService->updateVodSettings($section, $data);
return $this->jsonSuccess(['msg' => '更新配置成功']); return $this->jsonSuccess(['msg' => '更新配置成功']);
} else { } else {
$vod = $configService->getSectionConfig($section); $vod = $settingService->getSectionSettings($section);
$this->view->setVar('vod', $vod); $this->view->setVar('vod', $vod);
} }
} }
/** /**
* @Route("/live", name="admin.config.live") * @Route("/live", name="admin.setting.live")
*/ */
public function liveAction() public function liveAction()
{ {
$section = 'live'; $section = 'live';
$configService = new ConfigService(); $settingService = new SettingService();
if ($this->request->isPost()) { if ($this->request->isPost()) {
$data = $this->request->getPost(); $data = $this->request->getPost();
$configService->updateLiveConfig($section, $data); $settingService->updateLiveSettings($section, $data);
return $this->jsonSuccess(['msg' => '更新配置成功']); return $this->jsonSuccess(['msg' => '更新配置成功']);
} else { } else {
$live = $configService->getSectionConfig($section); $live = $settingService->getSectionSettings($section);
$ptt = json_decode($live->pull_trans_template); $ptt = json_decode($live->pull_trans_template);
@ -139,11 +139,11 @@ class ConfigController extends Controller
} }
/** /**
* @Route("/payment", name="admin.config.payment") * @Route("/payment", name="admin.setting.payment")
*/ */
public function paymentAction() public function paymentAction()
{ {
$configService = new ConfigService(); $settingService = new SettingService();
if ($this->request->isPost()) { if ($this->request->isPost()) {
@ -151,14 +151,14 @@ class ConfigController extends Controller
$data = $this->request->getPost(); $data = $this->request->getPost();
$configService->updateSectionConfig($section, $data); $settingService->updateSectionSettings($section, $data);
return $this->jsonSuccess(['msg' => '更新配置成功']); return $this->jsonSuccess(['msg' => '更新配置成功']);
} else { } else {
$alipay = $configService->getSectionConfig('payment.alipay'); $alipay = $settingService->getSectionSettings('payment.alipay');
$wxpay = $configService->getSectionConfig('payment.wxpay'); $wxpay = $settingService->getSectionSettings('payment.wxpay');
$this->view->setVar('alipay', $alipay); $this->view->setVar('alipay', $alipay);
$this->view->setVar('wxpay', $wxpay); $this->view->setVar('wxpay', $wxpay);
@ -166,25 +166,25 @@ class ConfigController extends Controller
} }
/** /**
* @Route("/smser", name="admin.config.smser") * @Route("/smser", name="admin.setting.smser")
*/ */
public function smserAction() public function smserAction()
{ {
$section = 'smser'; $section = 'smser';
$configService = new ConfigService(); $settingService = new SettingService();
if ($this->request->isPost()) { if ($this->request->isPost()) {
$data = $this->request->getPost(); $data = $this->request->getPost();
$configService->updateSmserConfig($section, $data); $settingService->updateSmserSettings($section, $data);
return $this->jsonSuccess(['msg' => '更新配置成功']); return $this->jsonSuccess(['msg' => '更新配置成功']);
} else { } else {
$smser = $configService->getSectionConfig($section); $smser = $settingService->getSectionSettings($section);
$template = json_decode($smser->template); $template = json_decode($smser->template);
@ -194,44 +194,44 @@ class ConfigController extends Controller
} }
/** /**
* @Route("/mailer", name="admin.config.mailer") * @Route("/mailer", name="admin.setting.mailer")
*/ */
public function mailerAction() public function mailerAction()
{ {
$section = 'mailer'; $section = 'mailer';
$configService = new ConfigService(); $settingService = new SettingService();
if ($this->request->isPost()) { if ($this->request->isPost()) {
$data = $this->request->getPost(); $data = $this->request->getPost();
$configService->updateSectionConfig($section, $data); $settingService->updateSectionSettings($section, $data);
return $this->jsonSuccess(['msg' => '更新配置成功']); return $this->jsonSuccess(['msg' => '更新配置成功']);
} else { } else {
$mailer = $configService->getSectionConfig($section); $mailer = $settingService->getSectionSettings($section);
$this->view->setVar('mailer', $mailer); $this->view->setVar('mailer', $mailer);
} }
} }
/** /**
* @Route("/captcha", name="admin.config.captcha") * @Route("/captcha", name="admin.setting.captcha")
*/ */
public function captchaAction() public function captchaAction()
{ {
$section = 'captcha'; $section = 'captcha';
$configService = new ConfigService(); $settingService = new SettingService();
if ($this->request->isPost()) { if ($this->request->isPost()) {
$data = $this->request->getPost(); $data = $this->request->getPost();
$configService->updateSectionConfig($section, $data); $settingService->updateSectionSettings($section, $data);
$content = [ $content = [
'location' => $this->request->getHTTPReferer(), 'location' => $this->request->getHTTPReferer(),
@ -242,30 +242,30 @@ class ConfigController extends Controller
} else { } else {
$captcha = $configService->getSectionConfig($section); $captcha = $settingService->getSectionSettings($section);
$this->view->setVar('captcha', $captcha); $this->view->setVar('captcha', $captcha);
} }
} }
/** /**
* @Route("/vip", name="admin.config.vip") * @Route("/vip", name="admin.setting.vip")
*/ */
public function vipAction() public function vipAction()
{ {
$configService = new ConfigService(); $settingService = new SettingService();
if ($this->request->isPost()) { if ($this->request->isPost()) {
$data = $this->request->getPost('vip'); $data = $this->request->getPost('vip');
$configService->updateVipConfig($data); $settingService->updateVipSettings($data);
return $this->jsonSuccess(['msg' => '更新配置成功']); return $this->jsonSuccess(['msg' => '更新配置成功']);
} else { } else {
$vips = $configService->getVipConfig(); $vips = $settingService->getVipSettings();
$this->view->setVar('vips', $vips); $this->view->setVar('vips', $vips);
} }

View File

@ -3,7 +3,7 @@
namespace App\Http\Admin\Controllers; namespace App\Http\Admin\Controllers;
use App\Http\Admin\Services\AlipayTest as AlipayTestService; use App\Http\Admin\Services\AlipayTest as AlipayTestService;
use App\Http\Admin\Services\Config as ConfigService; use App\Http\Admin\Services\Setting as SettingService;
use App\Http\Admin\Services\WxpayTest as WxpayTestService; use App\Http\Admin\Services\WxpayTest as WxpayTestService;
use App\Services\Captcha as CaptchaService; use App\Services\Captcha as CaptchaService;
use App\Services\Live as LiveService; use App\Services\Live as LiveService;
@ -71,7 +71,7 @@ class TestController extends Controller
$obs->fms_url = substr($pushUrl, 0, $position + 1); $obs->fms_url = substr($pushUrl, 0, $position + 1);
$obs->stream_code = substr($pushUrl, $position + 1); $obs->stream_code = substr($pushUrl, $position + 1);
$this->view->pick('config/live_push_test'); $this->view->pick('setting/live_push_test');
$this->view->setVar('code_url', $codeUrl); $this->view->setVar('code_url', $codeUrl);
$this->view->setVar('obs', $obs); $this->view->setVar('obs', $obs);
@ -144,9 +144,9 @@ class TestController extends Controller
if ($result) { if ($result) {
$configService = new ConfigService(); $settingService = new SettingService();
$configService->updateSectionConfig('captcha', ['enabled' => 1]); $settingService->updateSectionSettings('captcha', ['enabled' => 1]);
return $this->jsonSuccess(['msg' => '后台验证成功']); return $this->jsonSuccess(['msg' => '后台验证成功']);
@ -183,7 +183,7 @@ class TestController extends Controller
); );
} }
$this->view->pick('config/payment_alipay_test'); $this->view->pick('setting/payment_alipay_test');
$this->view->setVar('trade_sn', $trade->sn); $this->view->setVar('trade_sn', $trade->sn);
$this->view->setVar('code_url', $codeUrl); $this->view->setVar('code_url', $codeUrl);
@ -236,7 +236,7 @@ class TestController extends Controller
$this->db->rollback(); $this->db->rollback();
} }
$this->view->pick('config/payment_wxpay_test'); $this->view->pick('setting/payment_wxpay_test');
$this->view->setVar('trade_sn', $trade->sn); $this->view->setVar('trade_sn', $trade->sn);
$this->view->setVar('code_url', $codeUrl); $this->view->setVar('code_url', $codeUrl);

View File

@ -8,7 +8,7 @@ use Phalcon\Mvc\User\Component;
class AuthMenu extends Component class AuthMenu extends Component
{ {
protected $authUser = []; protected $authUser;
protected $authNodes = []; protected $authNodes = [];
protected $ownedRoutes = []; protected $ownedRoutes = [];
protected $owned1stLevelIds = []; protected $owned1stLevelIds = [];
@ -27,7 +27,7 @@ class AuthMenu extends Component
$menus = []; $menus = [];
foreach ($this->authNodes as $node) { foreach ($this->authNodes as $node) {
if ($this->authUser['root'] || in_array($node['id'], $this->owned1stLevelIds)) { if ($this->authUser->id || in_array($node['id'], $this->owned1stLevelIds)) {
$menus[] = [ $menus[] = [
'id' => $node['id'], 'id' => $node['id'],
'label' => $node['label'], 'label' => $node['label'],
@ -45,7 +45,7 @@ class AuthMenu extends Component
foreach ($this->authNodes as $key => $level) { foreach ($this->authNodes as $key => $level) {
foreach ($level['child'] as $key2 => $level2) { foreach ($level['child'] as $key2 => $level2) {
foreach ($level2['child'] as $key3 => $level3) { foreach ($level2['child'] as $key3 => $level3) {
$hasRight = $this->authUser['root'] || in_array($level3['id'], $this->owned3rdLevelIds); $hasRight = $this->authUser->root || in_array($level3['id'], $this->owned3rdLevelIds);
if ($level3['type'] == 'menu' && $hasRight) { if ($level3['type'] == 'menu' && $hasRight) {
$menus[$key]['id'] = $level['id']; $menus[$key]['id'] = $level['id'];
$menus[$key]['label'] = $level['label']; $menus[$key]['label'] = $level['label'];
@ -76,7 +76,7 @@ class AuthMenu extends Component
foreach ($routeIdMapping as $key => $value) { foreach ($routeIdMapping as $key => $value) {
$ids = explode('-', $value); $ids = explode('-', $value);
if (in_array($key, $this->authUser['routes'])) { if (in_array($key, $this->authUser->routes)) {
$owned1stLevelIds[] = $ids[0]; $owned1stLevelIds[] = $ids[0];
$owned2ndLevelIds[] = $ids[0] . '-' . $ids[1]; $owned2ndLevelIds[] = $ids[0] . '-' . $ids[1];
$owned3rdLevelIds[] = $value; $owned3rdLevelIds[] = $value;

View File

@ -13,14 +13,14 @@ class AuthNode extends Service
$nodes[] = $this->getOperationNodes(); $nodes[] = $this->getOperationNodes();
$nodes[] = $this->getFinanceNodes(); $nodes[] = $this->getFinanceNodes();
$nodes[] = $this->getUserNodes(); $nodes[] = $this->getUserNodes();
$nodes[] = $this->getConfigNodes(); $nodes[] = $this->getSettingNodes();
return $nodes; return $nodes;
} }
protected function getContentNodes() protected function getContentNodes()
{ {
$nodes = [ return [
'id' => '1', 'id' => '1',
'label' => '内容管理', 'label' => '内容管理',
'child' => [ 'child' => [
@ -218,13 +218,11 @@ class AuthNode extends Service
], ],
], ],
]; ];
return $nodes;
} }
protected function getOperationNodes() protected function getOperationNodes()
{ {
$nodes = [ return [
'id' => '2', 'id' => '2',
'label' => '运营管理', 'label' => '运营管理',
'child' => [ 'child' => [
@ -416,13 +414,11 @@ class AuthNode extends Service
], ],
], ],
]; ];
return $nodes;
} }
protected function getFinanceNodes() protected function getFinanceNodes()
{ {
$nodes = [ return [
'id' => '3', 'id' => '3',
'label' => '财务管理', 'label' => '财务管理',
'child' => [ 'child' => [
@ -521,13 +517,11 @@ class AuthNode extends Service
], ],
], ],
]; ];
return $nodes;
} }
protected function getUserNodes() protected function getUserNodes()
{ {
$nodes = [ return [
'id' => '4', 'id' => '4',
'label' => '用户管理', 'label' => '用户管理',
'child' => [ 'child' => [
@ -620,13 +614,11 @@ class AuthNode extends Service
], ],
], ],
]; ];
return $nodes;
} }
protected function getConfigNodes() protected function getSettingNodes()
{ {
$nodes = [ return [
'id' => '5', 'id' => '5',
'label' => '系统配置', 'label' => '系统配置',
'child' => [ 'child' => [
@ -639,68 +631,66 @@ class AuthNode extends Service
'id' => '5-1-1', 'id' => '5-1-1',
'label' => '网站设置', 'label' => '网站设置',
'type' => 'menu', 'type' => 'menu',
'route' => 'admin.config.site', 'route' => 'admin.setting.site',
], ],
[ [
'id' => '5-1-2', 'id' => '5-1-2',
'label' => '密钥设置', 'label' => '密钥设置',
'type' => 'menu', 'type' => 'menu',
'route' => 'admin.config.secret', 'route' => 'admin.setting.secret',
], ],
[ [
'id' => '5-1-3', 'id' => '5-1-3',
'label' => '存储设置', 'label' => '存储设置',
'type' => 'menu', 'type' => 'menu',
'route' => 'admin.config.storage', 'route' => 'admin.setting.storage',
], ],
[ [
'id' => '5-1-4', 'id' => '5-1-4',
'label' => '点播设置', 'label' => '点播设置',
'type' => 'menu', 'type' => 'menu',
'route' => 'admin.config.vod', 'route' => 'admin.setting.vod',
], ],
[ [
'id' => '5-1-5', 'id' => '5-1-5',
'label' => '直播设置', 'label' => '直播设置',
'type' => 'menu', 'type' => 'menu',
'route' => 'admin.config.live', 'route' => 'admin.setting.live',
], ],
[ [
'id' => '5-1-6', 'id' => '5-1-6',
'label' => '短信设置', 'label' => '短信设置',
'type' => 'menu', 'type' => 'menu',
'route' => 'admin.config.smser', 'route' => 'admin.setting.smser',
], ],
[ [
'id' => '5-1-7', 'id' => '5-1-7',
'label' => '邮件设置', 'label' => '邮件设置',
'type' => 'menu', 'type' => 'menu',
'route' => 'admin.config.mailer', 'route' => 'admin.setting.mailer',
], ],
[ [
'id' => '5-1-8', 'id' => '5-1-8',
'label' => '验证码设置', 'label' => '验证码设置',
'type' => 'menu', 'type' => 'menu',
'route' => 'admin.config.captcha', 'route' => 'admin.setting.captcha',
], ],
[ [
'id' => '5-1-9', 'id' => '5-1-9',
'label' => '支付设置', 'label' => '支付设置',
'type' => 'menu', 'type' => 'menu',
'route' => 'admin.config.payment', 'route' => 'admin.setting.payment',
], ],
[ [
'id' => '5-1-10', 'id' => '5-1-10',
'label' => '会员设置', 'label' => '会员设置',
'type' => 'menu', 'type' => 'menu',
'route' => 'admin.config.vip', 'route' => 'admin.setting.vip',
] ]
], ],
], ],
], ],
]; ];
return $nodes;
} }
} }

View File

@ -1,137 +0,0 @@
<?php
namespace App\Http\Admin\Services;
use App\Caches\SectionConfig as SectionConfigCache;
use App\Repos\Config as ConfigRepo;
use App\Repos\Vip as VipRepo;
class Config extends Service
{
public function getSectionConfig($section)
{
$configRepo = new ConfigRepo();
$items = $configRepo->findBySection($section);
$result = new \stdClass();
if ($items->count() > 0) {
foreach ($items as $item) {
$result->{$item->item_key} = $item->item_value;
}
}
return $result;
}
public function updateSectionConfig($section, $config)
{
$configRepo = new ConfigRepo();
foreach ($config as $key => $value) {
$item = $configRepo->findItem($section, $key);
if ($item) {
$item->item_value = trim($value);
$item->update();
}
}
$cache = new SectionConfigCache();
$cache->rebuild($section);
}
public function updateStorageConfig($section, $config)
{
$protocol = ['http://', 'https://'];
if (isset($config['bucket_domain'])) {
$config['bucket_domain'] = str_replace($protocol, '', $config['bucket_domain']);
}
if (isset($config['ci_domain'])) {
$config['ci_domain'] = str_replace($protocol, '', $config['ci_domain']);
}
$this->updateSectionConfig($section, $config);
}
public function updateVodConfig($section, $config)
{
$this->updateSectionConfig($section, $config);
}
public function updateLiveConfig($section, $config)
{
$protocol = ['http://', 'https://'];
if (isset($config['push_domain'])) {
$config['push_domain'] = str_replace($protocol, '', $config['push_domain']);
}
if (isset($config['pull_domain'])) {
$config['pull_domain'] = str_replace($protocol, '', $config['pull_domain']);
}
if (isset($config['ptt'])) {
$ptt = $config['ptt'];
$keys = array_keys($ptt['id']);
$myPtt = [];
foreach ($keys as $key) {
$myPtt[$key] = [
'id' => $ptt['id'][$key],
'bit_rate' => $ptt['bit_rate'][$key],
'summary' => $ptt['summary'][$key],
'height' => $ptt['height'][$key],
];
}
$config['pull_trans_template'] = kg_json_encode($myPtt);
}
$this->updateSectionConfig($section, $config);
}
public function updateSmserConfig($section, $config)
{
$template = $config['template'];
$keys = array_keys($template['id']);
$myTemplate = [];
foreach ($keys as $key) {
$myTemplate[$key] = [
'id' => $template['id'][$key],
'content' => $template['content'][$key],
];
}
$config['template'] = kg_json_encode($myTemplate);
$this->updateSectionConfig($section, $config);
}
public function getVipConfig()
{
$vipRepo = new VipRepo();
$config = $vipRepo->findAll(['deleted' => 0]);
return $config;
}
public function updateVipConfig($items)
{
$vipRepo = new VipRepo();
foreach ($items as $id => $price) {
$vip = $vipRepo->findById($id);
$vip->price = $price;
$vip->update();
}
}
}

View File

@ -27,9 +27,9 @@ class Session extends Service
$user = $accountValidator->checkAdminLogin($post['account'], $post['password']); $user = $accountValidator->checkAdminLogin($post['account'], $post['password']);
$config = new Config(); $setting = new Setting();
$captcha = $config->getSectionConfig('captcha'); $captcha = $setting->getSectionSettings('captcha');
$securityValidator = new SecurityValidator(); $securityValidator = new SecurityValidator();

View File

@ -0,0 +1,135 @@
<?php
namespace App\Http\Admin\Services;
use App\Caches\Setting as SettingCache;
use App\Repos\Setting as SettingRepo;
use App\Repos\Vip as VipRepo;
class Setting extends Service
{
public function getSectionSettings($section)
{
$settingsRepo = new SettingRepo();
$items = $settingsRepo->findBySection($section);
$result = new \stdClass();
if ($items->count() > 0) {
foreach ($items as $item) {
$result->{$item->item_key} = $item->item_value;
}
}
return $result;
}
public function updateSectionSettings($section, $settings)
{
$settingsRepo = new SettingRepo();
foreach ($settings as $key => $value) {
$item = $settingsRepo->findItem($section, $key);
if ($item) {
$item->item_value = trim($value);
$item->update();
}
}
$cache = new SettingCache();
$cache->rebuild($section);
}
public function updateStorageSettings($section, $settings)
{
$protocol = ['http://', 'https://'];
if (isset($settings['bucket_domain'])) {
$settings['bucket_domain'] = str_replace($protocol, '', $settings['bucket_domain']);
}
if (isset($settings['ci_domain'])) {
$settings['ci_domain'] = str_replace($protocol, '', $settings['ci_domain']);
}
$this->updateSectionSettings($section, $settings);
}
public function updateVodSettings($section, $settings)
{
$this->updateSectionSettings($section, $settings);
}
public function updateLiveSettings($section, $settings)
{
$protocol = ['http://', 'https://'];
if (isset($settings['push_domain'])) {
$settings['push_domain'] = str_replace($protocol, '', $settings['push_domain']);
}
if (isset($settings['pull_domain'])) {
$settings['pull_domain'] = str_replace($protocol, '', $settings['pull_domain']);
}
if (isset($settings['ptt'])) {
$ptt = $settings['ptt'];
$keys = array_keys($ptt['id']);
$myPtt = [];
foreach ($keys as $key) {
$myPtt[$key] = [
'id' => $ptt['id'][$key],
'bit_rate' => $ptt['bit_rate'][$key],
'summary' => $ptt['summary'][$key],
'height' => $ptt['height'][$key],
];
}
$settings['pull_trans_template'] = kg_json_encode($myPtt);
}
$this->updateSectionSettings($section, $settings);
}
public function updateSmserSettings($section, $settings)
{
$template = $settings['template'];
$keys = array_keys($template['id']);
$myTemplate = [];
foreach ($keys as $key) {
$myTemplate[$key] = [
'id' => $template['id'][$key],
'content' => $template['content'][$key],
];
}
$settings['template'] = kg_json_encode($myTemplate);
$this->updateSectionSettings($section, $settings);
}
public function getVipSettings()
{
$vipRepo = new VipRepo();
return $vipRepo->findAll(['deleted' => 0]);
}
public function updateVipSettings($items)
{
$vipRepo = new VipRepo();
foreach ($items as $id => $price) {
$vip = $vipRepo->findById($id);
$vip->price = $price;
$vip->update();
}
}
}

View File

@ -1,4 +1,4 @@
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.config.captcha'}) }}"> <form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.captcha'}) }}">
<fieldset class="layui-elem-field layui-field-title"> <fieldset class="layui-elem-field layui-field-title">
<legend>验证码配置</legend> <legend>验证码配置</legend>

View File

@ -5,10 +5,10 @@
</ul> </ul>
<div class="layui-tab-content"> <div class="layui-tab-content">
<div class="layui-tab-item layui-show"> <div class="layui-tab-item layui-show">
{{ partial('config/live_push') }} {{ partial('setting/live_push') }}
</div> </div>
<div class="layui-tab-item"> <div class="layui-tab-item">
{{ partial('config/live_pull') }} {{ partial('setting/live_pull') }}
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,4 +1,4 @@
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.config.live'}) }}"> <form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.live'}) }}">
<fieldset class="layui-elem-field layui-field-title"> <fieldset class="layui-elem-field layui-field-title">
<legend>基础配置</legend> <legend>基础配置</legend>

View File

@ -1,4 +1,4 @@
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.config.live'}) }}"> <form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.live'}) }}">
<fieldset class="layui-elem-field layui-field-title"> <fieldset class="layui-elem-field layui-field-title">
<legend>基础配置</legend> <legend>基础配置</legend>

View File

@ -1,4 +1,4 @@
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.config.mailer'}) }}"> <form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.mailer'}) }}">
<fieldset class="layui-elem-field layui-field-title"> <fieldset class="layui-elem-field layui-field-title">
<legend>邮件配置</legend> <legend>邮件配置</legend>

View File

@ -5,10 +5,10 @@
</ul> </ul>
<div class="layui-tab-content"> <div class="layui-tab-content">
<div class="layui-tab-item layui-show"> <div class="layui-tab-item layui-show">
{{ partial('config/payment_alipay') }} {{ partial('setting/payment_alipay') }}
</div> </div>
<div class="layui-tab-item"> <div class="layui-tab-item">
{{ partial('config/payment_wxpay') }} {{ partial('setting/payment_wxpay') }}
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,4 +1,4 @@
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.config.payment'}) }}"> <form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.payment'}) }}">
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">开启支付</label> <label class="layui-form-label">开启支付</label>

View File

@ -1,4 +1,4 @@
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.config.payment'}) }}"> <form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.payment'}) }}">
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">开启支付</label> <label class="layui-form-label">开启支付</label>

View File

@ -1,4 +1,4 @@
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.config.secret'}) }}"> <form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.secret'}) }}">
<fieldset class="layui-elem-field layui-field-title"> <fieldset class="layui-elem-field layui-field-title">
<legend>密钥配置</legend> <legend>密钥配置</legend>

View File

@ -1,4 +1,4 @@
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.config.site'}) }}"> <form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.site'}) }}">
<fieldset class="layui-elem-field layui-field-title"> <fieldset class="layui-elem-field layui-field-title">
<legend>站点配置</legend> <legend>站点配置</legend>

View File

@ -1,4 +1,4 @@
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.config.smser'}) }}"> <form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.smser'}) }}">
<fieldset class="layui-elem-field layui-field-title"> <fieldset class="layui-elem-field layui-field-title">
<legend>基础配置</legend> <legend>基础配置</legend>

View File

@ -1,4 +1,4 @@
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.config.storage'}) }}"> <form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.storage'}) }}">
<fieldset class="layui-elem-field layui-field-title"> <fieldset class="layui-elem-field layui-field-title">
<legend>存储桶配置</legend> <legend>存储桶配置</legend>

View File

@ -1,4 +1,4 @@
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.config.vip'}) }}"> <form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.vip'}) }}">
<fieldset class="layui-elem-field layui-field-title"> <fieldset class="layui-elem-field layui-field-title">
<legend>会员设置</legend> <legend>会员设置</legend>

View File

@ -1,4 +1,4 @@
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.config.vod'}) }}"> <form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.vod'}) }}">
<fieldset class="layui-elem-field layui-field-title"> <fieldset class="layui-elem-field layui-field-title">
<legend>存储配置</legend> <legend>存储配置</legend>

View File

@ -13,7 +13,7 @@ class IndexController extends Controller
*/ */
public function indexAction() public function indexAction()
{ {
return $this->jsonSuccess(['data' => 'ok']);
} }
/** /**

View File

@ -3,7 +3,7 @@
namespace App\Http\Web\Controllers; namespace App\Http\Web\Controllers;
use App\Caches\NavTreeList as NavTreeListCache; use App\Caches\NavTreeList as NavTreeListCache;
use App\Caches\SectionConfig as SectionConfigCache; use App\Caches\Setting as SettingCache;
use App\Services\Auth\Web as WebAuth; use App\Services\Auth\Web as WebAuth;
use App\Traits\Response as ResponseTrait; use App\Traits\Response as ResponseTrait;
use App\Traits\Security as SecurityTrait; use App\Traits\Security as SecurityTrait;
@ -12,7 +12,7 @@ use Phalcon\Mvc\Dispatcher;
class Controller extends \Phalcon\Mvc\Controller class Controller extends \Phalcon\Mvc\Controller
{ {
protected $siteConfig; protected $siteSettings;
protected $navList; protected $navList;
protected $authUser; protected $authUser;
@ -38,7 +38,7 @@ class Controller extends \Phalcon\Mvc\Controller
} }
} }
$this->siteConfig = $this->getSiteConfig(); $this->siteSettings = $this->getSiteSettings();
$this->navList = $this->getNavList(); $this->navList = $this->getNavList();
$this->authUser = $this->getAuthUser(); $this->authUser = $this->getAuthUser();
@ -48,7 +48,7 @@ class Controller extends \Phalcon\Mvc\Controller
public function initialize() public function initialize()
{ {
$this->view->setVar('auth_user', $this->authUser); $this->view->setVar('auth_user', $this->authUser);
$this->view->setVar('site_config', $this->siteConfig); $this->view->setVar('site_settings', $this->siteSettings);
$this->view->setVar('top_nav_list', $this->navList['top']); $this->view->setVar('top_nav_list', $this->navList['top']);
$this->view->setVar('btm_nav_list', $this->navList['bottom']); $this->view->setVar('btm_nav_list', $this->navList['bottom']);
} }
@ -70,11 +70,11 @@ class Controller extends \Phalcon\Mvc\Controller
return $treeListCache->get(); return $treeListCache->get();
} }
protected function getSiteConfig() protected function getSiteSettings()
{ {
$sectionCache = new SectionConfigCache(); $settingCache = new SettingCache();
return $sectionCache->get('site'); return $settingCache->get('site');
} }
} }

View File

@ -2,7 +2,7 @@
namespace App\Listeners; namespace App\Listeners;
use App\Caches\SectionConfig as SectionConfigCache; use App\Caches\Setting as SectionConfigCache;
use App\Library\Logger as AppLogger; use App\Library\Logger as AppLogger;
use Phalcon\Logger\Adapter\File as FileLogger; use Phalcon\Logger\Adapter\File as FileLogger;
use Phalcon\Mvc\User\Plugin as UserPlugin; use Phalcon\Mvc\User\Plugin as UserPlugin;
@ -31,7 +31,7 @@ class Listener extends UserPlugin
* @param string $section * @param string $section
* @return array * @return array
*/ */
public function getSectionConfig($section) public function getSectionSettings($section)
{ {
$cache = new SectionConfigCache(); $cache = new SectionConfigCache();

View File

@ -2,7 +2,7 @@
namespace App\Models; namespace App\Models;
class Config extends Model class Setting extends Model
{ {
/** /**
@ -35,7 +35,7 @@ class Config extends Model
public function getSource() public function getSource()
{ {
return 'kg_config'; return 'kg_setting';
} }
} }

View File

@ -2,21 +2,21 @@
namespace App\Repos; namespace App\Repos;
use App\Models\Config as ConfigModel; use App\Models\Setting as SettingModel;
use Phalcon\Mvc\Model; use Phalcon\Mvc\Model;
use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface; use Phalcon\Mvc\Model\ResultsetInterface;
class Config extends Repository class Setting extends Repository
{ {
/** /**
* @param array $where * @param array $where
* @return Resultset|ResultsetInterface|ConfigModel[] * @return ResultsetInterface|Resultset|SettingModel[]
*/ */
public function findAll($where = []) public function findAll($where = [])
{ {
$query = ConfigModel::query(); $query = SettingModel::query();
$query->where('1 = 1'); $query->where('1 = 1');
@ -30,11 +30,11 @@ class Config extends Repository
/** /**
* @param string $section * @param string $section
* @param string $itemKey * @param string $itemKey
* @return ConfigModel|Model|bool * @return SettingModel|Model|bool
*/ */
public function findItem($section, $itemKey) public function findItem($section, $itemKey)
{ {
return ConfigModel::findFirst([ return SettingModel::findFirst([
'conditions' => 'section = :section: AND item_key = :item_key:', 'conditions' => 'section = :section: AND item_key = :item_key:',
'bind' => ['section' => $section, 'item_key' => $itemKey], 'bind' => ['section' => $section, 'item_key' => $itemKey],
]); ]);
@ -42,11 +42,11 @@ class Config extends Repository
/** /**
* @param string $section * @param string $section
* @return Resultset|ResultsetInterface|ConfigModel[] * @return ResultsetInterface|Resultset|SettingModel[]
*/ */
public function findBySection($section) public function findBySection($section)
{ {
$query = ConfigModel::query(); $query = SettingModel::query();
$query->where('section = :section:', ['section' => $section]); $query->where('section = :section:', ['section' => $section]);

View File

@ -18,7 +18,7 @@ class Captcha extends Service
/** /**
* @var array * @var array
*/ */
protected $config; protected $settings;
/** /**
* @var FileLogger * @var FileLogger
@ -32,7 +32,7 @@ class Captcha extends Service
public function __construct() public function __construct()
{ {
$this->config = $this->getSectionConfig('captcha'); $this->settings = $this->getSectionSettings('captcha');
$this->logger = $this->getLogger('captcha'); $this->logger = $this->getLogger('captcha');
@ -50,8 +50,8 @@ class Captcha extends Service
{ {
$userIp = $this->request->getClientAddress(); $userIp = $this->request->getClientAddress();
$appId = $this->config['app_id']; $appId = $this->settings['app_id'];
$secretKey = $this->config['secret_key']; $secretKey = $this->settings['secret_key'];
$captchaType = 9; $captchaType = 9;
try { try {
@ -103,12 +103,12 @@ class Captcha extends Service
*/ */
public function getCaptchaClient() public function getCaptchaClient()
{ {
$secret = $this->getSectionConfig('secret'); $secret = $this->getSectionSettings('secret');
$secretId = $secret['secret_id']; $secretId = $secret['secret_id'];
$secretKey = $secret['secret_key']; $secretKey = $secret['secret_key'];
$region = $this->config['region'] ?? 'ap-guangzhou'; $region = $this->settings['region'] ?? 'ap-guangzhou';
$credential = new Credential($secretId, $secretKey); $credential = new Credential($secretId, $secretKey);

View File

@ -8,11 +8,11 @@ class Live extends Service
/** /**
* @var array * @var array
*/ */
protected $config; protected $settings;
public function __construct() public function __construct()
{ {
$this->config = $this->getSectionConfig('live'); $this->settings = $this->getSectionSettings('live');
} }
/** /**
@ -23,10 +23,10 @@ class Live extends Service
*/ */
function getPushUrl($streamName) function getPushUrl($streamName)
{ {
$authEnabled = $this->config['push_auth_enabled']; $authEnabled = $this->settings['push_auth_enabled'];
$authKey = $this->config['push_auth_key']; $authKey = $this->settings['push_auth_key'];
$expireTime = $this->config['push_auth_delta'] + time(); $expireTime = $this->settings['push_auth_delta'] + time();
$domain = $this->config['push_domain']; $domain = $this->settings['push_domain'];
$appName = 'live'; $appName = 'live';
$authParams = $this->getAuthParams($streamName, $authKey, $expireTime); $authParams = $this->getAuthParams($streamName, $authKey, $expireTime);
@ -56,12 +56,12 @@ class Live extends Service
$appName = 'live'; $appName = 'live';
$protocol = $this->config['pull_protocol']; $protocol = $this->settings['pull_protocol'];
$domain = $this->config['pull_domain']; $domain = $this->settings['pull_domain'];
$authEnabled = $this->config['pull_auth_enabled']; $authEnabled = $this->settings['pull_auth_enabled'];
$transEnabled = $this->config['pull_trans_enabled']; $transEnabled = $this->settings['pull_trans_enabled'];
$authKey = $this->config['pull_auth_key']; $authKey = $this->settings['pull_auth_key'];
$expireTime = $this->config['pull_auth_delta'] + time(); $expireTime = $this->settings['pull_auth_delta'] + time();
$urls = []; $urls = [];

View File

@ -30,7 +30,7 @@ abstract class Mailer extends Service
*/ */
protected function getManager() protected function getManager()
{ {
$opt = $this->getSectionConfig('mailer'); $opt = $this->getSectionSettings('mailer');
$config = [ $config = [
'driver' => 'smtp', 'driver' => 'smtp',

View File

@ -16,7 +16,7 @@ class Alipay extends Payment
/** /**
* @var array * @var array
*/ */
protected $config; protected $settings;
/** /**
* @var \Yansongda\Pay\Gateways\Alipay * @var \Yansongda\Pay\Gateways\Alipay
@ -25,7 +25,7 @@ class Alipay extends Payment
public function __construct() public function __construct()
{ {
$this->config = $this->getSectionConfig('payment.alipay'); $this->settings = $this->getSectionSettings('payment.alipay');
$this->gateway = $this->getGateway(); $this->gateway = $this->getGateway();
} }
@ -86,7 +86,7 @@ class Alipay extends Payment
return false; return false;
} }
if ($data->app_id != $this->config['app_id']) { if ($data->app_id != $this->settings['app_id']) {
return false; return false;
} }
@ -245,10 +245,10 @@ class Alipay extends Payment
$level = $config->env == ENV_DEV ? 'debug' : 'info'; $level = $config->env == ENV_DEV ? 'debug' : 'info';
$payConfig = [ $payConfig = [
'app_id' => $this->config['app_id'], 'app_id' => $this->settings['app_id'],
'ali_public_key' => $this->config['public_key'], 'ali_public_key' => $this->settings['public_key'],
'private_key' => $this->config['private_key'], 'private_key' => $this->settings['private_key'],
'notify_url' => $this->config['notify_url'], 'notify_url' => $this->settings['notify_url'],
'log' => [ 'log' => [
'file' => log_path('alipay.log'), 'file' => log_path('alipay.log'),
'level' => $level, 'level' => $level,

View File

@ -17,7 +17,7 @@ class Wxpay extends Payment
/** /**
* @var array * @var array
*/ */
protected $config; protected $settings;
/** /**
* @var Wechat * @var Wechat
@ -26,7 +26,7 @@ class Wxpay extends Payment
public function __construct() public function __construct()
{ {
$this->config = $this->getSectionConfig('payment.wxpay'); $this->settings = $this->getSectionSettings('payment.wxpay');
$this->gateway = $this->getGateway(); $this->gateway = $this->getGateway();
} }
@ -87,7 +87,7 @@ class Wxpay extends Payment
return false; return false;
} }
if ($data->mch_id != $this->config['mch_id']) { if ($data->mch_id != $this->settings['mch_id']) {
return false; return false;
} }
@ -227,10 +227,10 @@ class Wxpay extends Payment
$level = $config->env == ENV_DEV ? 'debug' : 'info'; $level = $config->env == ENV_DEV ? 'debug' : 'info';
$payConfig = [ $payConfig = [
'app_id' => $this->config['app_id'], 'app_id' => $this->settings['app_id'],
'mch_id' => $this->config['mch_id'], 'mch_id' => $this->settings['mch_id'],
'key' => $this->config['key'], 'key' => $this->settings['key'],
'notify_url' => $this->config['notify_url'], 'notify_url' => $this->settings['notify_url'],
'log' => [ 'log' => [
'file' => log_path('wxpay.log'), 'file' => log_path('wxpay.log'),
'level' => $level, 'level' => $level,

View File

@ -2,7 +2,7 @@
namespace App\Services; namespace App\Services;
use App\Caches\SectionConfig as SectionConfigCache; use App\Caches\Setting as SettingCache;
use App\Library\Logger as AppLogger; use App\Library\Logger as AppLogger;
use App\Traits\Auth as AuthTrait; use App\Traits\Auth as AuthTrait;
use Phalcon\Logger\Adapter\File as FileLogger; use Phalcon\Logger\Adapter\File as FileLogger;
@ -34,11 +34,11 @@ class Service extends Component
* @param string $section * @param string $section
* @return array * @return array
*/ */
public function getSectionConfig($section) public function getSectionSettings($section)
{ {
$cache = new SectionConfigCache(); $settingCache = new SettingCache();
return $cache->get($section); return $settingCache->get($section);
} }
} }

View File

@ -11,7 +11,7 @@ Abstract class Smser extends Service
/** /**
* @var array * @var array
*/ */
protected $config; protected $settings;
/** /**
* @var FileLogger * @var FileLogger
@ -20,7 +20,7 @@ Abstract class Smser extends Service
public function __construct() public function __construct()
{ {
$this->config = $this->getSectionConfig('smser'); $this->settings = $this->getSectionSettings('smser');
$this->logger = $this->getLogger('smser'); $this->logger = $this->getLogger('smser');
} }
@ -64,19 +64,19 @@ Abstract class Smser extends Service
protected function createSingleSender() protected function createSingleSender()
{ {
return new SmsSingleSender($this->config['app_id'], $this->config['app_key']); return new SmsSingleSender($this->settings['app_id'], $this->settings['app_key']);
} }
protected function getTemplateId($code) protected function getTemplateId($code)
{ {
$template = json_decode($this->config['template'], true); $template = json_decode($this->settings['template'], true);
return $template[$code]['id'] ?? null; return $template[$code]['id'] ?? null;
} }
protected function getSignature() protected function getSignature()
{ {
return $this->config['signature']; return $this->settings['signature'];
} }
} }

View File

@ -12,7 +12,7 @@ class Storage extends Service
/** /**
* @var array * @var array
*/ */
protected $config; protected $settings;
/** /**
* @var FileLogger * @var FileLogger
@ -26,7 +26,7 @@ class Storage extends Service
public function __construct() public function __construct()
{ {
$this->config = $this->getSectionConfig('storage'); $this->settings = $this->getSectionSettings('storage');
$this->logger = $this->getLogger('storage'); $this->logger = $this->getLogger('storage');
@ -125,7 +125,7 @@ class Storage extends Service
*/ */
public function putString($key, $body) public function putString($key, $body)
{ {
$bucket = $this->config['bucket_name']; $bucket = $this->settings['bucket_name'];
try { try {
@ -155,7 +155,7 @@ class Storage extends Service
*/ */
public function putFile($key, $fileName) public function putFile($key, $fileName)
{ {
$bucket = $this->config['bucket_name']; $bucket = $this->settings['bucket_name'];
try { try {
@ -208,8 +208,8 @@ class Storage extends Service
*/ */
public function getBucketBaseUrl() public function getBucketBaseUrl()
{ {
$protocol = $this->config['bucket_protocol']; $protocol = $this->settings['bucket_protocol'];
$domain = $this->config['bucket_domain']; $domain = $this->settings['bucket_domain'];
return $protocol . '://' . $domain; return $protocol . '://' . $domain;
} }
@ -221,8 +221,8 @@ class Storage extends Service
*/ */
public function getCiBaseUrl() public function getCiBaseUrl()
{ {
$protocol = $this->config['ci_protocol']; $protocol = $this->settings['ci_protocol'];
$domain = $this->config['ci_domain']; $domain = $this->settings['ci_domain'];
return $protocol . '://' . $domain; return $protocol . '://' . $domain;
} }
@ -261,11 +261,11 @@ class Storage extends Service
*/ */
public function getCosClient() public function getCosClient()
{ {
$secret = $this->getSectionConfig('secret'); $secret = $this->getSectionSettings('secret');
return new CosClient([ return new CosClient([
'region' => $this->config['bucket_region'], 'region' => $this->settings['bucket_region'],
'schema' => $this->config['bucket_protocol'], 'schema' => $this->settings['bucket_protocol'],
'credentials' => [ 'credentials' => [
'secretId' => $secret['secret_id'], 'secretId' => $secret['secret_id'],
'secretKey' => $secret['secret_key'], 'secretKey' => $secret['secret_key'],

View File

@ -23,7 +23,7 @@ class Vod extends Service
/** /**
* @var array * @var array
*/ */
protected $config; protected $settings;
/** /**
* @var VodClient * @var VodClient
@ -37,7 +37,7 @@ class Vod extends Service
public function __construct() public function __construct()
{ {
$this->config = $this->getSectionConfig('vod'); $this->settings = $this->getSectionSettings('vod');
$this->logger = $this->getLogger('vod'); $this->logger = $this->getLogger('vod');
@ -86,7 +86,7 @@ class Vod extends Service
*/ */
public function getUploadSignature() public function getUploadSignature()
{ {
$secret = $this->getSectionConfig('secret'); $secret = $this->getSectionSettings('secret');
$secretId = $secret['secret_id']; $secretId = $secret['secret_id'];
$secretKey = $secret['secret_key']; $secretKey = $secret['secret_key'];
@ -152,12 +152,12 @@ class Vod extends Service
*/ */
public function getPlayUrl($url) public function getPlayUrl($url)
{ {
if ($this->config['key_anti_enabled'] == 0) { if ($this->settings['key_anti_enabled'] == 0) {
return $url; return $url;
} }
$key = $this->config['key_anti_key']; $key = $this->settings['key_anti_key'];
$expiry = $this->config['key_anti_expiry'] ?: 10800; $expiry = $this->settings['key_anti_expiry'] ?: 10800;
$path = parse_url($url, PHP_URL_PATH); $path = parse_url($url, PHP_URL_PATH);
$pos = strrpos($path, '/'); $pos = strrpos($path, '/');
@ -574,8 +574,8 @@ class Vod extends Service
{ {
$result = null; $result = null;
if ($this->config['watermark_enabled'] && $this->config['watermark_template'] > 0) { if ($this->settings['watermark_enabled'] && $this->settings['watermark_template'] > 0) {
$result = (int)$this->config['watermark_template']; $result = (int)$this->settings['watermark_template'];
} }
return $result; return $result;
@ -600,7 +600,7 @@ class Vod extends Service
30 => ['width' => 1280, 'bit_rate' => 1024, 'frame_rate' => 25], 30 => ['width' => 1280, 'bit_rate' => 1024, 'frame_rate' => 25],
]; ];
$format = $this->config['video_format']; $format = $this->settings['video_format'];
return $format == 'hls' ? $hls : $mp4; return $format == 'hls' ? $hls : $mp4;
} }
@ -621,7 +621,7 @@ class Vod extends Service
1010 => ['bit_rate' => 128, 'sample_rate' => 44100], 1010 => ['bit_rate' => 128, 'sample_rate' => 44100],
]; ];
return $this->config['audio_format'] == 'm4a' ? $m4a : $mp3; return $this->settings['audio_format'] == 'm4a' ? $m4a : $mp3;
} }
/** /**
@ -631,12 +631,12 @@ class Vod extends Service
*/ */
public function getVodClient() public function getVodClient()
{ {
$secret = $this->getSectionConfig('secret'); $secret = $this->getSectionSettings('secret');
$secretId = $secret['secret_id']; $secretId = $secret['secret_id'];
$secretKey = $secret['secret_key']; $secretKey = $secret['secret_key'];
$region = $this->config['storage_type'] == 'fixed' ? $this->config['storage_region'] : ''; $region = $this->settings['storage_type'] == 'fixed' ? $this->settings['storage_region'] : '';
$credential = new Credential($secretId, $secretKey); $credential = new Credential($secretId, $secretKey);