Files
amb_wechatapp/application/admin/controller/config/Terminal.php
T

72 lines
1.6 KiB
PHP

<?php
namespace app\admin\controller\config;
use app\common\controller\Backend;
/**
* 登录终端限制配置
*/
class Terminal extends Backend
{
/**
* 模型对象
* @var null
*/
protected $model = null;
protected $configName = 'terminal';
public function _initialize()
{
parent::_initialize();
}
/**
* 获取配置
* @return mixed
*/
public function getConfig()
{
\app\common\model\fill\Handle::check('app_config', $this->configName);
$data = \app\common\model\app\Config::getConfig($this->configName);
return $this->success("获取成功", $data);
}
/**
* 保存配置
* @return mixed
*/
public function setConfig()
{
$row = $this->request->post("row/a", [], 'trim');
// 登录终端限制数:范围 1-50,非数字回退默认值 3
if (isset($row['login_terminal_limit'])) {
$limit = trim((string)$row['login_terminal_limit']);
if ($limit === '' || !is_numeric($limit)) {
$row['login_terminal_limit'] = '3';
} else {
$limit = intval($limit);
if ($limit < 1) {
$limit = 1;
}
if ($limit > 50) {
$limit = 50;
}
$row['login_terminal_limit'] = (string)$limit;
}
}
\app\common\model\fill\Handle::check('app_config', $this->configName);
$data = \app\common\model\app\Config::setConfig($this->configName, $row);
return $this->success("保存成功", $data);
}
}