|
...
|
...
|
@@ -20,14 +20,83 @@ use Illuminate\Support\Facades\Cache; |
|
|
|
*/
|
|
|
|
class BaseController extends Controller
|
|
|
|
{
|
|
|
|
public $param;
|
|
|
|
public $request;
|
|
|
|
protected $param = [];//所有请求参数
|
|
|
|
protected $token = ''; //token
|
|
|
|
protected $request = [];//助手函数
|
|
|
|
protected $page = 1;//当前页
|
|
|
|
protected $row = 20;//每页条数
|
|
|
|
protected $header = [];//设置请求头参数
|
|
|
|
protected $order = 'created_at';
|
|
|
|
protected $order_type = 'desc';
|
|
|
|
protected $map = [];//处理后的参数
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct(Request $request)
|
|
|
|
{
|
|
|
|
$this->request = $request;
|
|
|
|
$this->param = $this->request->all();
|
|
|
|
$this->getParam();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :请求参数处理
|
|
|
|
* @name :getParam
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/17 16:34
|
|
|
|
*/
|
|
|
|
public function getParam(){
|
|
|
|
foreach ($this->param as $k => $v){
|
|
|
|
if(is_array($v)){
|
|
|
|
$this->map[$k] = $v;
|
|
|
|
}else{
|
|
|
|
$this->getMap($k,$v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :搜索参数处理
|
|
|
|
* @name :getMap
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/8/28 10:22
|
|
|
|
*/
|
|
|
|
public function getMap($k,$v){
|
|
|
|
switch ($k){
|
|
|
|
case "order":
|
|
|
|
$this->order = $v;
|
|
|
|
break;
|
|
|
|
case "order_type":
|
|
|
|
$this->order_type = $v;
|
|
|
|
break;
|
|
|
|
case 'page':
|
|
|
|
$this->page = $v;
|
|
|
|
break;
|
|
|
|
case 'row':
|
|
|
|
case 'size':
|
|
|
|
$this->row = $v;
|
|
|
|
break;
|
|
|
|
case "name":
|
|
|
|
$this->map['name'] = ['like','%'.$v.'%'];
|
|
|
|
break;
|
|
|
|
case "start_at":
|
|
|
|
$this->_btw[0] = $v;
|
|
|
|
$this->_btw[1] = date('Y-m-d H:i:s',time());
|
|
|
|
$this->map['created_at'] = ['between', $this->_btw];
|
|
|
|
break;
|
|
|
|
case "end_at":
|
|
|
|
$this->_btw[1] = $v;
|
|
|
|
$this->map['created_at'] = ['between', $this->_btw];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!empty($v) || $v == 0) {
|
|
|
|
$this->map[$k] = $v;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $data
|
|
|
|
* @param string $message
|
...
|
...
|
|