Article.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\api\controller;
  13. use app\api\model\Article as ArticleModel;
  14. /**
  15. * 文章控制器
  16. * Class Article
  17. * @package app\api\controller
  18. */
  19. class Article extends Controller
  20. {
  21. /**
  22. * 文章列表
  23. * @param int $categoryId
  24. * @return array
  25. * @throws \think\db\exception\DbException
  26. */
  27. public function list(int $categoryId = 0)
  28. {
  29. $model = new ArticleModel;
  30. $list = $model->getList($categoryId);
  31. return $this->renderSuccess(compact('list'));
  32. }
  33. /**
  34. * 文章详情
  35. * @param int $articleId
  36. * @return array|\think\response\Json
  37. * @throws \app\common\exception\BaseException
  38. */
  39. public function detail(int $articleId)
  40. {
  41. $detail = ArticleModel::getDetail($articleId);
  42. return $this->renderSuccess(compact('detail'));
  43. }
  44. }