115 lines
2.8 KiB
PHP
115 lines
2.8 KiB
PHP
<?php
|
||
// +------------------------------------------------+
|
||
// |http://www.cjango.com |
|
||
// +------------------------------------------------+
|
||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||
// +------------------------------------------------+
|
||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||
// +------------------------------------------------+
|
||
namespace app\system\controller;
|
||
|
||
use app\common\model\Config as ConfigModel;
|
||
use app\common\service\Config as ConfigService;
|
||
use think\Cache;
|
||
use think\Request;
|
||
|
||
class Config extends _Init
|
||
{
|
||
|
||
/**
|
||
* 批量设置的页面
|
||
* @return [type] [description]
|
||
*/
|
||
public function index()
|
||
{
|
||
if (IS_POST) {
|
||
$config = $this->request->post('config/a');
|
||
$result = ConfigService::batchEdit($config);
|
||
$this->back($result);
|
||
} else {
|
||
$map = [
|
||
'status' => 1,
|
||
];
|
||
$this->list = ConfigModel::where($map)->order('sort asc')->select();
|
||
return $this->fetch();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 所有参数页面
|
||
* @return [type] [description]
|
||
*/
|
||
public function params()
|
||
{
|
||
$map = [
|
||
'status' => ['egt', 0],
|
||
];
|
||
$this->list = ConfigModel::where($map)->order('sort asc,create_time desc,update_time desc')->paginate(10);
|
||
return $this->fetch();
|
||
}
|
||
|
||
/**
|
||
* 清除缓存
|
||
*/
|
||
public function clear()
|
||
{
|
||
if (Cache::clear()) {
|
||
return $this->success('清除缓存成功');
|
||
} else {
|
||
return $this->error();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 新增配置
|
||
*/
|
||
public function add(Request $request)
|
||
{
|
||
if (IS_POST) {
|
||
$data = $request->post();
|
||
$result = ConfigService::add($data);
|
||
return $this->back($result);
|
||
} else {
|
||
return $this->fetch();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 编辑配置
|
||
* @param [type] $id [description]
|
||
*/
|
||
public function edit(Request $request, $id)
|
||
{
|
||
if (IS_POST) {
|
||
$data = $request->post();
|
||
$result = ConfigService::edit($data);
|
||
return $this->back($result);
|
||
} else {
|
||
$this->assign('info', ConfigModel::find($id));
|
||
return $this->fetch('add');
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 修改状态
|
||
* @param [type] $id [description]
|
||
* @param [type] $status [description]
|
||
* @param [type] $type [description]
|
||
*/
|
||
public function status($id, $status, $type)
|
||
{
|
||
$result = ConfigService::status($id, $status, $type);
|
||
return $this->back($result);
|
||
}
|
||
|
||
/**
|
||
* 删除
|
||
* @param [type] $id [description]
|
||
*/
|
||
public function del($id)
|
||
{
|
||
$result = ConfigService::del($id);
|
||
return $this->back($result);
|
||
}
|
||
}
|