更新
This commit is contained in:
@@ -25,7 +25,10 @@ class Config extends Admin {
|
||||
* @title 配置管理
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function index() {
|
||||
public function index(ConfigM $config) {
|
||||
$param = $this->request->param();
|
||||
|
||||
|
||||
$group = input('group', 0, 'trim');
|
||||
$name = input('name', '', 'trim');
|
||||
/* 查询条件初始化 */
|
||||
@@ -38,13 +41,13 @@ class Config extends Admin {
|
||||
$map['name'] = array('like', '%' . $name . '%');
|
||||
}
|
||||
|
||||
$list = $this->model->where($map)->order('id desc')->paginate(25, false, array(
|
||||
$list = $config->where($map)->order('id desc')->paginate(25, false, array(
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
// 记录当前列表页的cookie
|
||||
Cookie('__forward__', $_SERVER['REQUEST_URI']);
|
||||
|
||||
$data = array(
|
||||
$this->data = array(
|
||||
'group' => config('config_group_list'),
|
||||
'config_type' => config('config_config_list'),
|
||||
'page' => $list->render(),
|
||||
@@ -52,32 +55,28 @@ class Config extends Admin {
|
||||
'list' => $list,
|
||||
);
|
||||
|
||||
$this->assign($data);
|
||||
$this->setMeta('配置管理');
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 信息配置
|
||||
*/
|
||||
public function group($id = 1) {
|
||||
public function group(ConfigM $config, $id = 1) {
|
||||
if ($this->request->isPost()) {
|
||||
$config = $this->request->post('config/a');
|
||||
$model = model('Config');
|
||||
foreach ($config as $key => $value) {
|
||||
$model->where(array('name' => $key))->setField('value', $value);
|
||||
$data = $this->request->post();
|
||||
|
||||
foreach ($data['config'] as $key => $value) {
|
||||
ConfigM::update(['value' => $value], ['name' => $key]);
|
||||
}
|
||||
//清除db_config_data缓存
|
||||
cache('db_config_data', null);
|
||||
cache('system_config_data', null);
|
||||
return $this->success("更新成功!");
|
||||
} else {
|
||||
$type = config('config_group_list');
|
||||
$list = (new ConfigM())->where(array('status' => 1, 'group' => $id))->field('id,name,title,extra,value,remark,type')->order('sort')->select();
|
||||
$list = $config->where(array('status' => 1, 'group' => $id))->field('id,name,title,extra,value,remark,type')->order('sort')->select();
|
||||
if ($list) {
|
||||
$this->data['list'] = $list;
|
||||
}
|
||||
// $this->assign('id', $id);
|
||||
// $this->setMeta($type[$id] . '设置');
|
||||
$this->data['id'] = $id;
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
@@ -86,17 +85,14 @@ class Config extends Admin {
|
||||
* @title 新增配置
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function add() {
|
||||
public function add(ConfigM $config) {
|
||||
if ($this->request->isPost()) {
|
||||
$config = model('Config');
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
$id = $config->validate(true)->save($data);
|
||||
$id = $config->save($data);
|
||||
if ($id) {
|
||||
cache('db_config_data', null);
|
||||
//记录行为
|
||||
action_log('update_config', 'config', $id, session('user_auth.uid'));
|
||||
return $this->success('新增成功', url('index'));
|
||||
cache('system_config_data', null);
|
||||
return $this->success('新增成功', url('/admin/config/index'));
|
||||
} else {
|
||||
return $this->error('新增失败');
|
||||
}
|
||||
@@ -104,8 +100,7 @@ class Config extends Admin {
|
||||
return $this->error($config->getError());
|
||||
}
|
||||
} else {
|
||||
$this->setMeta('新增配置');
|
||||
$this->assign('info', null);
|
||||
$this->data['info'] = [];
|
||||
return $this->fetch('edit');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user