Commit eca7a534 authored by zfc's avatar zfc

权限接口需要

parent 94a5defb
......@@ -101,10 +101,10 @@ class Agent extends Basic
* */
public function saveAgent($group_id=0){
$group_id=$this->request->param('id');
$table= New AAgents;
if (IS_POST && $group_id==0) {
if ($this->request->isPost()) {
$data = input('post.');
......@@ -171,32 +171,29 @@ class Agent extends Basic
/**
* 批量变更角色
* @post ids 用户组id
* @post idname 实际id名(auth_group_access表无id)
* @post group_id 变更的角色组id
*/
public function updateRole(){
$table=New AAgents;
$table2=New AuthGroupAccess;
$data=$this->request->param();
$ids=$data['ids'];
//1.清空原有数据
if(!empty($ids)&&!empty($data['group_id'])){
if($table2->delUid($data['idname'],$ids)){
//2.从新分发角色
$data2['group_id']=$data['group_id'];
if($table->addAllAccess($ids,$data2)){
if($table->saveStatus('auth_group_id',$data['group_id'],$ids)){
return $this->response(200,'成功',$data);
}else{
return $this->response(100,'失败',$data);
}
}
return $this->response(100,'失败',$data);
}else{
return $this->response(100,'数据为空',$data);
}
}
}
//
......
......@@ -58,8 +58,18 @@ class Auth extends Basic
$params = $this->request->param();
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$auth_group = New AuthGroup();
$where = 'status <> 0';
$search=$params['search'];
if(!empty($search)){
// Session::set("search.agent",$search);
$where.=" and id='$search' or title like '%$search%' ";
$data['search']=$search;
}
$data['list'] = $auth_group->getList($pageNo, $pageSize, 'id desc','*', $where);
$data['total'] = $auth_group->getTotal($where);
return $this->response(200, '', $data);
......@@ -133,7 +143,15 @@ class Auth extends Basic
if($err!=1){
return $this->response(100, $err);
}
$id = isset($data['id']) && $data['id']>0 ? $data['id']:false;
//新增或者编辑数据
if(empty($data['id'])){
$data['create_time']= date( 'Y-m-d H:i:s',time());
$data['update_time']= date( 'Y-m-d H:i:s',time());
$id='';
}else{
$data['update_time']= date( 'Y-m-d H:i:s',time());
$id=$data['id'];
}
if ($table->editData($data,$id)) {
return $this->response(200, '成功');
......@@ -150,6 +168,7 @@ class Auth extends Basic
}
}
//权限表list
public function classList($type=1){
$table=new authRule;
......@@ -185,7 +204,15 @@ class Auth extends Basic
$data['id'] = $group_id;
$menu_auth = input('post.menu_auth/a','');//获取所有授权菜单id
$data['rules'] = implode(',',$menu_auth);//拼接
$id = isset($data['id']) && $data['id']>0 ? $data['id']:false;
//新增或者编辑数据
if(empty($data['id'])){
$data['create_time']= date( 'Y-m-d H:i:s',time());
$data['update_time']= date( 'Y-m-d H:i:s',time());
$id='';
}else{
$data['update_time']= date( 'Y-m-d H:i:s',time());
$id=$data['id'];
}
//提交数据
if ( $table->editData($data,$id)) {
......@@ -270,6 +297,11 @@ class Auth extends Basic
//条件
$field="a.id,a.name,a.title,a.depend_flag,a.type,a.pid,a.icon,a.sort,if(a.is_menu,'是','否')is_menu,a.status,ifnull(b.title,'顶级') as title2";
$where='a.status=1';
$search=$params['search'];
if(!empty($search)){
$where.=" and a.id='$search' or a.name like '%$search%' ";
$data['search']=$search;
}
$order='a.pid asc,a.sort asc';
$join=[['auth_rule b', ' a.pid=b.id','left']];
$data['list'] = $table->authRuleList($pageNo, $pageSize,$order,$field,$join, $where);
......
......@@ -47,7 +47,7 @@ public function saveList(){
}
//更新数据
public function saveStatus($name,$key,$ids){
$r = $this->save([$name,$key],["id",'in',$ids]);
$r = $this->where("id",'in',$ids)->update([$name=>$key]);
return $r;
}
//删除数据
......
......@@ -100,7 +100,7 @@ Route::group('index', [
'AgentList'=>['index/agent/AgentList', ['method' => 'get']], //列表
'saveAgent'=>['index/agent/saveAgent', ['method' => 'post']], //列表
'updateStatus'=>['index/agent/updateStatus', ['method' => 'get']], //列表
'updateRole'=>['index/agent/updateRole', ['method' => 'get']], //列表
'updateRole'=>['index/agent/updateRole', ['method' => 'post']], //经纪人角色修改接口
//商圈
......
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