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
5e43b422
Commit
5e43b422
authored
Jan 31, 2018
by
zfc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
刻苦
parent
9239bb9b
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
113 additions
and
38 deletions
+113
-38
Agent.php
application/index/controller/Agent.php
+3
-4
Auth.php
application/index/controller/Auth.php
+19
-16
Login.php
application/index/controller/Login.php
+23
-14
Basic.php
application/index/extend/Basic.php
+25
-2
access.html
application/index/view/auth/access.html
+1
-1
navigation.html
application/index/view/global/navigation.html
+1
-0
AAgents.php
application/model/AAgents.php
+8
-0
AuthGroup.php
application/model/AuthGroup.php
+6
-0
route.php
application/route.php
+2
-1
navigation.js
public/resource/js/navigation.js
+23
-0
public.js
public/resource/js/public.js
+2
-0
No files found.
application/index/controller/Agent.php
View file @
5e43b422
...
...
@@ -176,16 +176,15 @@ class Agent extends Basic
public
function
updateRole
(){
$table
=
New
AAgents
;
$data
=
$this
->
request
->
param
();
$ids
=
$data
[
'ids'
]
;
$ids
=
trim
(
$data
[
'ids'
],
','
)
;
if
(
!
empty
(
$ids
)
&&!
empty
(
$data
[
'group_id'
])){
if
(
$table
->
saveStatus
(
'auth_group_id'
,
$data
[
'group_id'
],
$ids
)){
return
$this
->
response
(
200
,
'成功'
,
$data
);
}
}
return
$this
->
response
(
100
,
'失败'
,
$data
);
}
else
{
return
$this
->
response
(
100
,
'数据为空'
,
$data
);
}
...
...
application/index/controller/Auth.php
View file @
5e43b422
...
...
@@ -263,23 +263,26 @@ class Auth extends Basic
/**
* 设置角色的状态
*/
public
function
setStatus
(
$model
=
'auth_rule'
,
$script
=
false
){
$ids
=
input
(
'request.ids/a'
);
if
(
$model
==
'AuthGroup'
)
{
if
(
is_array
(
$ids
))
{
if
(
in_array
(
1
,
$ids
))
{
$this
->
error
(
'超级管理员不允许操作'
);
}
}
else
{
if
(
$ids
===
1
)
{
$this
->
error
(
'超级管理员不允许操作'
);
}
}
}
else
{
//cache('admin_sidebar_menus_'.$this->currentUser['uid'],null);//清空后台菜单缓存
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
)){
return
$this
->
response
(
200
,
'成功'
,
$data
);
}
else
{
return
$this
->
response
(
100
,
'失败'
,
$data
);
}
parent
::
setStatus
(
$model
);
}
//权限表界面
public
function
authRuleIndex
(){
...
...
application/index/controller/Login.php
View file @
5e43b422
...
...
@@ -3,6 +3,7 @@
namespace
app\index\controller
;
use
app\index\extend\Basic
;
use
app\model\AAgents
;
use
app\model\AdminModel
;
use
think\Request
;
use
think\Session
;
...
...
@@ -18,11 +19,12 @@ class Login extends Basic
{
protected
$loginDb
;
protected
$loginagent
;
public
function
__construct
(
$request
=
null
)
{
parent
::
__construct
(
$request
);
$this
->
loginDb
=
new
AdminModel
();
$this
->
loginagent
=
new
AAgents
();
}
public
function
login
()
...
...
@@ -41,23 +43,30 @@ class Login extends Basic
if
(
!
isset
(
$name
)
||
!
isset
(
$passwd
))
{
return
view
(
"/login/login"
,
[
"msg"
=>
"用户名或密码不能为空"
]);
}
$params
[
"name"
]
=
$name
;
$params
[
"pswd"
]
=
md5
(
md5
(
$passwd
));
$result
=
$this
->
loginDb
->
verifyUser
(
$params
);
if
(
$name
==
'admin'
){
$params
[
"name"
]
=
$name
;
$params
[
"pswd"
]
=
md5
(
md5
(
$passwd
));
$result
=
$this
->
loginDb
->
verifyUser
(
$params
);
if
(
count
(
$result
)
>
0
)
{
//todo 更新登录信息
$this
->
loginDb
->
updateLoginTime
(
$result
[
0
][
"id"
]);
if
(
count
(
$result
)
>
0
)
{
//todo 更新登录信息
$this
->
loginDb
->
updateLoginTime
(
$result
[
0
][
"id"
]);
Session
::
set
(
"userName"
,
$result
[
0
][
"name"
]);
Session
::
set
(
"userId"
,
$result
[
0
][
"id"
]);
Session
::
set
(
"lastLoginTime"
,
time
());
$this
->
operating_records
(
$result
[
0
][
"id"
],
1
,
'后台登陆'
);
//记录操作日志
$this
->
redirect
(
'/admin.php/index/banner'
);
}
else
{
return
view
(
"/login/login"
,
[
"msg"
=>
"用户名或密码错误"
]);
Session
::
set
(
"userName"
,
$result
[
0
][
"name"
]);
Session
::
set
(
"userId"
,
$result
[
0
][
"id"
]);
Session
::
set
(
"lastLoginTime"
,
time
());
$this
->
operating_records
(
$result
[
0
][
"id"
],
1
,
'后台登陆'
);
//记录操作日志
$this
->
redirect
(
'/admin.php/index/banner'
);
}
else
{
return
view
(
"/login/login"
,
[
"msg"
=>
"用户名或密码错误"
]);
}
}
else
{
$params
[
"name"
]
=
$name
;
$params
[
"pswd"
]
=
md5
(
md5
(
$passwd
));
$this
->
loginagent
->
verifyUser
(
$params
);
}
}
/**
...
...
application/index/extend/Basic.php
View file @
5e43b422
...
...
@@ -9,12 +9,14 @@ namespace app\index\extend;
* Time: 9:35
* 基类
*/
use
app\model\AuthGroup
;
use
app\model\GOperatingRecords
;
use
think\Controller
;
use
think\Request
;
use
think\Response
;
use
think\Session
;
use
think\Db
;
use
app\model\AuthRule
;
class
Basic
extends
Controller
{
...
...
@@ -53,15 +55,30 @@ class Basic extends Controller
}
elseif
(
strtoupper
(
$this
->
request
->
method
())
===
"POST"
)
{
$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
))
{
$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
return
Response
::
create
(
$result
,
$type
);
}
public
function
navigation
(){
$table
=
New
AuthGroup
;
$data
=
$table
->
where
(
"pid=1"
)
->
select
();
return
$this
->
response
(
200
,
''
,
$data
);
}
/**
* Cors Options 授权处理
...
...
application/index/view/auth/access.html
View file @
5e43b422
{layout name="global/frame_tpl" /}
<
input
type=
"hidden"
class=
"page-load"
id=
"access"
/>
<!--关联js文件
-->
<
!--<input type="hidden" class="page-load" id="access" /><!–关联js文件–>
-->
<div
id=
"page-content-wrapper"
>
<div
class=
"container"
>
<div
class=
"col-lg-10 col-lg-offset-0"
>
...
...
application/index/view/global/navigation.html
View file @
5e43b422
<nav
class=
"navbar navbar-inverse"
id=
"sidebar-wrapper"
role=
"navigation"
>
<ul
class=
"nav sidebar-nav"
>
<!--便于后期更改使用-->
<!--<li class="sidebar-brand">-->
...
...
application/model/AAgents.php
View file @
5e43b422
...
...
@@ -107,4 +107,11 @@ public function saveList(){
return
$data
;
}
public
function
verifyUser
(
$params
)
{
return
$this
->
db
->
where
(
$params
)
->
select
();
}
}
\ No newline at end of file
application/model/AuthGroup.php
View file @
5e43b422
...
...
@@ -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
;
}
}
application/route.php
View file @
5e43b422
...
...
@@ -86,7 +86,7 @@ Route::group('index', [
'updateAccess'
=>
[
'index/auth/updateAccess'
,
[
'method'
=>
'post'
]],
//--编辑角色权限【接口】
'addAuth'
=>
[
'index/auth/addAuth'
,
[
'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'
]],
//成员授权
'authRuleIndex'
=>
[
'index/auth/authRuleIndex'
,
[
'method'
=>
'get'
]],
//权限列表界面
...
...
@@ -94,6 +94,7 @@ Route::group('index', [
'authRuleBox'
=>
[
'index/auth/authRuleBox'
,
[
'method'
=>
'get'
]],
//--编辑规则
'updateAuthRule'
=>
[
'index/auth/updateAuthRule'
,
[
'method'
=>
'get|post'
]],
//--编辑规则接口
'authClass'
=>
[
'index/auth/authClass'
,
[
'method'
=>
'get'
]],
//--规则分类列表
'navigation'
=>
[
'index/Basic/navigation'
,
[
'method'
=>
'get'
]],
//--规则分类列表
'agent'
=>
[
'index/agent/agent'
,
[
'method'
=>
'get'
]],
//列表
'saveAgentIndex'
=>
[
'index/agent/saveAgentIndex'
,
[
'method'
=>
'get'
]],
//列表
...
...
public/resource/js/navigation.js
0 → 100644
View file @
5e43b422
/* 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
public/resource/js/public.js
View file @
5e43b422
...
...
@@ -32,6 +32,8 @@ function getUrlParam(name) {
if
(
r
!=
null
)
return
unescape
(
r
[
2
]);
return
null
;
}
//字符串格式化
String
.
prototype
.
stringFormat
=
function
(){
var
formatted
=
this
;
...
...
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