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.
178 lines
3.1 KiB
178 lines
3.1 KiB
4 months ago
|
<?php
|
||
|
namespace app\node\model;
|
||
|
|
||
|
use app\BaseModel;
|
||
|
use app\mobilenode\info\PermissionMobilenode;
|
||
|
use app\node\info\PermissionNode;
|
||
|
use think\facade\Db;
|
||
|
|
||
|
class RoleList extends BaseModel
|
||
|
{
|
||
|
//定义表名
|
||
|
protected $name = 'massage_role_list';
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @author chenniang
|
||
|
* @DataTime: 2020-09-29 11:04
|
||
|
* @功能说明:添加
|
||
|
*/
|
||
|
public function dataAdd($data){
|
||
|
|
||
|
$data['create_time'] = time();
|
||
|
|
||
|
if(isset($data['node'])){
|
||
|
|
||
|
$node = $data['node'];
|
||
|
|
||
|
unset($data['node']);
|
||
|
}
|
||
|
|
||
|
$res = $this->insert($data);
|
||
|
|
||
|
$id = $this->getLastInsID();
|
||
|
|
||
|
if(isset($node)){
|
||
|
|
||
|
$this->updateSome($node,$id,$data['uniacid']);
|
||
|
}
|
||
|
|
||
|
return $id;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @author chenniang
|
||
|
* @DataTime: 2022-01-04 14:10
|
||
|
* @功能说明:添加权限节点
|
||
|
*/
|
||
|
public function updateSome($data,$id,$uniacid){
|
||
|
|
||
|
$node_model = new RoleNode();
|
||
|
|
||
|
$node_model->where(['role_id'=>$id])->delete();
|
||
|
|
||
|
if(!empty($data)){
|
||
|
|
||
|
foreach ($data as $k=>$v){
|
||
|
|
||
|
$data[$k]['uniacid'] = $uniacid;
|
||
|
|
||
|
$data[$k]['role_id'] = $id;
|
||
|
|
||
|
$data[$k]['auth'] = !empty($v['auth'])?implode(',',$v['auth']):'';
|
||
|
|
||
|
}
|
||
|
|
||
|
$node_model->saveAll($data);
|
||
|
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @author chenniang
|
||
|
* @DataTime: 2020-09-29 11:05
|
||
|
* @功能说明:编辑
|
||
|
*/
|
||
|
public function dataUpdate($dis,$data){
|
||
|
|
||
|
if(isset($data['node'])){
|
||
|
|
||
|
$node = $data['node'];
|
||
|
|
||
|
unset($data['node']);
|
||
|
}
|
||
|
|
||
|
$res = $this->where($dis)->update($data);
|
||
|
|
||
|
if(isset($node)){
|
||
|
|
||
|
$this->updateSome($node,$dis['id'],$data['uniacid']);
|
||
|
|
||
|
}
|
||
|
|
||
|
return $res;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @author chenniang
|
||
|
* @DataTime: 2020-09-29 11:06
|
||
|
* @功能说明:列表
|
||
|
*/
|
||
|
public function dataList($dis,$page){
|
||
|
|
||
|
$data = $this->where($dis)->order('status desc,id desc')->paginate($page)->toArray();
|
||
|
|
||
|
return $data;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @author chenniang
|
||
|
* @DataTime: 2020-09-29 11:43
|
||
|
* @功能说明:
|
||
|
*/
|
||
|
public function dataInfo($dis){
|
||
|
|
||
|
$data = $this->where($dis)->find();
|
||
|
|
||
|
return !empty($data)?$data->toArray():[];
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @author chenniang
|
||
|
* @DataTime: 2021-03-19 16:08
|
||
|
* @功能说明:开启默认
|
||
|
*/
|
||
|
public function updateOne($id){
|
||
|
|
||
|
$user_id = $this->where(['id'=>$id])->value('user_id');
|
||
|
|
||
|
$res = $this->where(['user_id'=>$user_id])->where('id','<>',$id)->update(['status'=>0]);
|
||
|
|
||
|
return $res;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @author chenniang
|
||
|
* @DataTime: 2023-05-04 17:54
|
||
|
* @功能说明:校验添加文件
|
||
|
*/
|
||
|
public function checkDatas($uniacid){
|
||
|
|
||
|
$p = new PermissionNode($uniacid);
|
||
|
|
||
|
$auth_num = $p->getAuthNumber();
|
||
|
|
||
|
$num = $this->where(['uniacid'=>$uniacid])->where('status','>',-1)->count();
|
||
|
|
||
|
// if($auth_num<$num){
|
||
|
|
||
|
// return ['code'=>500,'msg'=>'授权数量不足'];
|
||
|
|
||
|
//}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|