Node.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\index\controller;
  3. use app\index\controller\Base;
  4. use app\index\model\NodeModel;
  5. class Node extends Base{
  6. // 节点列表
  7. public function nodeList()
  8. {
  9. $node = new NodeModel();
  10. $nodes = $node->getNodeList();
  11. $nodes = getTree(objToArray($nodes), false);
  12. json_return(200 , $nodes , 'success');
  13. }
  14. // 添加节点
  15. public function nodeAdd()
  16. {
  17. $param = input('post.');
  18. $node = new NodeModel();
  19. $flag = $node->insertNode($param);
  20. if($flag['code'] != 1){
  21. return json(json_error_exception('1006',$flag['msg']));
  22. }
  23. $this->removeRoleCache();
  24. json_return(200,[],'success');
  25. }
  26. // 删除节点
  27. public function nodeDel()
  28. {
  29. $id = input('param.id');
  30. $role = new NodeModel();
  31. $flag = $role->delNode($id);
  32. if($flag['code'] != 1){
  33. return json(json_error_exception('1006',$flag['msg']));
  34. }
  35. $this->removeRoleCache();
  36. json_return(200,[],'success');
  37. }
  38. }