Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
2e848cae
Commit
2e848cae
authored
Feb 01, 2018
by
zfc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
规则显示隐藏
parent
de581a4c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
58 deletions
+79
-58
Auth.php
application/index/controller/Auth.php
+54
-40
Login.php
application/index/controller/Login.php
+13
-17
AuthRule.php
application/model/AuthRule.php
+10
-1
route.php
application/route.php
+2
-0
No files found.
application/index/controller/Auth.php
View file @
2e848cae
<?php
<?php
/**
/**
* Created by PhpStorm.
* Created by PhpStorm.
* User:
hujun
* User:
zfc
* Date: 2018/1/16
* Date: 2018/1/16
* Time: 13:51
* Time: 13:51
*/
*/
...
@@ -11,7 +11,6 @@ namespace app\index\controller;
...
@@ -11,7 +11,6 @@ namespace app\index\controller;
use
app\index\extend\Basic
;
use
app\index\extend\Basic
;
use
app\model\AuthGroup
;
use
app\model\AuthGroup
;
use
app\model\AuthRule
;
use
app\model\AuthRule
;
use
think\Db
;
class
Auth
extends
Basic
class
Auth
extends
Basic
{
{
protected
$authGroupModel
;
protected
$authGroupModel
;
...
@@ -21,8 +20,6 @@ class Auth extends Basic
...
@@ -21,8 +20,6 @@ class Auth extends Basic
/**
/**
* 权限列表页
* 权限列表页
*
* @return type
*/
*/
public
function
index
(){
public
function
index
(){
return
view
(
'index'
);
return
view
(
'index'
);
...
@@ -31,19 +28,15 @@ class Auth extends Basic
...
@@ -31,19 +28,15 @@ class Auth extends Basic
/**
/**
* 权限分配
* 权限分配
*
* @param type $group_id
*/
*/
public
function
access
(
$group_id
=
0
)
{
public
function
access
()
{
return
view
(
'access'
);
return
view
(
'access'
);
}
}
/**
/**
* 用户组授权用户列表
* 用户组授权用户列表
*
* @param type $group_id
*/
*/
public
function
accessUser
(
$group_id
=
0
)
{
public
function
accessUser
()
{
return
view
(
'accessUser'
);
return
view
(
'accessUser'
);
}
}
...
@@ -83,9 +76,6 @@ class Auth extends Basic
...
@@ -83,9 +76,6 @@ class Auth extends Basic
$data
[
'status'
]
=
200
;
$data
[
'status'
]
=
200
;
$data
[
'msg'
]
=
''
;
$data
[
'msg'
]
=
''
;
$params
=
$this
->
request
->
param
();
$pageNo
=
empty
(
$params
[
'pageNo'
])
?
1
:
$params
[
'pageNo'
];
$pageSize
=
empty
(
$params
[
'pageSize'
])
?
15
:
$params
[
'pageSize'
];
$auth_group
=
New
AuthGroup
();
$auth_group
=
New
AuthGroup
();
$where
=
'status = 0'
;
$where
=
'status = 0'
;
$data
[
'list'
]
=
$auth_group
->
getList2
(
'id desc'
,
'id,title'
,
$where
);
$data
[
'list'
]
=
$auth_group
->
getList2
(
'id desc'
,
'id,title'
,
$where
);
...
@@ -101,12 +91,13 @@ class Auth extends Basic
...
@@ -101,12 +91,13 @@ class Auth extends Basic
return
view
(
'role_edit'
);
return
view
(
'role_edit'
);
}
}
/**
/**验证数据
* 验证数据
* @param $data
* @param string $validate 验证器名或者验证规则数组
* @param $validate
* @param array $data [description]
* @return array|bool|int|string|true
* @return [type] [description]
*/
*/
protected
function
validateData
(
$data
,
$validate
)
protected
function
validateData
(
$data
,
$validate
)
{
{
if
(
!
$validate
||
empty
(
$data
))
return
false
;
if
(
!
$validate
||
empty
(
$data
))
return
false
;
...
@@ -119,12 +110,16 @@ class Auth extends Basic
...
@@ -119,12 +110,16 @@ class Auth extends Basic
}
}
/*
* 新增or修改or查看
/**
* $group_id !=0为查看
* 新增or修改or查看
* post存在id为新增
* 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
(){
public
function
addAuth
(){
$group_id
=
$this
->
request
->
param
(
'id'
);
$group_id
=
$this
->
request
->
param
(
'id'
);
...
@@ -161,7 +156,7 @@ class Auth extends Basic
...
@@ -161,7 +156,7 @@ class Auth extends Basic
}
}
}
else
{
}
else
{
$info
=
$table
->
where
(
"id=
{
$group_id
}
"
)
->
find
();
$info
=
$table
->
where
(
'id'
,
$group_id
)
->
find
();
return
$this
->
response
(
200
,
'取值'
,
$info
);
return
$this
->
response
(
200
,
'取值'
,
$info
);
...
@@ -170,6 +165,14 @@ class Auth extends Basic
...
@@ -170,6 +165,14 @@ class Auth extends Basic
//权限表list
//权限表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
){
public
function
classList
(
$type
=
1
){
$table
=
new
authRule
;
$table
=
new
authRule
;
$menus
=
db
(
'auth_rule'
)
->
select
();
$menus
=
db
(
'auth_rule'
)
->
select
();
...
@@ -187,14 +190,17 @@ class Auth extends Basic
...
@@ -187,14 +190,17 @@ class Auth extends Basic
/**
/**
* 角色权限分配or查看
* 角色权限分配or查看
* @param integer $group_id 组ID
* @return [type] [description]
* @date 2018-01-22
* @date 2018-01-22
* @author zfc
* @author zfc
*/
*/
/**
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
accessLook
(){
public
function
accessLook
(){
$table
=
New
AuthGroup
;
$table
=
New
AuthGroup
;
$table2
=
new
authRule
;
$group_id
=
$this
->
request
->
param
(
'id'
);
$group_id
=
$this
->
request
->
param
(
'id'
);
$data
[
'title'
]
=
'权限分配'
;
$data
[
'title'
]
=
'权限分配'
;
// echo $group_id;
// echo $group_id;
...
@@ -259,6 +265,23 @@ class Auth extends Basic
...
@@ -259,6 +265,23 @@ 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
);
}
}
/**
/**
* 设置角色的状态
* 设置角色的状态
...
@@ -266,16 +289,7 @@ class Auth extends Basic
...
@@ -266,16 +289,7 @@ class Auth extends Basic
public
function
updateGroup
(){
public
function
updateGroup
(){
$table
=
New
AuthGroup
;
$table
=
New
AuthGroup
;
$data
=
$this
->
request
->
param
();
$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'
],
','
);
$ids
=
trim
(
$data
[
'ids'
],
','
);
if
(
$table
->
saveStatus
(
'status'
,
$data
[
'status'
],
$ids
)){
if
(
$table
->
saveStatus
(
'status'
,
$data
[
'status'
],
$ids
)){
...
@@ -315,7 +329,7 @@ class Auth extends Basic
...
@@ -315,7 +329,7 @@ class Auth extends Basic
}
}
//编辑权限窗口
//编辑权限窗口
public
function
AuthRuleBox
(
$id
=
0
){
public
function
AuthRuleBox
(){
return
view
(
'auth_rule_box'
);
return
view
(
'auth_rule_box'
);
}
}
//分类列表
//分类列表
...
@@ -355,7 +369,7 @@ class Auth extends Basic
...
@@ -355,7 +369,7 @@ class Auth extends Basic
//新增或者编辑数据
//新增或者编辑数据
//prt($data)
;
//prt($data)
if
(
$table
->
editData
(
$data
,
$id
))
{
if
(
$table
->
editData
(
$data
,
$id
))
{
return
$this
->
response
(
200
,
'成功'
);
return
$this
->
response
(
200
,
'成功'
);
...
...
application/index/controller/Login.php
View file @
2e848cae
...
@@ -4,9 +4,7 @@ namespace app\index\controller;
...
@@ -4,9 +4,7 @@ namespace app\index\controller;
use
app\index\extend\Basic
;
use
app\index\extend\Basic
;
use
app\model\AAgents
;
use
app\model\AAgents
;
use
app\model\AdminModel
;
use
app\model\AuthRule
;
use
app\model\AuthRule
;
use
think\Request
;
use
think\Session
;
use
think\Session
;
/**
/**
...
@@ -19,15 +17,13 @@ use think\Session;
...
@@ -19,15 +17,13 @@ use think\Session;
class
Login
extends
Basic
class
Login
extends
Basic
{
{
protected
$loginDb
;
protected
$loginAgent
;
protected
$loginagent
;
protected
$authRule
;
protected
$authrule
;
public
function
__construct
(
$request
=
null
)
public
function
__construct
(
$request
=
null
)
{
{
parent
::
__construct
(
$request
);
parent
::
__construct
(
$request
);
$this
->
loginDb
=
new
AdminModel
();
$this
->
loginAgent
=
new
AAgents
();
$this
->
loginagent
=
new
AAgents
();
$this
->
authRule
=
new
AuthRule
();
$this
->
authrule
=
new
AuthRule
();
}
}
public
function
login
()
public
function
login
()
...
@@ -36,13 +32,13 @@ class Login extends Basic
...
@@ -36,13 +32,13 @@ class Login extends Basic
}
}
/**
/**
* 登陆验证
* @return \think\response\View
* @return \think\response\View
* @throws \think\Exception
*/
*/
public
function
loginVerify
()
public
function
loginVerify
()
{
{
$name
=
$_POST
[
"username"
];
$name
=
$_POST
[
"username"
];
$passwd
=
$_POST
[
"passwd"
];
$passw
or
d
=
$_POST
[
"passwd"
];
if
(
!
isset
(
$name
)
||
!
isset
(
$passwd
))
{
if
(
!
isset
(
$name
)
||
!
isset
(
$passwd
))
{
return
view
(
"/login/login"
,
[
"msg"
=>
"用户名或密码不能为空"
]);
return
view
(
"/login/login"
,
[
"msg"
=>
"用户名或密码不能为空"
]);
}
}
...
@@ -52,7 +48,7 @@ class Login extends Basic
...
@@ -52,7 +48,7 @@ class Login extends Basic
// $result = $this->loginDb->verifyUser($params);
// $result = $this->loginDb->verifyUser($params);
//
//
// if (count($result) > 0) {
// if (count($result) > 0) {
// /
*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"]);
...
@@ -74,9 +70,9 @@ class Login extends Basic
...
@@ -74,9 +70,9 @@ class Login extends Basic
[
'auth_group g'
,
'a.auth_group_id=g.id'
,
'left'
]
[
'auth_group g'
,
'a.auth_group_id=g.id'
,
'left'
]
];
];
$params
[
"name"
]
=
$name
;
$params
[
"name"
]
=
$name
;
$passw
d
=
md5
(
$passw
d
);
$passw
ord
=
md5
(
$passwor
d
);
$where
=
"( phone='
{
$name
}
') and password='
$passwd
' "
;
$where
=
"( phone='
{
$name
}
') and password='
$passw
or
d
' "
;
$list
=
$this
->
login
a
gent
->
verifyUser
(
$filed
,
$join
,
$where
);
$list
=
$this
->
login
A
gent
->
verifyUser
(
$filed
,
$join
,
$where
);
if
(
!
$list
){
if
(
!
$list
){
return
view
(
"/login/login"
,
[
"msg"
=>
"用户名或密码错误"
]);
return
view
(
"/login/login"
,
[
"msg"
=>
"用户名或密码错误"
]);
}
}
...
@@ -86,7 +82,7 @@ class Login extends Basic
...
@@ -86,7 +82,7 @@ class Login extends Basic
}
else
{
}
else
{
$rules
=
trim
(
$list
[
'rules'
],
','
);
$rules
=
trim
(
$list
[
'rules'
],
','
);
$where
=
"id in(
{
$rules
}
)and is_menu=1 and status=1 and pid=1 "
;
$where
=
"id in(
{
$rules
}
)and is_menu=1 and status=1 and pid=1 "
;
$nav
=
$this
->
auth
r
ule
->
loginRule
(
$where
);
$nav
=
$this
->
auth
R
ule
->
loginRule
(
$where
);
//$nav=collection($nav)->toArray();//转化arr
//$nav=collection($nav)->toArray();//转化arr
$nav2
=
array
();
$nav2
=
array
();
$url
=
''
;
//跳转页面
$url
=
''
;
//跳转页面
...
@@ -98,7 +94,7 @@ class Login extends Basic
...
@@ -98,7 +94,7 @@ class Login extends Basic
}
}
//搜索菜单功能
//搜索菜单功能
$where
=
"id in(
{
$rules
}
) and is_menu=0 and status=1 "
;
$where
=
"id in(
{
$rules
}
) and is_menu=0 and status=1 "
;
$r
=
$this
->
auth
r
ule
->
loginRule
(
$where
);
$r
=
$this
->
auth
R
ule
->
loginRule
(
$where
);
$r2
=
array
();
$r2
=
array
();
foreach
(
$r
as
$v
){
foreach
(
$r
as
$v
){
...
@@ -123,7 +119,7 @@ class Login extends Basic
...
@@ -123,7 +119,7 @@ class Login extends Basic
$this
->
operating_records
(
$list
[
"id"
],
1
,
'后台登陆'
);
//记录操作日志
$this
->
operating_records
(
$list
[
"id"
],
1
,
'后台登陆'
);
//记录操作日志
$this
->
redirect
(
'/admin.php/'
.
$url
);
$this
->
redirect
(
'/admin.php/'
.
$url
);
exit
;
// }
// }
...
...
application/model/AuthRule.php
View file @
2e848cae
...
@@ -114,7 +114,15 @@ class AuthRule extends BaseModel
...
@@ -114,7 +114,15 @@ class AuthRule extends BaseModel
$this
->
getLastSql
();
$this
->
getLastSql
();
return
$r
;
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
application/route.php
View file @
2e848cae
...
@@ -96,6 +96,8 @@ Route::group('index', [
...
@@ -96,6 +96,8 @@ Route::group('index', [
'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'
]],
//--规则分类列表
'navigation'
=>
[
'index/Basic/navigation'
,
[
'method'
=>
'get'
]],
//--规则分类列表
'updateRoleStatus'
=>
[
'index/auth/updateRoleStatus'
,
[
'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'
]],
//编辑列表列表界面
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment