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
b3ba72e6
Commit
b3ba72e6
authored
Jan 22, 2018
by
zfc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加角色
parent
7621cdd3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
104 additions
and
10 deletions
+104
-10
common.php
application/index/common.php
+6
-0
Auth.php
application/index/controller/Auth.php
+67
-8
index.html
application/index/view/auth/index.html
+4
-0
navigation.html
application/index/view/global/navigation.html
+1
-1
BaseModel.php
application/model/BaseModel.php
+23
-0
route.php
application/route.php
+3
-1
No files found.
application/index/common.php
View file @
b3ba72e6
<?php
//打印
function
prt
(
$arr
){
echo
'<pre/>'
;
print_r
(
$arr
);
}
\ No newline at end of file
application/index/controller/Auth.php
View file @
b3ba72e6
...
...
@@ -12,6 +12,8 @@ use app\index\extend\Basic;
use
app\model\AuthGroup
;
class
Auth
extends
Basic
{
/**
* 权限列表页
*
...
...
@@ -21,12 +23,6 @@ class Auth extends Basic
return
view
(
'index'
);
}
/**
* 角色编辑
*/
public
function
roleedit
()
{
return
view
(
'roleedit'
);
}
/**
* 权限分配
...
...
@@ -55,10 +51,72 @@ class Auth extends Basic
$pageSize
=
empty
(
$params
[
'pageSize'
])
?
15
:
$params
[
'pageSize'
];
$auth_group
=
New
AuthGroup
();
$where
=
'status <> 0'
;
$
data
[
'list'
]
=
$auth_group
->
getList
(
$pageNo
,
$pageSize
,
''
,
'*'
,
$where
);
$
info
[
'list'
]
=
$auth_group
->
getList
(
$pageNo
,
$pageSize
,
''
,
'*'
,
$where
);
$data
[
'total'
]
=
$auth_group
->
getTotal
(
$where
);
return
$this
->
response
(
200
,
''
,
$data
);
}
/**
* 角色编辑
*/
public
function
roleedit
()
{
//$this->assign('type','1');
// return $this->display();
return
view
(
'roleedit'
);
}
/**
* 验证数据
* @param string $validate 验证器名或者验证规则数组
* @param array $data [description]
* @return [type] [description]
*/
protected
function
validateData
(
$data
,
$validate
)
{
if
(
!
$validate
||
empty
(
$data
))
return
false
;
$result
=
$this
->
validate
(
$data
,
$validate
);
if
(
true
!==
$result
){
// 验证失败 输出错误信息
return
$result
;
}
return
1
;
}
//添加角色
public
function
addAuth
(
$group_id
=
0
){
$data
[
'status'
]
=
200
;
$data
[
'msg'
]
=
''
;
$title
=
$group_id
?
'编辑'
:
'新增'
;
$table
=
New
AuthGroup
();
$info
=
$table
->
find
();
if
(
empty
(
$group_id
))
{
$data
=
input
(
'post.'
);
$err
=
$this
->
validateData
(
$data
,
[
[
'title'
,
'require|chsAlpha'
,
'用户组名称不能为空|用户组名称只能是汉字和字母'
],
[
'description'
,
'chsAlphaNum'
,
'描述只能是汉字字母数字'
]
]
);
if
(
$err
!=
1
){
return
$this
->
response
(
100
,
$err
);
}
$id
=
isset
(
$data
[
'id'
])
&&
$data
[
'id'
]
>
0
?
$data
[
'id'
]
:
false
;
if
(
$table
->
editData
(
$data
,
$id
))
{
return
$this
->
response
(
200
,
'成功'
);
}
else
{
return
$this
->
response
(
101
,
'失败'
);
}
}
else
{
return
$this
->
response
(
200
,
$title
,
$info
);
}
}
}
\ No newline at end of file
application/index/view/auth/index.html
View file @
b3ba72e6
{layout name="global/frame_tpl" /}
<h4>
权限管理
</h4>
<a
href=
"/index/roleedit"
>
添加角色
</a>
<input
type=
"hidden"
class=
"page-load"
id=
"auth"
/>
<div
id=
"page-content-wrapper"
>
<div
class=
"container"
>
...
...
application/index/view/global/navigation.html
View file @
b3ba72e6
...
...
@@ -57,7 +57,7 @@
<div
class=
"successModel"
>
<div
class=
"successModel-center"
>
<p>
提交成功!
<!--提交成功!-->
</p>
</div>
</div>
...
...
application/model/BaseModel.php
View file @
b3ba72e6
...
...
@@ -24,6 +24,29 @@ class BaseModel extends Model
return
$this
->
where
(
$params
)
->
count
();
}
/**
* 新增或编辑数据
* @param array/object $data 来源数据
* @param boolean $kv 主键值
* @param string $key 主键名
* @return [type] 执行结果
*/
public
function
editData
(
$data
,
$kv
=
false
,
$key
=
'id'
,
$confirm
=
false
)
{
$this
->
allowField
(
true
);
if
(
$confirm
)
{
//是否验证
$this
->
validate
(
$confirm
);
}
if
(
$kv
){
//编辑
$res
=
$this
->
save
(
$data
,[
$key
=>
$kv
]);
}
else
{
$res
=
$this
->
data
(
$data
)
->
save
();
}
return
$res
;
}
/**
* 列表
*
...
...
application/route.php
View file @
b3ba72e6
...
...
@@ -75,6 +75,7 @@ Route::group('index', [
'addVersion'
=>
[
'index/version/addVersion'
,[
'method'
=>
'post'
]],
'getAuth'
=>
[
'index/auth/getAuth'
,
[
'method'
=>
'get'
]],
//权限列表
'access'
=>
[
'index/auth/access'
,
[
'method'
=>
'get'
]],
//权限分配
'addAuth'
=>
[
'index/auth/addAuth'
,
[
'method'
=>
'post'
]],
//添加角色
'roleedit'
=>
[
'index/auth/roleedit'
,
[
'method'
=>
'get'
]],
//编辑角色
'accessUser'
=>
[
'index/auth/accessUser'
,
[
'method'
=>
'get'
]],
//成员授权
'BusinessDistrict'
=>
[
'index/BusinessDistrict/index'
,
[
'method'
=>
'get'
]],
//商圈列表
...
...
@@ -85,7 +86,8 @@ Route::group('index', [
'houseEdit'
=>
[
'index/Houses/edit'
,
[
'method'
=>
'get|post'
]],
//编辑商铺
'houseDel'
=>
[
'index/Houses/del'
,
[
'method'
=>
'get'
]],
//删除商铺
'regions'
=>
[
'index/BusinessDistrict/regions'
,
[
'method'
=>
'get'
]],
//获取省市区数据
'getHouseList'
=>
[
'index/houses/getHouseList'
,
[
'method'
=>
'get'
]]
'getHouseList'
=>
[
'index/houses/getHouseList'
,
[
'method'
=>
'get'
]],
'regions'
=>
[
'index/BusinessDistrict/regions'
,
[
'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