50 lines
849 B
PHP
Raw Normal View History

2018-11-16 17:45:37 +08:00
<?php
namespace app\admin\controller;
use think\Controller;
use app\traits\ControllerTrait;
abstract class Base extends Controller
{
use ControllerTrait;
protected $limit = 20;
protected $page = 1;
protected $middleware = ['checkLogin', 'auth'];
/**
* 过滤参数
*
* @time at 2018年11月15日
* @param $params
* @return void
*/
protected function checkParams(&$params)
{
$this->limit = $params['limit'] ?? $this->limit;
$this->page = $params['page'] ?? $this->page;
foreach ($params as $key => $param) {
if (!$param || $key == 'limit' || $key == 'page') {
unset($params[$key]);
}
}
$this->start = $this->start();
}
/**
* Table ID Start
*
* @time at 2018年11月16日
* @return float|int
*/
protected function start()
{
2018-11-16 18:27:51 +08:00
return (int)$this->limit * ((int)$this->page - 1) + 1;
2018-11-16 17:45:37 +08:00
}
}