From 08fd7daf8cc39bb44c21b75f94282c72e6129dc4 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq,com> Date: Tue, 8 Aug 2023 16:05:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E3=80=81=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E9=98=88=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/config/Setting.php | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 source/application/api/controller/config/Setting.php 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