diff --git a/app/common/controller/PostController.php b/app/common/controller/PostController.php index 82f6cca..0300fa3 100644 --- a/app/common/controller/PostController.php +++ b/app/common/controller/PostController.php @@ -17,9 +17,9 @@ class PostController extends BaseController { use CrudControllerTrait; - protected $noNeedLogin = ['index']; - - protected $noNeedHeaderData = ['index']; + // protected $noNeedLogin = ['index']; + // + // protected $noNeedHeaderData = ['index']; protected $service; diff --git a/app/common/service/PostService.php b/app/common/service/PostService.php index 4973955..2c4a36f 100644 --- a/app/common/service/PostService.php +++ b/app/common/service/PostService.php @@ -52,7 +52,11 @@ class PostService $config['where']['category_id'] = $p['category_id']; } if (isset($p['scene']) && $p['scene']=='self') { - $config['where']['user_id'] = $request->user->uid; + if(!empty($request->user) && !empty($request->user->uid)){ + $config['where']['user_id'] = $request->user->uid; + }else{ + $config['where']['user_id'] = -1; + } } if(isset($p['year']) && $p['year']){ $from = strtotime($p['year'].'-01-01');