🐛 修复 BUG

This commit is contained in:
WispX
2020-03-17 14:27:36 +08:00
parent dd927972af
commit d90cacb33a
3 changed files with 5 additions and 33 deletions
+4 -4
View File
@@ -26,15 +26,15 @@ class Image extends Base
public function find()
{
$id = $this->param('id');
$id = $this->request->request('id');
$image = $this->model->where(['id' => $id])->find();
$this->response('success', $this->parseData($image));
}
public function items()
{
$page = $this->param('page', 1);
$rows = $this->param('rows', 20);
$page = $this->request->request('page', 1);
$rows = $this->request->request('rows', 20);
$images = $this->model->paginate(null, false, [
'page' => $page,
'list_rows' => $rows,
@@ -49,7 +49,7 @@ class Image extends Base
public function delete()
{
$user = new User();
$data = str_replace('', ',', $this->param('id'));
$data = str_replace('', ',', $this->request->request('id'));
if (strpos($data, ',') !== false) {
$data = explode(',', $data);
}
-28
View File
@@ -67,32 +67,4 @@ trait Core
throw new HttpResponseException($response);
}
/**
* 获取客户端传过来的参数
*
* @param string $name 参数名
* @param null $default 默认值
* @param string $filter 过滤方法
*
* @return mixed|string
*/
protected function param($name = '', $default = null, $filter = '')
{
$data = request()->param($name, $default, $filter);
if (is_array($data)) {
foreach ($data as &$value) {
if (is_string($value)) {
$value = trim($value);
}
}
}
if (is_string($data)) {
return trim($data);
}
return $data;
}
}
@@ -27,7 +27,7 @@ class ApiAuthenticate
}
$user = null;
$token = $request->header('token', $this->param('token'));
$token = $request->header('token', $request->request('token'));
if ($token) {
if (!$user = Users::get(['token' => $token])) {
$this->response('认证失败', [], 401);