Commit 2e848cae authored by zfc's avatar zfc

规则显示隐藏

parent de581a4c
<?php
/**
* Created by PhpStorm.
* User: hujun
* User: zfc
* Date: 2018/1/16
* Time: 13:51
*/
......@@ -11,7 +11,6 @@ namespace app\index\controller;
use app\index\extend\Basic;
use app\model\AuthGroup;
use app\model\AuthRule;
use think\Db;
class Auth extends Basic
{
protected $authGroupModel;
......@@ -21,8 +20,6 @@ class Auth extends Basic
/**
* 权限列表页
*
* @return type
*/
public function index(){
return view('index');
......@@ -31,19 +28,15 @@ class Auth extends Basic
/**
* 权限分配
*
* @param type $group_id
*/
public function access($group_id = 0) {
public function access() {
return view('access');
}
/**
* 用户组授权用户列表
*
* @param type $group_id
*/
public function accessUser($group_id = 0) {
public function accessUser() {
return view('accessUser');
}
......@@ -83,9 +76,6 @@ class Auth extends Basic
$data['status'] = 200;
$data['msg'] = '';
$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';
$data['list'] = $auth_group->getList2('id desc','id,title', $where);
......@@ -101,12 +91,13 @@ class Auth extends Basic
return view('role_edit');
}
/**
* 验证数据
* @param string $validate 验证器名或者验证规则数组
* @param array $data [description]
* @return [type] [description]
/**验证数据
* @param $data
* @param $validate
* @return array|bool|int|string|true
*/
protected function validateData($data,$validate)
{
if (!$validate || empty($data)) return false;
......@@ -119,12 +110,16 @@ class Auth extends Basic
}
/*
/**
* 新增or修改or查看
* $group_id !=0为查看
* post存在id为新增
*
* */
* $group_id !=0为查看
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function addAuth(){
$group_id=$this->request->param('id');
......@@ -161,7 +156,7 @@ class Auth extends Basic
}
} else {
$info= $table->where("id={$group_id}")->find();
$info= $table->where('id',$group_id)->find();
return $this->response(200, '取值', $info);
......@@ -170,6 +165,14 @@ class Auth extends Basic
//权限表list
/**
* @param int $type
* @return array|false|\PDOStatement|string|\think\Collection|\think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function classList($type=1){
$table=new authRule;
$menus=db('auth_rule')->select();
......@@ -187,14 +190,17 @@ class Auth extends Basic
/**
* 角色权限分配or查看
* @param integer $group_id 组ID
* @return [type] [description]
* @date 2018-01-22
* @author zfc
*/
/**
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function accessLook(){
$table= New AuthGroup;
$table2=new authRule;
$group_id=$this->request->param('id');
$data['title']='权限分配';
// echo $group_id;
......@@ -260,22 +266,30 @@ class Auth extends Basic
}
/**
* 设置权限状态
*/
public function updateRoleStatus(){
$table=New AuthRule;
$data=$this->request->param();
$ids=trim($data['ids'],',');
if($table->saveStatus('status',$data['status'],$ids)){
return $this->response(200,'成功',$data);
}else{
return $this->response(100,'失败',$data);
}
}
/**
* 设置角色的状态
*/
public function updateGroup(){
$table=New AuthGroup;
$data=$this->request->param();
// $ids = input('request.ids/a');
// if (is_array($ids)) {
// if(in_array(1, $ids)) {
// $this->error('超级管理员不允许操作');
// }
// } else{
// if($ids === 1) {
// $this->error('超级管理员不允许操作');
// }
// }
$ids=trim($data['ids'],',');
if($table->saveStatus('status',$data['status'],$ids)){
......@@ -315,7 +329,7 @@ class Auth extends Basic
}
//编辑权限窗口
public function AuthRuleBox($id=0){
public function AuthRuleBox(){
return view('auth_rule_box');
}
//分类列表
......@@ -355,7 +369,7 @@ class Auth extends Basic
//新增或者编辑数据
//prt($data);
//prt($data)
if ($table->editData($data,$id)) {
return $this->response(200, '成功');
......
......@@ -4,9 +4,7 @@ namespace app\index\controller;
use app\index\extend\Basic;
use app\model\AAgents;
use app\model\AdminModel;
use app\model\AuthRule;
use think\Request;
use think\Session;
/**
......@@ -19,15 +17,13 @@ use think\Session;
class Login extends Basic
{
protected $loginDb;
protected $loginagent;
protected $authrule;
protected $loginAgent;
protected $authRule;
public function __construct($request = null)
{
parent::__construct($request);
$this->loginDb = new AdminModel();
$this->loginagent=new AAgents();
$this->authrule=new AuthRule();
$this->loginAgent=new AAgents();
$this->authRule=new AuthRule();
}
public function login()
......@@ -36,13 +32,13 @@ class Login extends Basic
}
/**
* 登陆验证
* @return \think\response\View
* @throws \think\Exception
*/
public function loginVerify()
{
$name = $_POST["username"];
$passwd = $_POST["passwd"];
$password = $_POST["passwd"];
if (!isset($name) || !isset($passwd)) {
return view("/login/login", [ "msg" => "用户名或密码不能为空" ]);
}
......@@ -52,7 +48,7 @@ class Login extends Basic
// $result = $this->loginDb->verifyUser($params);
//
// if (count($result) > 0) {
// /*todo 更新登录信息*/
// // 更新登录信息
// $this->loginDb->updateLoginTime($result[0]["id"]);
//
// Session::set("userName",$result[0]["name"]);
......@@ -74,9 +70,9 @@ class Login extends Basic
['auth_group g','a.auth_group_id=g.id','left']
];
$params["name"] = $name;
$passwd = md5($passwd);
$where="( phone='{$name}') and password='$passwd' ";
$list=$this->loginagent->verifyUser($filed,$join,$where);
$password = md5($password);
$where="( phone='{$name}') and password='$password' ";
$list=$this->loginAgent->verifyUser($filed,$join,$where);
if(!$list){
return view("/login/login", [ "msg" => "用户名或密码错误" ]);
}
......@@ -86,7 +82,7 @@ class Login extends Basic
}else{
$rules=trim($list['rules'],',');
$where ="id in({$rules})and is_menu=1 and status=1 and pid=1 ";
$nav=$this->authrule->loginRule($where);
$nav=$this->authRule->loginRule($where);
//$nav=collection($nav)->toArray();//转化arr
$nav2=array();
$url='';//跳转页面
......@@ -98,7 +94,7 @@ class Login extends Basic
}
//搜索菜单功能
$where = "id in({$rules}) and is_menu=0 and status=1 ";
$r = $this->authrule->loginRule($where);
$r = $this->authRule->loginRule($where);
$r2 = array();
foreach($r as $v){
......@@ -123,7 +119,7 @@ class Login extends Basic
$this->operating_records($list["id"],1,'后台登陆'); //记录操作日志
$this->redirect('/admin.php/'.$url);
exit;
// }
......
......@@ -115,6 +115,14 @@ class AuthRule extends BaseModel
return $r;
}
//更新数据
public function saveStatus($name,$key,$ids){
$r = $this->where("id",'in',$ids)->update([$name=>$key]);
return $r;
}
}
\ No newline at end of file
......@@ -96,6 +96,8 @@ Route::group('index', [
'updateAuthRule'=>['index/auth/updateAuthRule', ['method' => 'get|post']], //--编辑规则接口
'authClass'=>['index/auth/authClass', ['method' => 'get']], //--规则分类列表
'navigation'=>['index/Basic/navigation', ['method' => 'get']], //--规则分类列表
'updateRoleStatus'=>['index/auth/updateRoleStatus', ['method' => 'get']], //--规则编辑【接口】
'agent'=>['index/agent/agent', ['method' => 'get']], //首页列表界面
'saveAgentIndex'=>['index/agent/saveAgentIndex', ['method' => 'get']], //编辑列表列表界面
......
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