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
5fbd3121
Commit
5fbd3121
authored
Feb 05, 2018
by
zfc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
权限正常为0隐藏为1
parent
069d8feb
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
53 additions
and
57 deletions
+53
-57
Agent.php
application/index/controller/Agent.php
+23
-28
Auth.php
application/index/controller/Auth.php
+13
-9
Login.php
application/index/controller/Login.php
+6
-7
Basic.php
application/index/extend/Basic.php
+1
-4
auth_rule_index.html
application/index/view/auth/auth_rule_index.html
+5
-5
AAgents.php
application/model/AAgents.php
+2
-1
AuthRule.php
application/model/AuthRule.php
+3
-3
No files found.
application/index/controller/Agent.php
View file @
5fbd3121
<?php
/**
* 经济人表
* @param id
* @param store_id ------门店id关联门店表
* @param district_id --区域id关联区域表
* @param level ---------等级 10业务员 20店长 30总监
* @param name ----------经济人姓名
* @param phone ---------手机号
* @param password ------登录密码
* @param sex -----------性别 0保密 1男 2女
* @param img -----------头像
* @param status --------账号状态,0正常 1冻结 2离职
* @param inviter_id ---邀请人id
* @param create_time ---创建时间
* @param update_time ---修改时间
* id
* store_id ------门店id关联门店表
* district_id --区域id关联区域表
* level ---------等级 10业务员 20店长 30总监
* name ----------经济人姓名
* phone ---------手机号
* password ------登录密码
* sex -----------性别 0保密 1男 2女
* img -----------头像
* status --------账号状态,0正常 1冻结 2离职
* create_time ---创建时间
* update_time ---修改时间
* Created by PhpStorm.
* User: zfc
* Date: 2018/2/26
...
...
@@ -23,11 +22,7 @@
namespace
app\index\controller
;
use
app\index\extend\Basic
;
use
app\model\AuthGroup
;
use
app\model\AuthRule
;
use
app\model\AAgents
;
use
app\model\AuthGroupAccess
;
use
think\Db
;
use
think\Session
;
class
Agent
extends
Basic
...
...
@@ -57,6 +52,9 @@ class Agent extends Basic
$data
[
'status'
]
=
200
;
$data
[
'msg'
]
=
''
;
$params
=
$this
->
request
->
param
();
//获取操作权限
$userRule
=
Session
::
get
(
'userRule'
);
$data
[
'userRule'
]
=
$userRule
;
$pageNo
=
empty
(
$params
[
'pageNo'
])
?
1
:
$params
[
'pageNo'
];
$pageSize
=
empty
(
$params
[
'pageSize'
])
?
15
:
$params
[
'pageSize'
];
//条件
...
...
@@ -64,23 +62,15 @@ class Agent extends Basic
$search
=
$params
[
'search'
];
// prt($data);
if
(
!
empty
(
$search
)){
// Session::set("search.agent",$search);
$where
.=
" and a.id='
$search
' or a.name like '%
$search
%' or a.phone like '%
$search
%' "
;
$data
[
'search'
]
=
$search
;
}
else
{
// $search=Session::get("search.agent");
// if(!empty($search)){
// $where.=" id='$search' or name like '%$search%' or phone like '%$search%' ";
// $data['search']=$search;
// }
}
$field
=
"a.id,a.store_id,a.district_id,a.`level`,a.`name`,a.phone,a.sex,a.img,a.`status`,a.inviter_id,a.create_time,
ifnull(s.store_name,'')store_name,ifnull(d.district_name,'')district_name"
;
$order
=
'a.id asc'
;
$join
=
[
[
'a_store s'
,
' a.store_id=
a
.id'
,
'left'
],
[
'a_store s'
,
' a.store_id=
s
.id'
,
'left'
],
[
'a_district d'
,
'a.district_id=d.id'
,
'left'
]
];
$data
[
'list'
]
=
$table
->
getListJoin
(
$pageNo
,
$pageSize
,
$order
,
$field
,
$join
,
$where
);
...
...
@@ -99,8 +89,13 @@ class Agent extends Basic
* post存在id为新增
*
* */
public
function
saveAgent
(
$group_id
=
0
){
/**
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
saveAgent
(){
$group_id
=
$this
->
request
->
param
(
'id'
);
$table
=
New
AAgents
;
...
...
application/index/controller/Auth.php
View file @
5fbd3121
...
...
@@ -56,10 +56,7 @@ class Auth extends Basic
$where
=
'status in(0,1)'
;
$search
=
$params
[
'search'
];
if
(
!
empty
(
$search
)){
// Session::set("search.agent",$search);
$where
.=
" and id='
$search
' or title like '%
$search
%' "
;
$data
[
'search'
]
=
$search
;
}
...
...
@@ -316,13 +313,13 @@ class Auth extends Basic
$where
=
'a.status in(0,1)'
;
$search
=
$params
[
'search'
];
if
(
!
empty
(
$search
)){
$where
.=
" and a.id='
$search
' or a.name like '%
$search
%' "
;
$where
.=
" and a.id='
$search
' or a.name like '%
$search
%'
or a.title 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
);
$data
[
'total'
]
=
$table
->
getTotal
(
'status=1
'
);
$data
[
'total'
]
=
$table
->
getTotal
(
$where
,
'a
'
);
// prt($list);//转化arr
//prt(collection($list)->toArray());//转化arr
return
$this
->
response
(
200
,
'成功'
,
$data
);
...
...
@@ -359,12 +356,19 @@ class Auth extends Basic
if
(
$this
->
request
->
isPost
())
{
$data
=
input
(
'post.'
);
$id
=
isset
(
$data
[
'id'
])
&&
$data
[
'id'
]
>
0
?
$data
[
'id'
]
:
false
;
//判断name是否重复
if
(
$table
->
repetition
(
'name'
,
$data
[
'name'
])
&&
empty
(
$id
)){
return
$this
->
response
(
100
,
'存在重复值'
);
return
$this
->
response
(
100
,
'url存在重复值'
);
}
//新增或者编辑数据
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'
];
}
...
...
application/index/controller/Login.php
View file @
5fbd3121
...
...
@@ -37,6 +37,7 @@ class Login extends Basic
*/
public
function
loginVerify
()
{
$name
=
$_POST
[
"username"
];
$password
=
$_POST
[
"passwd"
];
...
...
@@ -76,18 +77,17 @@ class Login extends Basic
$where
=
"( phone='
{
$name
}
') and password='
$password
' "
;
$list
=
$this
->
loginAgent
->
verifyUser
(
$filed
,
$join
,
$where
);
if
(
!
$list
){
return
view
(
"/login/login"
,
[
"msg"
=>
"用户名或密码错误"
]);
}
//
prt($list->toArray());//转化arr
prt
(
$list
->
toArray
());
//转化arr
if
(
$list
[
'admin_off'
]
!=
'0'
||
empty
(
$list
[
'rules'
])){
return
view
(
"/login/login"
,
[
"msg"
=>
"用户无后台访问权限"
]);
}
else
{
$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=
0
and pid=1 "
;
$nav
=
$this
->
authRule
->
loginRule
(
$where
);
//$nav=collection($nav)->toArray();//转化arr
//prt(collection($nav)->toArray());
$nav2
=
array
();
$url
=
''
;
//跳转页面
foreach
(
$nav
as
$k
=>
$v
){
...
...
@@ -96,8 +96,9 @@ class Login extends Basic
}
$nav2
[
$v
->
id
]
=
$v
;
}
//搜索菜单功能
$where
=
"id in(
{
$rules
}
) and is_menu=0 and status=
1
"
;
$where
=
"id in(
{
$rules
}
) and is_menu=0 and status=
0
"
;
$r
=
$this
->
authRule
->
loginRule
(
$where
);
$r2
=
array
();
...
...
@@ -114,7 +115,6 @@ class Login extends Basic
$list
[
'nav'
]
=
$nav2
;
$list2
=
$list
->
toArray
();
//转化arr
}
// Session::delete("userinfo");
Session
::
set
(
"userName"
,
$list
[
"name"
]);
Session
::
set
(
"userId"
,
$list
[
"id"
]);
Session
::
set
(
"userinfo"
,
$list2
);
...
...
@@ -123,7 +123,6 @@ class Login extends Basic
$this
->
operating_records
(
$list
[
"id"
],
1
,
'后台登陆'
);
//记录操作日志
$this
->
redirect
(
'/admin.php/'
.
$url
);
exit
;
// }
...
...
application/index/extend/Basic.php
View file @
5fbd3121
...
...
@@ -63,10 +63,6 @@ class Basic extends Controller
$this
->
userAuth
(
$requestPath
);
$t
=
Session
::
get
(
"usertable"
);
if
(
trim
(
$t
)
==
'agent'
){
$this
->
userAuth
(
$requestPath
);
}
}
/**
...
...
@@ -77,6 +73,7 @@ class Basic extends Controller
*/
public
function
userAuth
(
$requestPath
){
$session
=
Session
::
get
(
"userinfo.nav"
);
$rule
=
0
;
if
(
$session
!=
NULL
)
{
//判断当前控制器用户是否拥有进入权限
...
...
application/index/view/auth/auth_rule_index.html
View file @
5fbd3121
...
...
@@ -31,7 +31,7 @@
<form
class=
"form form-inline"
method=
"get"
action=
"/admin.php/admin/user/index.html"
>
<div
class=
"form-group"
>
<div
class=
"input-group search-form"
>
<input
type=
"text"
name=
"search"
class=
"form-control search-input pull-right"
value=
""
placeholder=
"请输入ID"
>
<input
type=
"text"
name=
"search"
class=
"form-control search-input pull-right"
value=
""
placeholder=
"请输入ID
/部分url/名称
"
>
<span
class=
"input-group-btn"
>
<button
id=
"search"
type=
"button"
class=
"btn btn-success search-btn"
><i
class=
"glyphicon glyphicon-search"
></i></button>
</span>
...
...
@@ -94,7 +94,7 @@
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-3 control-label"
>
链接:
</label>
<input
type=
"text"
value=
""
name=
"name"
class=
"form-control btn6"
>
<input
type=
"text"
value=
""
name=
"name"
placeholder=
'上一级模块名/当前模块名'
class=
"form-control btn6"
>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-3 control-label"
>
后台菜单:
</label>
...
...
@@ -103,20 +103,20 @@
<div
class=
"radio radio-primary fl mr-10"
>
<label
class=
"radio-label1"
for=
"is_menu1"
>
<div
class=
"iradio_minimal-blue checked"
style=
"position: relative;"
aria-checked=
"false"
aria-disabled=
"false"
>
<input
type=
"radio"
value=
"1"
id=
"is_menu1"
name=
"is_menu"
style=
""
>
<input
type=
"radio"
value=
"1"
id=
"is_menu1"
name=
"is_menu"
style=
""
>
</div>
是
</label>
</div>
<div
class=
"radio radio-primary fl mr-10"
>
<label
class=
"radio-label2"
>
<div
class=
"iradio_minimal-blue"
style=
"position: relative;"
aria-checked=
"false"
aria-disabled=
"false"
>
<input
type=
"radio"
value=
"0"
id=
"is_menu2"
name=
"is_menu"
style
=
""
>
<input
type=
"radio"
value=
"0"
id=
"is_menu2"
name=
"is_menu"
required
=
""
>
</div>
否
</label>
</div>
</div>
<div
class=
"help-block "
><i
class=
"fa fa-info-circle color-info1"
></i>
是否标记为
后台
菜单
</div>
</div>
<div
class=
"help-block "
><i
class=
"fa fa-info-circle color-info1"
></i>
是否标记为菜单
</div>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-3 control-label"
>
排序:
</label>
...
...
application/model/AAgents.php
View file @
5fbd3121
...
...
@@ -27,6 +27,7 @@ public function saveList(){
->
limit
(
$pageSize
)
->
page
(
$p
)
->
select
();
//echo $this->getLastSql();
return
$data
;
}
...
...
@@ -115,7 +116,7 @@ public function saveList(){
->
join
(
$join
)
->
where
(
$params
)
->
find
();
echo
$this
->
getLastSql
();
//
echo $this->getLastSql();
return
$r
;
}
...
...
application/model/AuthRule.php
View file @
5fbd3121
...
...
@@ -63,9 +63,9 @@ class AuthRule extends BaseModel
* @param $params
* @return int|string
*/
public
function
getTotal
(
$params
)
public
function
getTotal
(
$params
,
$as
=
''
)
{
return
$this
->
where
(
$params
)
->
count
();
return
$this
->
alias
(
$as
)
->
where
(
$params
)
->
count
();
}
//查询不带分页
...
...
@@ -111,7 +111,7 @@ class AuthRule extends BaseModel
$r
=
$this
->
field
(
'id,name,title,pid'
)
->
where
(
$where
)
->
select
();
$this
->
getLastSql
();
//
$this->getLastSql();
return
$r
;
}
...
...
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