1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace app\logics;
- use app\model\Pool;
- use think\facade\Db;
- class PoolLogic
- {
- /*
- * addnode 添加组织结构节点
- * @params
- * $name string 节点名称
- * $level integer 层级数
- * $pid integer 上一级id,即父id
- */
- public static function addpool($name = '', $org_id, $level = 1)
- {
- $org_obj = new Pool();
- if($org_obj->save([
- 'name' => $name,
- 'level' => $level,
- 'org_id' => $org_id
- ])){
- return true;
- }
- }
- /**
- * dispool 关闭节点。
- *
- * @params
- * $id integer 要关闭的组织结构节点
- */
- public static function dispool($id)
- {
- if( Pool::where('id',$id)->update([ 'status' => 0 ])){
- return true;
- }else{
- return false;
- }
- }
- public static function struc()
- {
- $where = [];
- ///
- $where[] = ['state','=',1];
- $allpools = Pool::where($where)->order('level','asc')->select()->toArray();
- return json_encode($allpools);
- }
- }
|