UserController.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: wuwu <15093565100@163.com>
  8. // +----------------------------------------------------------------------
  9. namespace api\portal\controller;
  10. use api\portal\service\PortalPostService;
  11. use cmf\controller\RestBaseController;
  12. class UserController extends RestBaseController
  13. {
  14. /**
  15. * 会员文章列表
  16. * @throws \think\db\exception\DataNotFoundException
  17. * @throws \think\db\exception\ModelNotFoundException
  18. * @throws \think\exception\DbException
  19. */
  20. public function articles()
  21. {
  22. $userId = $this->request->param('user_id', 0, 'intval');
  23. if (empty($userId)) {
  24. $this->error('用户id不能空!');
  25. }
  26. $param = $this->request->param();
  27. $param['user_id'] = $userId;
  28. $portalPostService = new PortalPostService();
  29. $articles = $portalPostService->postArticles($param);
  30. if ($articles->isEmpty()) {
  31. $this->error('没有数据');
  32. } else {
  33. $this->success('ok', ['list' => $articles]);
  34. }
  35. }
  36. }