Article.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\model\{ArticleCategory,Article as ArticleModel};
  4. use app\common\controller\Api;
  5. use liuniu\UtilService;
  6. use think\Request;
  7. class Article extends Api
  8. {
  9. protected $noNeedLogin = ['*'];
  10. protected $noNeedRight = ['*'];
  11. public function ify(Request $request)
  12. {
  13. list($pid,$key) = UtilService::getMore(
  14. [
  15. ['pid',0],
  16. ['key',''],
  17. ],$request,true
  18. );
  19. $cid = $this->cid;
  20. return $this->success('获取成功',ArticleCategory::lst(compact('cid','pid','key')));
  21. }
  22. public function lst(Request $request)
  23. {
  24. list($ifyid,$key,$page,$limit,$is_hot,$is_rec,$cid) = UtilService::getMore(
  25. [
  26. ['ifyid',0],
  27. ['key',''],
  28. ['page',1],
  29. ['limit',20],
  30. ['is_hot',-1],
  31. ['is_rec',-1],
  32. ['cid',$this->cid],
  33. ],$request,true
  34. );
  35. return $this->success('获取成功',ArticleModel::lst(compact('ifyid','key','page','limit','is_hot','is_rec','cid')));
  36. }
  37. public function view()
  38. {
  39. $id = input('id',0);
  40. return $this->success('获取成功',ArticleModel::find($id));
  41. }
  42. }