40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller;
|
|
|
|
use think\Db;
|
|
|
|
class SystemConfig extends Base
|
|
{
|
|
|
|
// 系统参数列表
|
|
public function systemConfigList(){
|
|
$sys_config = Db::name('system_config')->where(['status'=>1])->select();
|
|
return $this->buildSuccess($sys_config);
|
|
}
|
|
|
|
// 系统参数修改
|
|
public function systemConfigEdit(){
|
|
$id = $this->request->post('id');
|
|
$value = $this->request->post('value');
|
|
if (empty($id)) {
|
|
return $this->buildFailed('参数错误');
|
|
}
|
|
$result = Db::name('system_config')->where(['id'=>$id])->find();
|
|
if ($result['value'] == $value) {
|
|
return $this->buildFailed('重复修改,请确认后再修改!');
|
|
}
|
|
if ($result['name'] == 'INQUIRY_PERIOD' && !preg_match("/^[1-9][0-9]*$/", $value)) {
|
|
return $this->buildFailed('参数值不是正整数,请重新输入!');
|
|
}
|
|
$upd = Db::name('system_config')->where(['id'=>$id])->update(['value'=>$value]);
|
|
if ($upd) {
|
|
return $this->buildSuccess('', '参数值修改成功');
|
|
} else {
|
|
return $this->buildFailed('参数值修改失败');
|
|
}
|
|
}
|
|
|
|
|
|
}
|