Commit 8d25bc94 authored by hujun's avatar hujun

权限修改

parent c9ab99bc
...@@ -37,13 +37,20 @@ class Basic extends Controller ...@@ -37,13 +37,20 @@ class Basic extends Controller
public $lastLoginTime; public $lastLoginTime;
protected $filterVerify = array( protected $filterVerify = array(
"index/login", 'index/login',
"index/loginVerify", 'index/loginVerify',
'index/logout',
'/'
); );
/** /**
* 基础接口SDK * 基础接口SDK
*
* Basic constructor.
* @param Request|null $request * @param Request|null $request
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/ */
public function __construct(Request $request = null) public function __construct(Request $request = null)
{ {
...@@ -78,14 +85,16 @@ class Basic extends Controller ...@@ -78,14 +85,16 @@ class Basic extends Controller
public function userAuth($requestPath){ public function userAuth($requestPath){
$session_menu = Session::get("user_info.menu"); $session_menu = Session::get("user_info.menu");
$session_auth = Session::get("user_info.auth"); $session_auth = Session::get("user_info.auth");
$rule = 0;
$auth_id = 0; $auth_id = 0;
//判断当前控制器用户是否拥有进入权限 //判断当前控制器用户是否拥有进入权限
foreach ($session_menu as $v){ foreach ($session_menu as $v){
//不区分大小写 //不区分大小写
if(strcasecmp(trim($v['name_all']),$requestPath)==0){ if(strcasecmp(trim($v['name_all']),$requestPath)==0){
$auth_id = $v['id']; $auth_id = $v['id'];
} }
if (!empty($v['_child'])) {
foreach ($v['_child'] as $value) { foreach ($v['_child'] as $value) {
//不区分大小写 //不区分大小写
if(strcasecmp($value['name_all'],$requestPath) == 0){ if(strcasecmp($value['name_all'],$requestPath) == 0){
...@@ -93,9 +102,10 @@ class Basic extends Controller ...@@ -93,9 +102,10 @@ class Basic extends Controller
} }
} }
} }
}
foreach ($session_auth as $v) { foreach ($session_auth as $v) {
if(strcasecmp(trim($v['name']),$requestPath)==0){ if(strcasecmp($v['name'],$requestPath) == 0){
$auth_id = $v['id']; $auth_id = $v['id'];
} }
} }
...@@ -104,7 +114,8 @@ class Basic extends Controller ...@@ -104,7 +114,8 @@ class Basic extends Controller
$is_auth = 0; $is_auth = 0;
} else { } else {
$agents = new AAgents(); $agents = new AAgents();
$is_auth = $agents->agentsAuth($auth_id); $is_auth = $agents->agentsAuth($auth_id, Session::get('userId'));
$is_auth = empty($is_auth['id']) ? 0:1;
} }
if (empty($is_auth)) { if (empty($is_auth)) {
...@@ -132,6 +143,7 @@ class Basic extends Controller ...@@ -132,6 +143,7 @@ class Basic extends Controller
if ((time() - $this->lastLoginTime) > 7200) { if ((time() - $this->lastLoginTime) > 7200) {
$this->redirect('/index/login'); $this->redirect('/index/login');
} }
return ;
} }
/** /**
...@@ -149,17 +161,6 @@ class Basic extends Controller ...@@ -149,17 +161,6 @@ class Basic extends Controller
return Response::create($result, $type); return Response::create($result, $type);
} }
// /**
// * @return Response
// * @throws \think\db\exception\DataNotFoundException
// * @throws \think\db\exception\ModelNotFoundException
// * @throws \think\exception\DbException
// */
// public function navigation(){
// $table=New AuthGroup;
// $data=$table->where("pid=1")->select();
// return $this->response(200, '', $data);
// }
/** /**
* Cors Options 授权处理 * Cors Options 授权处理
......
...@@ -192,16 +192,13 @@ class AAgents extends BaseModel ...@@ -192,16 +192,13 @@ class AAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function verifyUser($field, $join, $params) public function verifyUser($field,$join,$params)
{ {
return $this->field($field)
$r = $this->field($field)
->alias('a') ->alias('a')
->join($join) ->join($join)
->where($params) ->where($params)
->find(); ->find();
//echo $this->getLastSql();
return $r;
} }
/** /**
...@@ -329,11 +326,14 @@ class AAgents extends BaseModel ...@@ -329,11 +326,14 @@ class AAgents extends BaseModel
return $data; return $data;
} }
/** /**
* 批量获取经纪人 * 批量获取经纪人
*
* @param $params * @param $params
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/ */
public function getAgentsByStoreId($params) public function getAgentsByStoreId($params)
{ {
...@@ -345,6 +345,7 @@ class AAgents extends BaseModel ...@@ -345,6 +345,7 @@ class AAgents extends BaseModel
return $result; return $result;
} }
public function getAgentsInfoByAgentId($field, $params) public function getAgentsInfoByAgentId($field, $params)
{ {
$where_ = []; $where_ = [];
...@@ -361,7 +362,26 @@ class AAgents extends BaseModel ...@@ -361,7 +362,26 @@ class AAgents extends BaseModel
->where($where_) ->where($where_)
->select(); ->select();
return $result; return $result;
}
/**
* 检查是否有权限
*
* @param $id
* @param $agents_id
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function agentsAuth($id, $agents_id) {
return $this->alias('a')
->field('b.id')
->join('auth_group b','a.auth_group_id=b.id','left')
->where("FIND_IN_SET({$id},b.rules)")
->where('a.id',$agents_id)
->where('b.status',0)
->find();
} }
public function searchAgentsByKeyword($field, $params) public function searchAgentsByKeyword($field, $params)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment