1 changed files with 45 additions and 0 deletions
@ -0,0 +1,45 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace app\api\controller\config; |
||||
|
use \app\api\controller\Controller; |
||||
|
use app\common\dm\Dm; |
||||
|
|
||||
|
class Setting extends Controller |
||||
|
{ |
||||
|
|
||||
|
public function setThreshold() |
||||
|
{ |
||||
|
|
||||
|
$threshold = $this->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')); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue