diff --git a/source/application/admin/controller/Passport.php b/source/application/admin/controller/Passport.php index 411dd8d..a2ba53b 100644 --- a/source/application/admin/controller/Passport.php +++ b/source/application/admin/controller/Passport.php @@ -23,8 +23,8 @@ class Passport extends Controller { if ($this->request->isAjax()) { $model = new UserModel; - if ($model->login($this->postData('User'))) { - return $this->renderSuccess('登录成功', url('index/index')); + if ($model->login($_POST['User'])) { + return $this->renderSuccess('登录成功', url('admin/setting.config/index')); } return $this->renderError($model->getError() ?: '登录失败'); } diff --git a/source/application/admin/controller/setting/Config.php b/source/application/admin/controller/setting/Config.php index f620414..044ceab 100644 --- a/source/application/admin/controller/setting/Config.php +++ b/source/application/admin/controller/setting/Config.php @@ -5,6 +5,7 @@ namespace app\admin\controller\setting; use app\admin\controller\Controller; use app\common\dm\Dm; use app\common\model\Pass; +use think\Session; /** * 配置 @@ -24,26 +25,65 @@ class Config extends Controller if ($this->request->isAjax()) { - $request = $this->request->request(); + $request = $_POST; + if ( Session::get('__token__') != $request['token']) $this->renderError('token验证失败'); $threshold = $request['threshold']; - if (empty($threshold)) $this->renderError('请填写阈值'); - if (is_numeric($threshold) && $threshold > 0) $this->renderError('阈值必须是数字'); + if (!is_array($threshold)) $this->renderError('参数类型错误'); - # 修改阈值 - $dm->update('bt_config',['value' => $threshold],'"key"='."'threshold'"); + $errorArr = []; + $i = 0; + foreach ($threshold as $id => $value) { + $error = []; + $i++; + $strpos = strpos($value,'-'); + if ($strpos !== false) { + $arr = explode("-",$value); + if (!preg_match("/^\d+$/",$arr[0])) $error[] = "第{$i}行,第1个数据必须是数字"; + if (!preg_match("/^\d+$/",$arr[1])) $error[] = "第{$i}行,第2个必须是数字"; + if ($arr[1] < $arr[0]) $error[] = "第{$i}行,第2个不能小于第1个数据"; + } else { + if (!preg_match("/^\d+$/",$value)) $error[] = "第{$i}行,数据必须是数字"; + } + + # 验证数据是否发生修改 + $queryRes = $dm->find('bt_config',['id' => $id]); + if (empty($queryRes)) $error[] = "第{$i}行,数据不存在"; + if ($queryRes['value'] == $value) continue; + + if (!empty($error)) { + $errorArr = array_merge($errorArr,$error); + continue; + } + + $dm->update('bt_config',['value' => $value],['id' => $id]); + } + + if (!empty($errorArr)) { + return $this->renderError(implode("
",$errorArr)); + } return $this->renderSuccess('操作成功'); } - $configList = []; - - $configRes = $dm->find("bt_config",' "key" = ' . "'threshold'"); - $threshold = $configRes['value']; + $configRes = $dm->select("bt_config"); + foreach ($configRes as &$configRow) { + $configRow['groupName'] = ''; + $tyGroupRes = $dm->find('bt_passenger_monitor_group',['groupId' => $configRow['key']],'"groupName"'); + if ($tyGroupRes) { + $configRow['groupName'] = $tyGroupRes['groupName']; + } + if (empty($configRow['groupName'])) { + $whGroupRes = $dm->find('bt_library',['group_id' => $configRow['key']],'"group_name"'); + if ($whGroupRes) { + $configRow['groupName'] = $whGroupRes['group_name']; + } + } + } return $this->fetch('index', [ - 'configList' => $configList, - 'threshold' => $threshold, + 'configList' => $configRes, + 'token' => $this->request->token() ]); } } \ No newline at end of file diff --git a/source/application/admin/extra/menus.php b/source/application/admin/extra/menus.php index 85aaeff..095642a 100644 --- a/source/application/admin/extra/menus.php +++ b/source/application/admin/extra/menus.php @@ -30,36 +30,36 @@ return [ // ] // ], // ], - 'statistics' => [ - 'name' => '数据统计', - 'icon' => 'icon-shezhi', - 'submenu' => [ - [ - 'name' => '客流统计数据', - 'index' => 'pass.pass/index' - ], - [ - 'name' => '总客流统计数据', - 'index' => 'pass.pass/allIndex' - ], - [ - 'name' => '客流实时统计数据', - 'index' => 'pass.pass/realIndex' - ], - ], - ], +// 'statistics' => [ +// 'name' => '数据统计', +// 'icon' => 'icon-shezhi', +// 'submenu' => [ +// [ +// 'name' => '客流统计数据', +// 'index' => 'pass.pass/index' +// ], +// [ +// 'name' => '总客流统计数据', +// 'index' => 'pass.pass/allIndex' +// ], +// [ +// 'name' => '客流实时统计数据', +// 'index' => 'pass.pass/realIndex' +// ], +// ], +// ], 'setting' => [ 'name' => '系统设置', 'icon' => 'icon-shezhi', 'submenu' => [ - [ - 'name' => '清理缓存', - 'index' => 'setting.cache/clear' - ], - [ - 'name' => '环境检测', - 'index' => 'setting.science/index' - ], +// [ +// 'name' => '清理缓存', +// 'index' => 'setting.cache/clear' +// ], +// [ +// 'name' => '环境检测', +// 'index' => 'setting.science/index' +// ], [ 'name' => '配置', 'index' => 'setting.config/index' diff --git a/source/application/admin/model/admin/User.php b/source/application/admin/model/admin/User.php index bc2b3dc..14220b8 100644 --- a/source/application/admin/model/admin/User.php +++ b/source/application/admin/model/admin/User.php @@ -2,6 +2,7 @@ namespace app\admin\model\admin; +use app\common\dm\Dm; use think\Session; use app\common\model\admin\User as UserModel; @@ -23,18 +24,20 @@ class User extends UserModel public function login($data) { // 验证用户名密码是否正确 - if (!$user = self::useGlobalScope(false)->where([ + $dm = new Dm(); + $user = $dm->dmPDOFind('bt_admin_user',[ 'user_name' => $data['user_name'], 'password' => yoshop_hash($data['password']) - ])->find()) { + ]); + if (!$user['status']) { $this->error = '登录失败, 用户名或密码错误'; return false; } // 保存登录状态 Session::set('yoshop_admin', [ 'user' => [ - 'admin_user_id' => $user['admin_user_id'], - 'user_name' => $user['user_name'], + 'admin_user_id' => $user['data']['admin_user_id'], + 'user_name' => $user['data']['user_name'], ], 'is_login' => true, ]); diff --git a/source/application/admin/view/layouts/layout.php b/source/application/admin/view/layouts/layout.php index 03dc60c..abf3c5c 100644 --- a/source/application/admin/view/layouts/layout.php +++ b/source/application/admin/view/layouts/layout.php @@ -31,7 +31,7 @@