修复配置管理以及菜单管理,增加验证

This commit is contained in:
2020-03-26 16:19:45 +08:00
parent 1346905e82
commit 8cd53f9366
11 changed files with 190 additions and 153 deletions
+12 -14
View File
@@ -6,10 +6,11 @@
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\controller\admin;
use app\controller\Admin;
use app\model\Config as ConfigM;
use think\facade\Cache;
/**
* @title 配置管理
@@ -89,15 +90,15 @@ class Config extends Admin {
if ($this->request->isPost()) {
$data = $this->request->post();
if ($data) {
$id = $config->save($data);
if ($id) {
cache('system_config_data', null);
$result = ConfigM::create($data);
if (false !== $result) {
Cache::pull('db_config_data');
return $this->success('新增成功', url('/admin/config/index'));
} else {
return $this->error('新增失败');
}
} else {
return $this->error($config->getError());
return $this->error('无添加数据!');
}
} else {
$this->data['info'] = [];
@@ -111,31 +112,28 @@ class Config extends Admin {
*/
public function edit($id = 0) {
if ($this->request->isPost()) {
$config = model('Config');
$data = $this->request->post();
if ($data) {
$result = $config->validate('Config.edit')->save($data, array('id' => $data['id']));
$result = ConfigM::update($data, array('id' => $data['id']));
if (false !== $result) {
cache('db_config_data', null);
Cache::pull('db_config_data');
//记录行为
action_log('update_config', 'config', $data['id'], session('user_auth.uid'));
return $this->success('更新成功', Cookie('__forward__'));
} else {
return $this->error($config->getError(), '');
return $this->error('更新失败!');
}
} else {
return $this->error($config->getError());
return $this->error('无更新数据!');
}
} else {
$info = array();
/* 获取数据 */
$info = db('Config')->field(true)->find($id);
$info = ConfigM::find($id);
if (false === $info) {
return $this->error('获取配置信息错误');
}
$this->assign('info', $info);
$this->setMeta('编辑配置');
$this->data = ['info' => $info];
return $this->fetch();
}
}