PoolLogic.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace app\logics;
  3. use app\model\Pool;
  4. use think\facade\Db;
  5. class PoolLogic
  6. {
  7. /*
  8. * addnode 添加组织结构节点
  9. * @params
  10. * $name string 节点名称
  11. * $level integer 层级数
  12. * $pid integer 上一级id,即父id
  13. */
  14. public static function addpool($name = '', $org_id, $level = 1)
  15. {
  16. $org_obj = new Pool();
  17. if($org_obj->save([
  18. 'name' => $name,
  19. 'level' => $level,
  20. 'org_id' => $org_id
  21. ])){
  22. return true;
  23. }
  24. }
  25. /**
  26. * dispool 关闭节点。
  27. *
  28. * @params
  29. * $id integer 要关闭的组织结构节点
  30. */
  31. public static function dispool($id)
  32. {
  33. if( Pool::where('id',$id)->update([ 'status' => 0 ])){
  34. return true;
  35. }else{
  36. return false;
  37. }
  38. }
  39. public static function struc()
  40. {
  41. $where = [];
  42. ///
  43. $where[] = ['state','=',1];
  44. $allpools = Pool::where($where)->order('level','asc')->select()->toArray();
  45. return json_encode($allpools);
  46. }
  47. }