Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bigsys
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
bigsys
Commits
161cadd9
Commit
161cadd9
authored
Sep 14, 2017
by
fangzhipeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复根管理员权限bug
parent
3730d816
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
97 additions
and
46 deletions
+97
-46
bigsys-auth/bigsys-auth-project/pom.xml
bigsys-auth/bigsys-auth-project/pom.xml
+6
-0
bigsys-auth/bigsys-auth-project/src/main/java/com/bigsys/auth/project/controller/MenuController.java
...va/com/bigsys/auth/project/controller/MenuController.java
+18
-12
bigsys-auth/bigsys-auth-project/src/main/java/com/bigsys/auth/project/service/RoleMenuService.java
...java/com/bigsys/auth/project/service/RoleMenuService.java
+2
-0
bigsys-auth/bigsys-auth-project/src/main/java/com/bigsys/auth/project/service/impl/RoleMenuServiceImpl.java
...bigsys/auth/project/service/impl/RoleMenuServiceImpl.java
+10
-0
bigsys-auth/bigsys-auth-project/vue/src/mock/menus.js
bigsys-auth/bigsys-auth-project/vue/src/mock/menus.js
+3
-22
bigsys-auth/bigsys-auth-project/vue/src/router/index.js
bigsys-auth/bigsys-auth-project/vue/src/router/index.js
+8
-0
bigsys-auth/bigsys-auth-project/vue/src/views/layout/Sidebar.vue
...auth/bigsys-auth-project/vue/src/views/layout/Sidebar.vue
+45
-3
bigsys-auth/bigsys-auth-project/vue/src/views/pages/role.vue
bigsys-auth/bigsys-auth-project/vue/src/views/pages/role.vue
+5
-9
No files found.
bigsys-auth/bigsys-auth-project/pom.xml
View file @
161cadd9
...
...
@@ -76,6 +76,12 @@
<artifactId>
pagehelper-spring-boot-starter
</artifactId>
<version>
1.2.0
</version>
</dependency>
<dependency>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
<version>
21.0
</version>
</dependency>
</dependencies>
<build>
...
...
bigsys-auth/bigsys-auth-project/src/main/java/com/bigsys/auth/project/controller/MenuController.java
View file @
161cadd9
package
com
.
bigsys
.
auth
.
project
.
controller
;
import
com.bigsys.auth.project.model.Menu
;
import
com.bigsys.auth.project.db.model.User
;
import
com.bigsys.auth.project.service.RoleMenuService
;
import
com.bigsys.auth.project.service.RoleService
;
import
com.bigsys.auth.project.service.UserRoleService
;
import
com.bigsys.auth.project.service.WrapperRole
;
import
com.bigsys.auth.project.util.response.BSResponse
;
import
com.
fasterxml.jackson.databind.JavaType
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.
google.common.collect.Lists
;
import
org.apache.shiro.SecurityUtils
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java
.io.IOException
;
import
java
x.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -15,17 +19,19 @@ import java.util.List;
@RequestMapping
(
value
=
"/menu"
)
public
class
MenuController
{
String
menu
=
"[{\"name\":\"aa\",\"hasSub\":true,\"menus\":[{\"name\":\"bb\",\"link\":\"/index\",\"hasSub\":false}]},{\"name\":\"aa\",\"link\":\"/\",\"hasSub\":false},{\"name\":\"aa\",\"link\":\"/\",\"hasSub\":false},{\"name\":\"系统管理\",\"link\":\"/\",\"hasSub\":true,\"menus\":[{\"name\":\"角色管理\",\"link\":\"/role/index\",\"hasSub\":false},{\"name\":\"权限管理\",\"link\":\"/auth/index\",\"hasSub\":false},{\"name\":\"用户管理\",\"link\":\"/user/index\",\"hasSub\":false},{\"name\":\"菜单管理\",\"link\":\"/user/index\",\"hasSub\":false}]}]"
;
@Resource
private
RoleMenuService
roleMenuService
;
@Resource
private
UserRoleService
userRoleService
;
@RequestMapping
(
value
=
"/getMenus"
)
public
BSResponse
getMenus
(
String
userId
)
{
JavaType
javaType
=
new
ObjectMapper
().
getTypeFactory
().
constructParametricType
(
ArrayList
.
class
,
Menu
.
class
);
List
<
Menu
>
menus
=
null
;
try
{
menus
=
new
ObjectMapper
().
readValue
(
menu
,
javaType
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
public
BSResponse
getMenus
()
{
User
curUser
=
(
User
)
SecurityUtils
.
getSubject
().
getPrincipal
();
userRoleService
.
wrapperRoles
(
Lists
.
newArrayList
(
curUser
));
if
(
curUser
.
getRoleIds
().
contains
(
"admin"
))
{
return
BSResponse
.
ok
(
"all"
);
}
List
<
String
>
menus
=
roleMenuService
.
getRoleMenus
(
curUser
.
getRoleIds
());
return
BSResponse
.
ok
(
menus
);
}
...
...
bigsys-auth/bigsys-auth-project/src/main/java/com/bigsys/auth/project/service/RoleMenuService.java
View file @
161cadd9
...
...
@@ -11,4 +11,6 @@ public interface RoleMenuService extends BaseService<Integer, RoleMenu, RoleMenu
void
addRoleMenus
(
RoleMenus
roleMenus
);
List
<
String
>
getRoleMenus
(
String
role
);
List
<
String
>
getRoleMenus
(
List
<
String
>
roleIds
);
}
bigsys-auth/bigsys-auth-project/src/main/java/com/bigsys/auth/project/service/impl/RoleMenuServiceImpl.java
View file @
161cadd9
...
...
@@ -51,4 +51,14 @@ public class RoleMenuServiceImpl extends BaseServiceImpl<Integer, RoleMenu, Role
.
collect
(
Collectors
.
toList
());
return
menus
;
}
@Override
public
List
<
String
>
getRoleMenus
(
List
<
String
>
roleIds
)
{
List
<
RoleMenu
>
roleMenus
=
selectByExample
((
a
,
b
)
->
{
b
.
andRoleIn
(
roleIds
);
});
return
roleMenus
.
stream
()
.
map
(
roleMenu
->
roleMenu
.
getMenu
())
.
distinct
().
collect
(
Collectors
.
toList
());
}
}
bigsys-auth/bigsys-auth-project/vue/src/mock/menus.js
View file @
161cadd9
export
default
[
{
name
:
'
aa
'
,
hasSub
:
true
,
menus
:
[
{
name
:
'
bb
'
,
link
:
'
/index
'
,
hasSub
:
false
,
menus
:
[]
}
]
},
{
name
:
'
aa
'
,
link
:
'
/
'
,
hasSub
:
false
,
menus
:
[]
},
{
name
:
'
aa
'
,
link
:
'
/
'
,
hasSub
:
false
,
menus
:
[]
name
:
'
测试菜单
'
,
link
:
'
/test
'
,
hasSub
:
false
},
{
name
:
'
系统管理
'
,
...
...
bigsys-auth/bigsys-auth-project/vue/src/router/index.js
View file @
161cadd9
...
...
@@ -21,6 +21,14 @@ import error404 from '../views/pages/404'
**/
export
const
constantRouterMap
=
[
{
path
:
'
/
'
,
component
:
Layout
,
redirect
:
'
/404
'
,
name
:
'
测试页面
'
,
children
:
[
{
path
:
'
test
'
,
component
:
user
,
name
:
'
主页2
'
}
]
},
{
path
:
'
/sys
'
,
component
:
Layout
,
redirect
:
'
/404
'
,
...
...
bigsys-auth/bigsys-auth-project/vue/src/views/layout/Sidebar.vue
View file @
161cadd9
...
...
@@ -21,13 +21,50 @@
<
script
>
import
SidebarItem
from
'
./SidebarItem
'
import
{
mapGetters
}
from
'
vuex
'
import
axios
from
'
axios
'
import
menus
from
'
../../mock/menus
'
var
id
=
10000
export
default
{
components
:
{
SidebarItem
},
created
()
{
this
.
$store
.
dispatch
(
'
GET_MENUS
'
)
axios
.
get
(
'
/api/menu/getMenus
'
).
then
((
response
)
=>
{
if
(
response
.
data
.
data
===
'
all
'
)
{
this
.
menus
=
menus
}
else
{
var
hit
=
(
resmenu
,
link
)
=>
{
for
(
let
i
=
0
;
i
<
resmenu
.
length
;
i
++
)
{
if
(
link
===
resmenu
[
i
])
{
return
true
}
}
return
false
}
var
solveMenu
=
(
copymenu
,
menus
,
resmenu
)
=>
{
menus
.
forEach
((
menu
)
=>
{
var
newmenu
=
{}
newmenu
.
id
=
id
++
newmenu
.
link
=
menu
.
link
newmenu
.
name
=
menu
.
name
newmenu
.
hasSub
=
menu
.
hasSub
if
(
!
menu
.
hasSub
&&
hit
(
resmenu
,
menu
.
link
))
{
copymenu
.
push
(
newmenu
)
}
else
if
(
menu
.
hasSub
)
{
newmenu
.
menus
=
[]
solveMenu
(
newmenu
.
menus
,
menu
.
menus
,
resmenu
)
if
(
newmenu
.
menus
.
length
>
0
)
{
copymenu
.
push
(
newmenu
)
}
}
})
}
var
copymenu
=
[]
solveMenu
(
copymenu
,
menus
,
response
.
data
.
data
)
this
.
menus
=
copymenu
}
})
},
methods
:
{
handleOpen
(
key
,
keyPath
)
{
...
...
@@ -35,10 +72,15 @@
},
handleClose
(
key
,
keyPath
)
{
console
.
log
(
key
,
keyPath
)
},
filter
(
resMenus
,
menus
)
{
}
},
computed
:
{
...
mapGetters
([
'
menus
'
])
data
()
{
return
{
menus
:
menus
}
}
}
</
script
>
bigsys-auth/bigsys-auth-project/vue/src/views/pages/role.vue
View file @
161cadd9
...
...
@@ -94,6 +94,7 @@
}
})
}
addId
(
menus
)
},
methods
:
{
getCheckedNodes
()
{
...
...
@@ -157,11 +158,6 @@
return
}
that
.
curData
=
data
if
(
data
.
parentId
===
'
admin
'
)
{
that
.
data3
=
menus
that
.
dialogVisible
=
true
return
}
var
roleMenus
=
axios
.
get
(
'
/api/role/getRoleMenus?role=
'
+
data
.
parentId
)
var
authedMenus
=
axios
.
get
(
'
/api/role/getRoleMenus?role=
'
+
data
.
id
)
axios
.
all
([
roleMenus
,
authedMenus
]).
then
((
response
)
=>
{
...
...
@@ -193,7 +189,6 @@
}
var
solveCheckedMenu
=
(
copymenu
,
ids
,
checkedMenu
)
=>
{
console
.
log
(
copymenu
)
copymenu
.
forEach
((
menu
)
=>
{
if
(
!
menu
.
hasSub
&&
hit
(
checkedMenu
,
menu
.
link
))
{
ids
.
push
(
menu
.
id
)
...
...
@@ -203,12 +198,13 @@
})
}
var
resmenu
=
response
[
0
].
data
.
data
if
(
data
.
parentId
===
'
admin
'
)
{
resmenu
=
menus
}
var
copymenu
=
[]
solveMenu
(
copymenu
,
menus
,
resmenu
)
that
.
data3
=
copymenu
if
(
data
.
parentId
===
'
admin
'
)
{
that
.
data3
=
menus
copymenu
=
menus
}
var
ids
=
[]
var
checkedMenu
=
response
[
1
].
data
.
data
solveCheckedMenu
(
copymenu
,
ids
,
checkedMenu
)
...
...
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