Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jeecg-boot
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
jeecg-boot
Commits
ef97f700
Commit
ef97f700
authored
Oct 16, 2021
by
zhangdaiscott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
授权首页菜单后,自定义首页功能不生效 #3069
parent
6fb01abb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
11 deletions
+30
-11
jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/enums/RoleIndexConfigEnum.java
+13
-0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysPermissionController.java
+17
-11
No files found.
jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/enums/RoleIndexConfigEnum.java
View file @
ef97f700
package
org
.
jeecg
.
common
.
constant
.
enums
;
import
java.util.List
;
/**
* 首页自定义
* 通过角色编码与首页组件路径配置
...
...
@@ -64,6 +66,17 @@ public enum RoleIndexConfigEnum {
return
null
;
}
public
static
String
getIndexByRoles
(
List
<
String
>
roles
)
{
for
(
String
role
:
roles
)
{
for
(
RoleIndexConfigEnum
e
:
RoleIndexConfigEnum
.
values
())
{
if
(
e
.
roleCode
.
equals
(
role
))
{
return
e
.
componentUrl
;
}
}
}
return
null
;
}
public
String
getRoleCode
()
{
return
roleCode
;
}
...
...
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysPermissionController.java
View file @
ef97f700
...
...
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.shiro.SecurityUtils
;
import
org.apache.shiro.authz.annotation.RequiresRoles
;
import
org.jeecg.common.api.vo.Result
;
import
org.jeecg.common.constant.CommonConstant
;
import
org.jeecg.common.constant.enums.RoleIndexConfigEnum
;
...
...
@@ -22,6 +23,7 @@ import org.jeecg.modules.system.model.TreeModel;
import
org.jeecg.modules.system.service.*
;
import
org.jeecg.modules.system.util.PermissionDataUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.*
;
...
...
@@ -54,6 +56,12 @@ public class SysPermissionController {
@Autowired
private
ISysUserService
sysUserService
;
/**
* 系统安全模式(true开启,false关闭)
*/
@Value
(
value
=
"${jeecg.safeMode:false}"
)
private
Boolean
sysSafeMode
;
/**
* 加载数据节点
...
...
@@ -215,21 +223,18 @@ public class SysPermissionController {
//update-begin-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
if
(!
PermissionDataUtil
.
hasIndexPage
(
metaList
)){
SysPermission
indexMenu
=
sysPermissionService
.
list
(
new
LambdaQueryWrapper
<
SysPermission
>().
eq
(
SysPermission:
:
getName
,
"首页"
)).
get
(
0
);
metaList
.
add
(
0
,
indexMenu
);
}
//update-end-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
//update-begin--Author:liusq Date:20210624 for:自定义首页地址LOWCOD-1578
List
<
String
>
roles
=
sysUserService
.
getRole
(
loginUser
.
getUsername
());
if
(
roles
.
size
()>
0
){
for
(
String
code:
roles
)
{
String
componentUrl
=
RoleIndexConfigEnum
.
getIndexByCode
(
code
);
if
(
StringUtils
.
isNotBlank
(
componentUrl
)){
indexMenu
.
setComponent
(
componentUrl
);
break
;
}
}
String
compUrl
=
RoleIndexConfigEnum
.
getIndexByRoles
(
roles
);
if
(
StringUtils
.
isNotBlank
(
compUrl
)){
List
<
SysPermission
>
menus
=
metaList
.
stream
().
filter
(
sysPermission
->
"首页"
.
equals
(
sysPermission
.
getName
())).
collect
(
Collectors
.
toList
());
menus
.
get
(
0
).
setComponent
(
compUrl
);
}
//update-end--Author:liusq Date:20210624 for:自定义首页地址LOWCOD-1578
metaList
.
add
(
0
,
indexMenu
);
}
//update-end-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
JSONObject
json
=
new
JSONObject
();
JSONArray
menujsonArray
=
new
JSONArray
();
this
.
getPermissionJsonArray
(
menujsonArray
,
metaList
,
null
);
...
...
@@ -249,6 +254,7 @@ public class SysPermissionController {
json
.
put
(
"auth"
,
authjsonArray
);
//全部权限配置集合(按钮权限,访问权限)
json
.
put
(
"allAuth"
,
allauthjsonArray
);
json
.
put
(
"sysSafeMode"
,
sysSafeMode
);
result
.
setResult
(
json
);
result
.
success
(
"查询成功"
);
}
catch
(
Exception
e
)
{
...
...
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