Commit 5e43b422 authored by zfc's avatar zfc

刻苦

parent 9239bb9b
...@@ -176,16 +176,15 @@ class Agent extends Basic ...@@ -176,16 +176,15 @@ class Agent extends Basic
public function updateRole(){ public function updateRole(){
$table=New AAgents; $table=New AAgents;
$data=$this->request->param(); $data=$this->request->param();
$ids=$data['ids']; $ids=trim($data['ids'],',');
if(!empty($ids)&&!empty($data['group_id'])){ if(!empty($ids)&&!empty($data['group_id'])){
if($table->saveStatus('auth_group_id',$data['group_id'],$ids)){ if($table->saveStatus('auth_group_id',$data['group_id'],$ids)){
return $this->response(200,'成功',$data); return $this->response(200,'成功',$data);
}
}
return $this->response(100,'失败',$data); return $this->response(100,'失败',$data);
}else{ }else{
return $this->response(100,'数据为空',$data); return $this->response(100,'数据为空',$data);
} }
......
...@@ -263,23 +263,26 @@ class Auth extends Basic ...@@ -263,23 +263,26 @@ class Auth extends Basic
/** /**
* 设置角色的状态 * 设置角色的状态
*/ */
public function setStatus($model ='auth_rule',$script = false){ public function updateGroup(){
$ids = input('request.ids/a'); $table=New AuthGroup;
if ($model =='AuthGroup') { $data=$this->request->param();
if (is_array($ids)) { // $ids = input('request.ids/a');
if(in_array(1, $ids)) { // if (is_array($ids)) {
$this->error('超级管理员不允许操作'); // if(in_array(1, $ids)) {
} // $this->error('超级管理员不允许操作');
} else{ // }
if($ids === 1) { // } else{
$this->error('超级管理员不允许操作'); // if($ids === 1) {
} // $this->error('超级管理员不允许操作');
} // }
} else{ // }
//cache('admin_sidebar_menus_'.$this->currentUser['uid'],null);//清空后台菜单缓存
$ids=trim($data['ids'],',');
if($table->saveStatus('status',$data['status'],$ids)){
return $this->response(200,'成功',$data);
}else{
return $this->response(100,'失败',$data);
} }
parent::setStatus($model);
} }
//权限表界面 //权限表界面
public function authRuleIndex(){ public function authRuleIndex(){
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace app\index\controller; namespace app\index\controller;
use app\index\extend\Basic; use app\index\extend\Basic;
use app\model\AAgents;
use app\model\AdminModel; use app\model\AdminModel;
use think\Request; use think\Request;
use think\Session; use think\Session;
...@@ -18,11 +19,12 @@ class Login extends Basic ...@@ -18,11 +19,12 @@ class Login extends Basic
{ {
protected $loginDb; protected $loginDb;
protected $loginagent;
public function __construct($request = null) public function __construct($request = null)
{ {
parent::__construct($request); parent::__construct($request);
$this->loginDb = new AdminModel(); $this->loginDb = new AdminModel();
$this->loginagent=new AAgents();
} }
public function login() public function login()
...@@ -41,23 +43,30 @@ class Login extends Basic ...@@ -41,23 +43,30 @@ class Login extends Basic
if (!isset($name) || !isset($passwd)) { if (!isset($name) || !isset($passwd)) {
return view("/login/login", [ "msg" => "用户名或密码不能为空" ]); return view("/login/login", [ "msg" => "用户名或密码不能为空" ]);
} }
$params["name"] = $name; if($name=='admin'){
$params["pswd"] = md5(md5($passwd)); $params["name"] = $name;
$result = $this->loginDb->verifyUser($params); $params["pswd"] = md5(md5($passwd));
$result = $this->loginDb->verifyUser($params);
if (count($result) > 0) { if (count($result) > 0) {
//todo 更新登录信息 //todo 更新登录信息
$this->loginDb->updateLoginTime($result[0]["id"]); $this->loginDb->updateLoginTime($result[0]["id"]);
Session::set("userName",$result[0]["name"]); Session::set("userName",$result[0]["name"]);
Session::set("userId",$result[0]["id"]); Session::set("userId",$result[0]["id"]);
Session::set("lastLoginTime",time()); Session::set("lastLoginTime",time());
$this->operating_records($result[0]["id"],1,'后台登陆'); //记录操作日志 $this->operating_records($result[0]["id"],1,'后台登陆'); //记录操作日志
$this->redirect('/admin.php/index/banner'); $this->redirect('/admin.php/index/banner');
} else { } else {
return view("/login/login", [ "msg" => "用户名或密码错误" ]); return view("/login/login", [ "msg" => "用户名或密码错误" ]);
}
}else{
$params["name"] = $name;
$params["pswd"] = md5(md5($passwd));
$this->loginagent->verifyUser($params);
} }
} }
/** /**
......
...@@ -9,12 +9,14 @@ namespace app\index\extend; ...@@ -9,12 +9,14 @@ namespace app\index\extend;
* Time: 9:35 * Time: 9:35
* 基类 * 基类
*/ */
use app\model\AuthGroup;
use app\model\GOperatingRecords; use app\model\GOperatingRecords;
use think\Controller; use think\Controller;
use think\Request; use think\Request;
use think\Response; use think\Response;
use think\Session; use think\Session;
use think\Db; use think\Db;
use app\model\AuthRule;
class Basic extends Controller class Basic extends Controller
{ {
...@@ -53,15 +55,30 @@ class Basic extends Controller ...@@ -53,15 +55,30 @@ class Basic extends Controller
} elseif (strtoupper($this->request->method()) === "POST") { } elseif (strtoupper($this->request->method()) === "POST") {
$this->params = $this->request->param() != null ? $this->request->param() : null; $this->params = $this->request->param() != null ? $this->request->param() : null;
} }
$requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1]; $requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1];
if (!in_array(trim($requestPath), $this->filterVerify)) { if (!in_array(trim($requestPath), $this->filterVerify)) {
$this->userVerify(); $this->userVerify();
} }
} }
public function userAuth(){
$request= \think\Request::instance();
$r= $request->controller();
$route= $request->module();
$name= $request->action();
$url=$route."/".$name;
}
/** /**
* 验证登录时效 * 验证登录时效
...@@ -94,6 +111,12 @@ class Basic extends Controller ...@@ -94,6 +111,12 @@ class Basic extends Controller
return Response::create($result, $type); return Response::create($result, $type);
} }
public function navigation(){
$table=New AuthGroup;
$data=$table->where("pid=1")->select();
return $this->response(200, '', $data);
}
/** /**
* Cors Options 授权处理 * Cors Options 授权处理
......
{layout name="global/frame_tpl" /} {layout name="global/frame_tpl" /}
<input type="hidden" class="page-load" id="access" /><!--关联js文件--> <!--<input type="hidden" class="page-load" id="access" />&lt;!&ndash;关联js文件&ndash;&gt;-->
<div id="page-content-wrapper"> <div id="page-content-wrapper">
<div class="container"> <div class="container">
<div class="col-lg-10 col-lg-offset-0"> <div class="col-lg-10 col-lg-offset-0">
......
<nav class="navbar navbar-inverse" id="sidebar-wrapper" role="navigation"> <nav class="navbar navbar-inverse" id="sidebar-wrapper" role="navigation">
<ul class="nav sidebar-nav"> <ul class="nav sidebar-nav">
<!--便于后期更改使用--> <!--便于后期更改使用-->
<!--<li class="sidebar-brand">--> <!--<li class="sidebar-brand">-->
......
...@@ -107,4 +107,11 @@ public function saveList(){ ...@@ -107,4 +107,11 @@ public function saveList(){
return $data; return $data;
} }
public function verifyUser($params)
{
return $this->db
->where($params)
->select();
}
} }
\ No newline at end of file
...@@ -207,4 +207,10 @@ class AuthGroup extends BaseModel ...@@ -207,4 +207,10 @@ class AuthGroup extends BaseModel
} }
} }
//更新数据
public function saveStatus($name,$key,$ids){
$r = $this->where("id",'in',$ids)->update([$name=>$key]);
return $r;
}
} }
...@@ -86,7 +86,7 @@ Route::group('index', [ ...@@ -86,7 +86,7 @@ Route::group('index', [
'updateAccess' => ['index/auth/updateAccess', ['method' => 'post']], //--编辑角色权限【接口】 'updateAccess' => ['index/auth/updateAccess', ['method' => 'post']], //--编辑角色权限【接口】
'addAuth' => ['index/auth/addAuth', ['method' => 'get|post']], //--添加角色【接口】 'addAuth' => ['index/auth/addAuth', ['method' => 'get|post']], //--添加角色【接口】
'accessLook'=>['index/auth/accessLook', ['method' => 'get|post']], //--查看编辑角色权限【接口】 'accessLook'=>['index/auth/accessLook', ['method' => 'get|post']], //--查看编辑角色权限【接口】
'setStatus'=>['index/auth/setStatus', ['method' => 'post']], //--设置角色的状态【接口】 'updateGroup'=>['index/auth/updateGroup', ['method' => 'post']], //--设置角色的状态【接口】
'accessUser' => ['index/auth/accessUser', ['method' => 'get']], //成员授权 'accessUser' => ['index/auth/accessUser', ['method' => 'get']], //成员授权
'authRuleIndex'=>['index/auth/authRuleIndex', ['method' => 'get']], //权限列表界面 'authRuleIndex'=>['index/auth/authRuleIndex', ['method' => 'get']], //权限列表界面
...@@ -94,6 +94,7 @@ Route::group('index', [ ...@@ -94,6 +94,7 @@ Route::group('index', [
'authRuleBox'=>['index/auth/authRuleBox', ['method' => 'get']], //--编辑规则 'authRuleBox'=>['index/auth/authRuleBox', ['method' => 'get']], //--编辑规则
'updateAuthRule'=>['index/auth/updateAuthRule', ['method' => 'get|post']], //--编辑规则接口 'updateAuthRule'=>['index/auth/updateAuthRule', ['method' => 'get|post']], //--编辑规则接口
'authClass'=>['index/auth/authClass', ['method' => 'get']], //--规则分类列表 'authClass'=>['index/auth/authClass', ['method' => 'get']], //--规则分类列表
'navigation'=>['index/Basic/navigation', ['method' => 'get']], //--规则分类列表
'agent'=>['index/agent/agent', ['method' => 'get']], //列表 'agent'=>['index/agent/agent', ['method' => 'get']], //列表
'saveAgentIndex'=>['index/agent/saveAgentIndex', ['method' => 'get']], //列表 'saveAgentIndex'=>['index/agent/saveAgentIndex', ['method' => 'get']], //列表
......
/* auth 2018/01/23 by dafei
*/
define (['doT', 'css!style/home.css','pagination','bootstrapJs'], function (doT, template) {
var navbar = {
init: function () {
//初始化dot
$ ("body").append (template);
navbar.getList ();
navbar.event ();
},
event: function () {
},
getList: function(){
}
}
return navbar;
});
\ No newline at end of file
...@@ -32,6 +32,8 @@ function getUrlParam(name) { ...@@ -32,6 +32,8 @@ function getUrlParam(name) {
if(r != null) return unescape(r[2]); if(r != null) return unescape(r[2]);
return null; return null;
} }
//字符串格式化 //字符串格式化
String.prototype.stringFormat = function(){ String.prototype.stringFormat = function(){
var formatted = this; var formatted = this;
......
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