mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-21 03:17:05 +08:00
408 lines
9.5 KiB
PHP
408 lines
9.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Admin\Controllers;
|
|
|
|
use App\Http\Admin\Services\Setting as SettingService;
|
|
|
|
/**
|
|
* @RoutePrefix("/admin/setting")
|
|
*/
|
|
class SettingController extends Controller
|
|
{
|
|
|
|
/**
|
|
* @Route("/site", name="admin.setting.site")
|
|
*/
|
|
public function siteAction()
|
|
{
|
|
$section = 'site';
|
|
|
|
$settingService = new SettingService();
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
$data = $this->request->getPost();
|
|
|
|
$settingService->updateSettings($section, $data);
|
|
|
|
return $this->jsonSuccess(['msg' => '更新配置成功']);
|
|
|
|
} else {
|
|
|
|
$site = $settingService->getSettings($section);
|
|
|
|
$site['url'] = $site['url'] ?: kg_site_url();
|
|
|
|
$this->view->setVar('site', $site);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @Route("/secret", name="admin.setting.secret")
|
|
*/
|
|
public function secretAction()
|
|
{
|
|
$section = 'secret';
|
|
|
|
$settingService = new SettingService();
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
$data = $this->request->getPost();
|
|
|
|
$settingService->updateSettings($section, $data);
|
|
|
|
return $this->jsonSuccess(['msg' => '更新配置成功']);
|
|
|
|
} else {
|
|
|
|
$secret = $settingService->getSettings($section);
|
|
|
|
$this->view->setVar('secret', $secret);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @Route("/storage", name="admin.setting.storage")
|
|
*/
|
|
public function storageAction()
|
|
{
|
|
$section = 'cos';
|
|
|
|
$settingService = new SettingService();
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
$data = $this->request->getPost();
|
|
|
|
$settingService->updateStorageSettings($section, $data);
|
|
|
|
return $this->jsonSuccess(['msg' => '更新配置成功']);
|
|
|
|
} else {
|
|
|
|
$cos = $settingService->getSettings($section);
|
|
|
|
$this->view->setVar('cos', $cos);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @Route("/vod", name="admin.setting.vod")
|
|
*/
|
|
public function vodAction()
|
|
{
|
|
$section = 'vod';
|
|
|
|
$settingService = new SettingService();
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
$data = $this->request->getPost();
|
|
|
|
$settingService->updateVodSettings($section, $data);
|
|
|
|
return $this->jsonSuccess(['msg' => '更新配置成功']);
|
|
|
|
} else {
|
|
|
|
$vod = $settingService->getSettings($section);
|
|
|
|
$this->view->setVar('vod', $vod);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @Route("/live", name="admin.setting.live")
|
|
*/
|
|
public function liveAction()
|
|
{
|
|
$settingService = new SettingService();
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
$section = $this->request->getPost('section', 'string');
|
|
|
|
$data = $this->request->getPost();
|
|
|
|
$settingService->updateLiveSettings($section, $data);
|
|
|
|
return $this->jsonSuccess(['msg' => '更新配置成功']);
|
|
|
|
} else {
|
|
|
|
$push = $settingService->getLiveSettings('live.push');
|
|
$pull = $settingService->getLiveSettings('live.pull');
|
|
$notify = $settingService->getLiveSettings('live.notify');
|
|
|
|
$this->view->setVar('push', $push);
|
|
$this->view->setVar('pull', $pull);
|
|
$this->view->setVar('notify', $notify);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @Route("/pay", name="admin.setting.pay")
|
|
*/
|
|
public function payAction()
|
|
{
|
|
$settingService = new SettingService();
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
$section = $this->request->getPost('section', 'string');
|
|
|
|
$data = $this->request->getPost();
|
|
|
|
$settingService->updateSettings($section, $data);
|
|
|
|
return $this->jsonSuccess(['msg' => '更新配置成功']);
|
|
|
|
} else {
|
|
|
|
$alipay = $settingService->getAlipaySettings();
|
|
$wxpay = $settingService->getWxpaySettings();
|
|
|
|
$this->view->setVar('alipay', $alipay);
|
|
$this->view->setVar('wxpay', $wxpay);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @Route("/sms", name="admin.setting.sms")
|
|
*/
|
|
public function smsAction()
|
|
{
|
|
$section = 'sms';
|
|
|
|
$settingService = new SettingService();
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
$data = $this->request->getPost();
|
|
|
|
$settingService->updateSmsSettings($section, $data);
|
|
|
|
return $this->jsonSuccess(['msg' => '更新配置成功']);
|
|
|
|
} else {
|
|
|
|
$sms = $settingService->getSettings($section);
|
|
|
|
$this->view->setVar('sms', $sms);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @Route("/mail", name="admin.setting.mail")
|
|
*/
|
|
public function mailAction()
|
|
{
|
|
$section = 'mail';
|
|
|
|
$settingService = new SettingService();
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
$data = $this->request->getPost();
|
|
|
|
$settingService->updateSettings($section, $data);
|
|
|
|
return $this->jsonSuccess(['msg' => '更新配置成功']);
|
|
|
|
} else {
|
|
|
|
$mail = $settingService->getSettings($section);
|
|
|
|
$this->view->setVar('mail', $mail);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @Route("/captcha", name="admin.setting.captcha")
|
|
*/
|
|
public function captchaAction()
|
|
{
|
|
$section = 'captcha';
|
|
|
|
$settingService = new SettingService();
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
$data = $this->request->getPost();
|
|
|
|
$settingService->updateSettings($section, $data);
|
|
|
|
$content = [
|
|
'location' => $this->request->getHTTPReferer(),
|
|
'msg' => '更新配置成功',
|
|
];
|
|
|
|
return $this->jsonSuccess($content);
|
|
|
|
} else {
|
|
|
|
$captcha = $settingService->getSettings($section);
|
|
|
|
$this->view->setVar('captcha', $captcha);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @Route("/point", name="admin.setting.point")
|
|
*/
|
|
public function pointAction()
|
|
{
|
|
$section = 'point';
|
|
|
|
$settingService = new SettingService();
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
$data = $this->request->getPost();
|
|
|
|
$settingService->updatePointSettings($section, $data);
|
|
|
|
return $this->jsonSuccess(['msg' => '更新配置成功']);
|
|
|
|
} else {
|
|
|
|
$point = $settingService->getSettings($section);
|
|
|
|
$this->view->setVar('point', $point);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @Route("/vip", name="admin.setting.vip")
|
|
*/
|
|
public function vipAction()
|
|
{
|
|
$settingService = new SettingService();
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
$data = $this->request->getPost('vip');
|
|
|
|
$settingService->updateVipSettings($data);
|
|
|
|
return $this->jsonSuccess(['msg' => '更新配置成功']);
|
|
|
|
} else {
|
|
|
|
$items = $settingService->getVipSettings();
|
|
|
|
$this->view->setVar('items', $items);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @Route("/im", name="admin.setting.im")
|
|
*/
|
|
public function imAction()
|
|
{
|
|
$settingService = new SettingService();
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
$section = $this->request->getPost('section', 'string');
|
|
|
|
$data = $this->request->getPost();
|
|
|
|
$settingService->updateSettings($section, $data);
|
|
|
|
return $this->jsonSuccess(['msg' => '更新配置成功']);
|
|
|
|
} else {
|
|
|
|
$main = $settingService->getSettings('im.main');
|
|
$cs = $settingService->getSettings('im.cs');
|
|
|
|
$this->view->setVar('main', $main);
|
|
$this->view->setVar('cs', $cs);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @Route("/oauth", name="admin.setting.oauth")
|
|
*/
|
|
public function oauthAction()
|
|
{
|
|
$settingService = new SettingService();
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
$section = $this->request->getPost('section', 'string');
|
|
|
|
$data = $this->request->getPost();
|
|
|
|
$settingService->updateSettings($section, $data);
|
|
|
|
return $this->jsonSuccess(['msg' => '更新配置成功']);
|
|
|
|
} else {
|
|
|
|
$qqAuth = $settingService->getQQAuthSettings();
|
|
$weixinAuth = $settingService->getWeixinAuthSettings();
|
|
$weiboAuth = $settingService->getWeiboAuthSettings();
|
|
|
|
$this->view->setVar('qq_auth', $qqAuth);
|
|
$this->view->setVar('weixin_auth', $weixinAuth);
|
|
$this->view->setVar('weibo_auth', $weiboAuth);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @Route("/wechat/oa", name="admin.setting.wechat_oa")
|
|
*/
|
|
public function wechatOaAction()
|
|
{
|
|
$settingService = new SettingService();
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
$section = $this->request->getPost('section', 'string');
|
|
|
|
$data = $this->request->getPost();
|
|
|
|
$settingService->updateWeChatOASettings($section, $data);
|
|
|
|
return $this->jsonSuccess(['msg' => '更新配置成功']);
|
|
|
|
} else {
|
|
|
|
$oa = $settingService->getWeChatOASettings();
|
|
|
|
$this->view->pick('setting/wechat_oa');
|
|
$this->view->setVar('oa', $oa);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @Route("/dingtalk/robot", name="admin.setting.dingtalk_robot")
|
|
*/
|
|
public function dingtalkRobotAction()
|
|
{
|
|
$section = 'dingtalk.robot';
|
|
|
|
$settingService = new SettingService();
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
$data = $this->request->getPost();
|
|
|
|
$settingService->updatePointSettings($section, $data);
|
|
|
|
return $this->jsonSuccess(['msg' => '更新配置成功']);
|
|
|
|
} else {
|
|
|
|
$robot = $settingService->getSettings($section);
|
|
|
|
$this->view->pick('setting/dingtalk_robot');
|
|
$this->view->setVar('robot', $robot);
|
|
}
|
|
}
|
|
|
|
}
|