宝体数据调用接口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

45 lines
1.3 KiB

<?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'));
}
}