Article.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2024 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 think\response\Json;
  14. use app\api\model\Article as ArticleModel;
  15. /**
  16. * 文章控制器
  17. * Class Article
  18. * @package app\api\controller
  19. */
  20. class Article extends Controller
  21. {
  22. /**
  23. * 文章列表
  24. * @param int $categoryId
  25. * @return Json
  26. * @throws \think\db\exception\DbException
  27. */
  28. public function list(int $categoryId = 0): Json
  29. {
  30. $model = new ArticleModel;
  31. $list = $model->getList($categoryId);
  32. return $this->renderSuccess(compact('list'));
  33. }
  34. /**
  35. * 文章详情
  36. * @param int $articleId
  37. * @return Json
  38. * @throws \cores\exception\BaseException
  39. */
  40. public function detail(int $articleId): Json
  41. {
  42. $detail = ArticleModel::getDetail($articleId);
  43. return $this->renderSuccess(compact('detail'));
  44. }
  45. }