diff --git a/source/application/api/controller/config/Setting.php b/source/application/api/controller/config/Setting.php new file mode 100644 index 0000000..8118cfc --- /dev/null +++ b/source/application/api/controller/config/Setting.php @@ -0,0 +1,45 @@ +request->param('value'); + + if (empty($threshold) || $threshold == 'NULL') return $this->renderError('请填写阈值'); + if (!is_numeric($threshold)) return $this->renderError('阈值必须是整形'); + if ($threshold < 0) return $this->renderError('阈值不能为负数'); + + $dm = new Dm(); + + $queryConfig = $dm->find('bt_config',['key' => 'threshold']); + + if ($queryConfig['value'] == $threshold) { + return $this->renderError('阈值与当前设置阈值一致:'.$threshold); + } + + # 修改阈值 + $dm->update('bt_config',['value' => $threshold],['key' => 'threshold']); + + $commit_explain = '修改阈值:'.$queryConfig['value'].' => '.$threshold; + + return $this->renderSuccess(compact('commit_explain')); + } + + public function getThreshold() + { + $dm = new Dm(); + + $config = $dm->find('bt_config',['key' => 'threshold']); + + $commit_explain = '当前阈值:'.$config['value']; + + return $this->renderSuccess(compact('commit_explain')); + } +} \ No newline at end of file