You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.4 KiB

3 years ago
  1. <?php
  2. namespace Api\Controller;
  3. use Think\Controller;
  4. class RecycleController extends BaseController {
  5. //获取被删除的页面列表
  6. public function getList(){
  7. $item_id = I("item_id/d");
  8. $login_user = $this->checkLogin();
  9. $uid = $login_user['uid'] ;
  10. if(!$this->checkItemCreator($uid , $item_id)){
  11. $this->sendError(10303);
  12. return ;
  13. }
  14. if ($item_id > 0 ) {
  15. $ret = D("Recycle")->where(" item_id = '$item_id' ")->order(" del_time desc ")->select();
  16. }
  17. if ($ret) {
  18. foreach ($ret as $key => &$value) {
  19. $value['del_time'] = date("Y-m-d H:i:s",$value['del_time']);
  20. }
  21. }
  22. $this->sendResult($ret);
  23. }
  24. //恢复页面
  25. public function recover(){
  26. $item_id = I("item_id/d");
  27. $page_id = I("page_id/d");
  28. $login_user = $this->checkLogin();
  29. $uid = $login_user['uid'] ;
  30. if(!$this->checkItemCreator($uid , $item_id)){
  31. $this->sendError(10303);
  32. return ;
  33. }
  34. if ($item_id > 0 ) {
  35. M("Page")->where(" page_id = '$page_id' ")->save(array("is_del"=>0));
  36. D("Page")->where(" page_id = '$page_id' ")->save(array("is_del"=>0 ,"cat_id"=>0));
  37. $ret = D("Recycle")->where(" item_id = '$item_id' and page_id = '$page_id' ")->delete();
  38. }
  39. $this->sendResult(array());
  40. }
  41. }