Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
杨建斌
/
page
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
1
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
1b542228
authored
2018-03-25 22:59:25 +0800
by
yangjianbin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
init
1 parent
18c151ab
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
3 deletions
application/controllers/Perm.php
application/controllers/Perm.php
View file @
1b54222
...
...
@@ -59,9 +59,31 @@ class Perm extends CI_Controller {
public
function
organization
()
{
$data
=
'[{"id":1,"pId":0,"name":"父节点1 (5人)","open":true},{"id":11,"pId":1,"name":"叶子节点 1-1"},{"id":12,"pId":1,"name":"叶子节点 1-2"},{"id":13,"pId":1,"name":"叶子节点 1-3"},{"id":2,"pId":0,"name":"父节点 2","open":true},{"id":21,"pId":2,"name":"叶子节点 2-1"},{"id":22,"pId":2,"name":"叶子节点 2-2"},{"id":23,"pId":2,"name":"叶子节点 2-3"},{"id":3,"pId":0,"name":"父节点 3","open":true},{"id":31,"pId":3,"name":"叶子节点 3-1"},{"id":32,"pId":3,"name":"叶子节点 3-2"},{"id":33,"pId":3,"name":"叶子节点 3-3"}]'
;
$data
=
json_decode
(
$data
,
true
);
$res
=
json_decode
(
file_get_contents
(
$this
->
config
->
item
(
'apiBaseUrl'
)
.
'department/getTree'
));
$data
=
$res
->
data
;
$arr
=
array
();
foreach
(
$data
as
$k
=>
$v
)
{
$item
=
array
();
$item
[
'id'
]
=
$v
->
id
;
$item
[
'name'
]
=
$v
->
name
;
$item
[
'pId'
]
=
0
;
$item
[
'open'
]
=
true
;
if
(
!
$v
->
children
||
empty
(
$v
->
children
))
{
continue
;
}
$arr
[]
=
$item
;
foreach
(
$v
->
children
as
$kk
=>
$vv
)
{
$item2
=
array
();
$item2
[
'id'
]
=
$v
->
id
;
$item2
[
'name'
]
=
$v
->
name
;
$item2
[
'pId'
]
=
$v
->
id
;
$arr
[]
=
$item2
;
}
$this
->
output
->
set_content_type
(
'application/json'
)
->
set_output
(
json_encode
(
$data
));
}
// $data = '[{"id":1,"pId":0,"name":"父节点1 (5人)","open":true},{"id":11,"pId":1,"name":"叶子节点 1-1"},{"id":12,"pId":1,"name":"叶子节点 1-2"},{"id":13,"pId":1,"name":"叶子节点 1-3"},{"id":2,"pId":0,"name":"父节点 2","open":true},{"id":21,"pId":2,"name":"叶子节点 2-1"},{"id":22,"pId":2,"name":"叶子节点 2-2"},{"id":23,"pId":2,"name":"叶子节点 2-3"},{"id":3,"pId":0,"name":"父节点 3","open":true},{"id":31,"pId":3,"name":"叶子节点 3-1"},{"id":32,"pId":3,"name":"叶子节点 3-2"},{"id":33,"pId":3,"name":"叶子节点 3-3"}]';
// $data = json_decode($data, true);
$this
->
output
->
set_content_type
(
'application/json'
)
->
set_output
(
json_encode
(
$arr
));
}
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment