Article.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace app\controller\api\article;
  3. use think\App;
  4. use app\common\repositories\article\ArticleRepository as repository;
  5. use ln\basic\BaseController;
  6. class Article extends BaseController
  7. {
  8. /**
  9. * @var repository
  10. */
  11. protected $repository;
  12. /**
  13. * StoreBrand constructor.
  14. * @param App $app
  15. * @param repository $repository
  16. */
  17. public function __construct(App $app, repository $repository)
  18. {
  19. parent::__construct($app);
  20. $this->repository = $repository;
  21. }
  22. /**
  23. * @return mixed
  24. * @author Qinii
  25. */
  26. public function lst($cid)
  27. {
  28. [$page, $limit] = $this->getPage();
  29. $where = ['status' => 1,'cid' => $cid];
  30. return app('json')->success($this->repository->search(0,$where, $page, $limit));
  31. }
  32. public function detail($id)
  33. {
  34. if (!$this->repository->merApiExists($id))
  35. return app('json')->fail('文章不存在');
  36. return app('json')->success($this->repository->get($id,0));
  37. }
  38. }