提交 4025d265 authored 作者: fengzy's avatar fengzy 提交者: wangkr

数据权限

上级 4d9ec805
...@@ -124,6 +124,55 @@ class BasicInfor ...@@ -124,6 +124,55 @@ class BasicInfor
'data' => $basestates 'data' => $basestates
]); ]);
} }
//获取项目数据权限
public function getDataPermission(){
$uid = request()->get('uid');
//查找数据权限规则表
$map=[];
$permission=db::name('permission_data')->field('permission_ids')->where(['s_id'=>$uid])->find();
$arr= json_decode($permission['permission_ids'],true);
if($arr['department_id']){
$department_ids=strpos($arr['department_id'],',');
if($department_ids===false){
$map[]=['department_id','=', $arr['department_id']];
}else{
$map[]=['department_id','in',$arr['department_id']];
}
}
if($arr['region_id']){
$area_ids=strpos($arr['region_id'],',');
if($area_ids===false){
$map[]=['area_id','=', $arr['region_id']];
}else{
$map[]=['area_id','in',$arr['region_id']];
}
}
if($arr['business_id']){
$business_ids=strpos($arr['business_id'],',');
if($business_ids===false){
$map[]=['business_line_id','=', $arr['business_id']];
}else{
$map[]=['business_line_id','in',$arr['business_id']];
}
}
//如果数据规则表不存在数据信息 ,默认返回此用户的部门id
if(!$map){
$staff = db::name('staff')->field('d_id')->where(['id'=>$uid])->find();
if($staff && $staff['d_id']!==0){
$map[]=['department_id','=',$staff['d_id']];
}
}
return json([
'code' => 200,
'message' => 'SUCCESS',
'data' => $map
]);
}
static function getBasestateTree($array, $pid =0, $level = 0){ static function getBasestateTree($array, $pid =0, $level = 0){
......
...@@ -80,4 +80,10 @@ class Assign ...@@ -80,4 +80,10 @@ class Assign
return (new BasicInfor)->getBasestate(); return (new BasicInfor)->getBasestate();
} }
public function getDataPermission($uid){
$this->token->check();
return (new BasicInfor)->getDataPermission($uid);
}
} }
\ No newline at end of file
...@@ -29,3 +29,5 @@ Route::get('/v1/customers','api/v1.supplier.Assign/getCustomers'); //上游客 ...@@ -29,3 +29,5 @@ Route::get('/v1/customers','api/v1.supplier.Assign/getCustomers'); //上游客
//基站状态 //基站状态
Route::get('/v1/basestate','api/v1.supplier.Assign/getBasestate'); //基站状态信息 Route::get('/v1/basestate','api/v1.supplier.Assign/getBasestate'); //基站状态信息
Route::get('/v1/permission','api/v1.supplier.Assign/getDataPermission'); //获取项目数据权限
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论