CatalogController.class.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace Api\Controller;
  3. use Think\Controller;
  4. class CatalogController extends BaseController {
  5. //获取目录列表
  6. public function catList(){
  7. $login_user = $this->checkLogin();
  8. $item_id = I("item_id/d");
  9. if (!$this->checkItemVisit($login_user['uid'] , $item_id)) {
  10. $this->sendError(10303);
  11. return ;
  12. }
  13. if ($item_id > 0 ) {
  14. $ret = D("Catalog")->where(" item_id = '$item_id' ")->order(" 's_number', addtime asc ")->select();
  15. }
  16. if ($ret) {
  17. $this->sendResult($ret);
  18. }else{
  19. $return['error_code'] = 10103 ;
  20. $return['error_message'] = 'request fail' ;
  21. $this->sendResult($return);
  22. }
  23. }
  24. //获取二级目录列表
  25. public function secondCatList(){
  26. $login_user = $this->checkLogin();
  27. $item_id = I("item_id/d");
  28. if (!$this->checkItemVisit($login_user['uid'] , $item_id)) {
  29. $this->sendError(10303);
  30. return ;
  31. }
  32. if ($item_id > 0 ) {
  33. $ret = D("Catalog")->where(" item_id = '$item_id' and level =2 ")->order(" 's_number', addtime asc ")->select();
  34. }
  35. if ($ret) {
  36. $this->sendResult($ret);
  37. }else{
  38. $return['error_code'] = 10103 ;
  39. $return['error_message'] = 'request fail' ;
  40. $this->sendResult($return);
  41. }
  42. }
  43. //获取二级目录的子目录列表,即三级目录列表(如果存在的话)
  44. public function childCatList(){
  45. $cat_id = I("cat_id/d");
  46. if ($cat_id > 0 ) {
  47. $ret = D("Catalog")->where(" parent_cat_id = '$cat_id' ")->order(" 's_number', addtime asc ")->select();
  48. }
  49. if ($ret) {
  50. $this->sendResult($ret);
  51. }else{
  52. $return['error_code'] = 10103 ;
  53. $return['error_message'] = 'request fail' ;
  54. $this->sendResult($return);
  55. }
  56. }
  57. }