zzwy2/app/controller/manager/Config.php

95 lines
2.5 KiB
PHP
Raw Normal View History

2022-10-08 09:31:39 +00:00
<?php
namespace app\controller\manager;
use app\model\ConfigSetting;
use think\facade\Config as CConfig;
/**
* 基础配置
* Class Config
* @package app\controller\manager
*/
class Config extends Base
{
public function base()
{
$configName = 'extraBase';
if ($this->request->isPost()) {
$data = input("post.");
if(isset($data['_token'])) {
unset($data['_token']);
}
ConfigSetting::setConfigByName($configName, $data);
return $this->json(0);
} else {
// 兼容写法,把原配置文件中的配置信息写入到数据库
$conf = ConfigSetting::getConfigContentsByName($configName);
if (empty($conf)) {
CConfig::load('extra/base', $configName);
$conf = config($configName);
if (!empty($conf)) {
ConfigSetting::setConfigByName($configName, $conf);
}
}
$this->data['item'] = $conf;
return $this->view();
}
}
//法律制度
public function statute()
{
$configName = 'extraStatute';
if ($this->request->isPost()) {
$data = input("post.");
if(isset($data['_token'])) {
unset($data['_token']);
}
ConfigSetting::setConfigByName($configName, $data);
return $this->json();
} else {
$conf = ConfigSetting::getConfigContentsByName($configName);
if (empty($conf)) {
CConfig::load('extra/statute', $configName);
$conf = config($configName);
if (!empty($conf)) {
ConfigSetting::setConfigByName($configName, $conf);
}
}
$this->data['item'] = $conf;
return $this->view();
}
}
/**
* 侧边栏配置
* @date 2021-11
*/
public function slide()
{
$configName = 'extraSlide';
if ($this->request->isPost()) {
$data = input("post.");
if(isset($data['_token'])) {
unset($data['_token']);
}
ConfigSetting::setConfigByName($configName, $data);
return $this->json();
} else {
$conf = ConfigSetting::getConfigContentsByName($configName);
$this->data['item'] = $conf;
return $this->view();
}
}
}