Skip to content

Commit fa77fc5

Browse files
taoCharles7c
authored andcommitted
fix:修复新建租户的管理员用户角色回显错误
1 parent 1b065b1 commit fa77fc5

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

continew-common/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,4 @@
180180
<artifactId>continew-starter-extension-tenant-mp</artifactId>
181181
</dependency>
182182
</dependencies>
183-
</project>
183+
</project>

continew-system/src/main/java/top/continew/admin/system/service/impl/RoleServiceImpl.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package top.continew.admin.system.service.impl;
1818

19+
import cn.dev33.satoken.stp.StpUtil;
1920
import cn.hutool.core.collection.CollUtil;
2021
import cn.hutool.core.util.ObjectUtil;
2122
import com.alicp.jetcache.anno.CacheInvalidate;
@@ -50,6 +51,7 @@
5051
import java.util.List;
5152
import java.util.Optional;
5253
import java.util.Set;
54+
import java.util.stream.Collectors;
5355

5456
/**
5557
* 角色业务实现
@@ -135,7 +137,13 @@ public void fill(Object obj) {
135137

136138
@Override
137139
public List<LabelValueResp> dict(RoleQuery query, SortQuery sortQuery) {
138-
query.setExcludeRoleCodes(RoleCodeEnum.getSuperRoleCodes());
140+
List<String> currentUserRoleCodes = StpUtil.getRoleList();
141+
final List<String> superRoleCodes = RoleCodeEnum.getSuperRoleCodes();
142+
// dict查询的时候,需要查询当前用户拥有的角色而不是排除,避免前端显示角色数字而不是角色名称
143+
final List<String> excludeRoleCodes = superRoleCodes.stream()
144+
.filter(roleCode -> !currentUserRoleCodes.contains(roleCode))
145+
.collect(Collectors.toList());
146+
query.setExcludeRoleCodes(CollUtil.defaultIfEmpty(excludeRoleCodes, superRoleCodes));
139147
return super.dict(query, sortQuery);
140148
}
141149

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@
114114
<groupId>org.apache.maven.plugins</groupId>
115115
<artifactId>maven-compiler-plugin</artifactId>
116116
<configuration>
117+
<annotationProcessorPaths>
118+
<path>
119+
<groupId>org.projectlombok</groupId>
120+
<artifactId>lombok</artifactId>
121+
</path>
122+
</annotationProcessorPaths>
117123
<compilerArgument>-parameters</compilerArgument>
118124
</configuration>
119125
</plugin>

0 commit comments

Comments
 (0)