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
5ea6ecbe
Commit
5ea6ecbe
authored
Jan 29, 2018
by
zfc
Committed by
hujun
Jan 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
经纪人列表接口
parent
29c59b60
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
151 additions
and
11 deletions
+151
-11
Agent.php
application/index/controller/Agent.php
+90
-3
Auth.php
application/index/controller/Auth.php
+6
-3
Basic.php
application/index/extend/Basic.php
+1
-0
AAgents.php
application/model/AAgents.php
+41
-0
AuthGroupAccess.php
application/model/AuthGroupAccess.php
+11
-3
auth_rule_box_template_tpl.html
public/resource/template/auth_rule_box_template_tpl.html
+2
-2
No files found.
application/index/controller/Agent.php
View file @
5ea6ecbe
...
...
@@ -26,6 +26,7 @@ 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
;
...
...
@@ -88,16 +89,102 @@ class Agent extends Basic
return
$this
->
response
(
200
,
'成功'
,
$data
);
}
//新增or修改
public
function
saveAgent
(){
/*
* 新增or修改or查看
* $group_id !=0为查看
* post存在id为新增
*
* */
public
function
saveAgent
(
$group_id
=
0
){
$table
=
New
AAgents
;
if
(
IS_POST
&&
$group_id
==
0
)
{
$data
=
input
(
'post.'
);
$id
=
isset
(
$data
[
'id'
])
&&
$data
[
'id'
]
>
0
?
$data
[
'id'
]
:
false
;
//判断name是否重复
if
(
$table
->
repetition
(
'phone'
,
$data
[
'phone'
])
&&
empty
(
$id
)){
return
$this
->
response
(
100
,
'存在重复值'
);
}
//新增或者编辑数据
//prt($data);
if
(
$table
->
editData
(
$data
,
$id
))
{
return
$this
->
response
(
200
,
'成功'
);
}
else
{
return
$this
->
response
(
100
,
'无修改'
);
}
}
else
{
//查看
$info
=
$table
->
where
(
'id'
,
$group_id
)
->
find
();
//echo $table->getLastSql();
return
$this
->
response
(
200
,
'查看'
,
$info
);
}
}
//删除(冻结)
public
function
updateStatus
(){
$data
=
$this
->
request
->
param
();
$ids
=
$data
[
'ids'
];
//排除超级管理员
if
(
is_array
(
$ids
))
{
if
(
in_array
(
1
,
$ids
))
{
return
$this
->
response
(
100
,
'超级管理员不允许操作'
,
$data
);
}
}
else
{
if
(
$ids
===
1
)
{
return
$this
->
response
(
100
,
'超级管理员不允许操作'
,
$data
);
}
}
$table
=
New
AAgents
;
if
(
$table
->
saveStatus
(
$data
[
'name'
],
$data
[
'k'
],
$ids
)){
return
$this
->
response
(
200
,
'成功'
,
$data
);
}
else
{
return
$this
->
response
(
100
,
'失败'
,
$data
);
}
}
//批量变更角色
/**
* 批量变更角色
* @post ids 用户组id
* @post idname 实际id名(auth_group_access表无id)
* @post group_id 变更的角色组id
*/
public
function
updateRole
(){
$table
=
New
AAgents
;
$table2
=
New
AuthGroupAccess
;
$data
=
$this
->
request
->
param
();
$ids
=
$data
[
'ids'
];
//1.清空原有数据
if
(
!
empty
(
$ids
)
&&!
empty
(
$data
[
'group_id'
])
&&!
empty
(
$data
[
'idname'
])){
if
(
$table2
->
delUid
(
$data
[
'idname'
],
$ids
)){
//2.从新分发角色
$data2
[
'group_id'
]
=
$data
[
'group_id'
];
if
(
$table
->
addAllAccess
(
$ids
,
$data2
)){
return
$this
->
response
(
200
,
'成功'
,
$data
);
}
else
{
return
$this
->
response
(
100
,
'失败'
,
$data
);
}
}
}
}
//
...
...
application/index/controller/Auth.php
View file @
5ea6ecbe
...
...
@@ -88,10 +88,13 @@ class Auth extends Basic
}
//添加角色
/*
* 新增or修改or查看
* $group_id !=0为查看
* post存在id为新增
*
* */
public
function
addAuth
(
$group_id
=
0
){
$data
[
'status'
]
=
200
;
$data
[
'msg'
]
=
''
;
$title
=
$group_id
?
'编辑'
:
'新增'
;
$table
=
New
AuthGroup
();
...
...
application/index/extend/Basic.php
View file @
5ea6ecbe
...
...
@@ -60,6 +60,7 @@ class Basic extends Controller
}
/**
* 验证登录时效
*/
...
...
application/model/AAgents.php
View file @
5ea6ecbe
...
...
@@ -30,5 +30,45 @@ public function saveList(){
return
$data
;
}
/**
*检查重复
*
*/
public
function
repetition
(
$name
,
$key
){
$r
=
$this
->
field
(
$name
)
->
where
(
$name
,
'='
,
$key
)
->
select
();
//$this->getLastSql();
if
(
$r
){
return
true
;
}
else
{
return
false
;
}
}
//更新数据
public
function
saveStatus
(
$name
,
$key
,
$ids
){
$r
=
$this
->
save
([
$name
,
$key
],[
"id"
,
'in'
,
$ids
]);
return
$r
;
}
//删除数据
public
function
delUid
(
$name
,
$ids
){
$this
->
where
(
$name
,
'in'
,
$ids
)
->
delete
();
}
//通过ids批量添加数据
public
function
addAllAccess
(
$ids
,
$data
){
$idarr
=
explode
(
$ids
);
if
(
is_array
(
$idarr
)){
$arr
=
array
();
foreach
(
$idarr
as
$v
){
$data
[
'uid'
]
=
$v
;
$arr
[]
=
$data
;
}
$r
=
$this
->
saveAll
(
$arr
);
}
else
{
$data
[
'uid'
]
=
$ids
;
$r
=
$this
->
save
(
$data
);
}
return
$r
;
}
}
\ No newline at end of file
application/model/AuthGroupAccess.php
View file @
5ea6ecbe
<?php
// 权限模型
namespace
app\
admin\
model
;
namespace
app\model
;
class
AuthGroupAccess
extends
Base
use
think\Model
;
class
AuthGroupAccess
extends
BaseModel
{
// 设置完整的数据表(包含前缀)
// protected $table = 'think_access';
...
...
@@ -33,7 +35,13 @@ class AuthGroupAccess extends Base
return
false
;
}
public
function
delUid
(
$name
,
$ids
){
$r
=
$this
->
where
(
$name
,
'in'
,
$ids
)
->
delete
();
return
$r
;
}
/**
* 获取组对应的用户Uids
* @param string $group_id [description]
...
...
public/resource/template/auth_rule_box_template_tpl.html
View file @
5ea6ecbe
...
...
@@ -4,9 +4,9 @@
[
%
for
(
var
item
in
it
){
%
]
[
%
if
(
it
[
item
][
'pid'
]
!=
0
){
%
]
<
option
value
=
"[%= it[item]['id'] %]"
>
&
nbsp
;
&
nbsp
;
└
[
%=
it
[
item
][
"title"
]
%
]
&
nbsp
;
<
/option
>
<
option
value
=
"[%= it[item]['id'] %]"
>
[
%=
it
[
item
][
"title_show"
]
%
]
<
/option
>
[
%
}
else
{
%
]
<
option
value
=
"[%= it[item]['id'] %]"
>
[
%=
it
[
item
][
"title
"
]
%
]
&
nbsp
;
<
/option
>
<
option
value
=
"[%= it[item]['id'] %]"
>
[
%=
it
[
item
][
"title
_show"
]
%
]
<
/option
>
[
%
}
%
]
[
%
}
%
]
...
...
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