Article.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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,$order) = 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. ['order','']
  34. ],$request,true
  35. );
  36. return $this->success('获取成功',ArticleModel::lst(compact('ifyid','key','page','limit','is_hot','is_rec','cid','order')));
  37. }
  38. public function view()
  39. {
  40. $id = input('id',0);
  41. ArticleModel::where('id',$id)->inc('visit',1)->update();
  42. return $this->success('获取成功',ArticleModel::find($id));
  43. }
  44. }