Article.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\api\article;
  12. use think\App;
  13. use app\common\repositories\article\ArticleRepository as repository;
  14. use crmeb\basic\BaseController;
  15. class Article extends BaseController
  16. {
  17. /**
  18. * @var repository
  19. */
  20. protected $repository;
  21. /**
  22. * StoreBrand constructor.
  23. * @param App $app
  24. * @param repository $repository
  25. */
  26. public function __construct(App $app, repository $repository)
  27. {
  28. parent::__construct($app);
  29. $this->repository = $repository;
  30. }
  31. /**
  32. * @return mixed
  33. * @author Qinii
  34. */
  35. public function lst($cid)
  36. {
  37. [$page, $limit] = $this->getPage();
  38. $where = ['status' => 1,'cid' => $cid];
  39. return app('json')->success($this->repository->search(0,$where, $page, $limit));
  40. }
  41. public function detail($id)
  42. {
  43. if (!$this->repository->merApiExists($id))
  44. return app('json')->fail('文章不存在');
  45. return app('json')->success($this->repository->get($id,0));
  46. }
  47. }