Dynamic.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace app\api\controller;
  3. use app\api\model\UserDynamic as UserDynamicModel;
  4. use app\api\service\User as UserService;
  5. /**
  6. * 动态控制器
  7. * Class Dynamic
  8. * @package app\api\controller
  9. */
  10. class Dynamic extends Controller
  11. {
  12. public function list()
  13. {
  14. // 获取列表数据
  15. $model = new UserDynamicModel();
  16. $pageSize = $this->request->param('pageSize', 15);
  17. $list = $model->getList($this->request->param(), (int)$pageSize);
  18. return $this->renderSuccess(compact('list'));
  19. }
  20. /**
  21. * 推荐动态
  22. * @return \think\response\Json
  23. * @throws \think\db\exception\DbException
  24. */
  25. public function index()
  26. {
  27. // 获取列表数据
  28. $model = new UserDynamicModel();
  29. $pageSize = $this->request->param('pageSize', 15);
  30. $userInfo = UserService::getCurrentLoginUser(true);
  31. $userId = isset($userInfo['user_id'])? intval($userInfo['user_id']) : 0;
  32. $list = $model->getIndexList($userId,$this->request->param(), (int)$pageSize);
  33. return $this->renderSuccess(compact('list'));
  34. }
  35. }