Skip to content

Commit 92f5a02

Browse files
authored
Merge branch 'master' into fix-4779
2 parents 9b15f62 + bb15bec commit 92f5a02

File tree

14 files changed

+61
-101
lines changed

14 files changed

+61
-101
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
restore-keys: ${{ runner.os }}-m2
4545
- name: JDK 8
4646
if: matrix.jdk == '8'
47-
run: mvn -B clean package -P travis jacoco:report -Dmaven.gitcommitid.skip=true
47+
run: mvn -B clean package jacoco:report -Dmaven.gitcommitid.skip=true
4848
- name: JDK 11
4949
if: matrix.jdk == '11'
5050
run: mvn -B clean compile -Dmaven.gitcommitid.skip=true

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Apollo 2.2.0
1818
* [[Multi-Database Support] Optimize column define case sensitivity](https://github.com/apolloconfig/apollo/pull/4776)
1919
* [[Multi-Database Support][pg] Where clause need escape, otherwise will request postgre use lowwer case](https://github.com/apolloconfig/apollo/pull/4780)
2020
* [Misc dependency updates](https://github.com/apolloconfig/apollo/pull/4784)
21+
* [Fix the problem that the deletion failure of the system rights management page does not prompt](https://github.com/apolloconfig/apollo/pull/4803)
22+
* [Fix the issue of the system permission management page retrieving non-existent users](https://github.com/apolloconfig/apollo/pull/4802)
2123

2224
------------------
2325
All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/13?closed=1)

apollo-adminservice/src/test/resources/application.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ spring:
1919

2020
server:
2121
port: ${port:8090}
22-
23-
logging:
24-
level:
25-
org.springframework.cloud: 'DEBUG'
26-
file:
27-
name: /opt/logs/${ctrip.appid}/apollo-adminservice.log
2822

2923
ctrip:
3024
appid: 100003172

apollo-configservice/src/test/resources/application.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ spring:
1919

2020
server:
2121
port: ${port:8080}
22-
23-
logging:
24-
level:
25-
org.springframework.cloud: 'DEBUG'
26-
file:
27-
name: /opt/logs/${ctrip.appid}/apollo-configservice.log
2822

2923
ctrip:
3024
appid: 100003171

apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultRolePermissionService.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@
2828
import com.ctrip.framework.apollo.portal.repository.RoleRepository;
2929
import com.ctrip.framework.apollo.portal.repository.UserRoleRepository;
3030
import com.ctrip.framework.apollo.portal.service.RolePermissionService;
31+
import com.ctrip.framework.apollo.portal.spi.UserService;
3132
import com.google.common.base.Preconditions;
3233
import com.google.common.collect.HashMultimap;
3334
import com.google.common.collect.Lists;
3435
import com.google.common.collect.Multimap;
3536
import com.google.common.collect.Sets;
37+
import java.util.Comparator;
38+
import java.util.LinkedHashSet;
3639
import org.springframework.beans.factory.annotation.Autowired;
3740
import org.springframework.transaction.annotation.Transactional;
3841
import org.springframework.util.CollectionUtils;
@@ -61,6 +64,8 @@ public class DefaultRolePermissionService implements RolePermissionService {
6164
private PortalConfig portalConfig;
6265
@Autowired
6366
private ConsumerRoleRepository consumerRoleRepository;
67+
@Autowired
68+
private UserService userService;
6469

6570
/**
6671
* Create role with permissions, note that role name should be unique
@@ -149,12 +154,15 @@ public Set<UserInfo> queryUsersWithRole(String roleName) {
149154
}
150155

151156
List<UserRole> userRoles = userRoleRepository.findByRoleId(role.getId());
157+
List<UserInfo> userInfos = userService.findByUserIds(userRoles.stream().map(UserRole::getUserId).collect(Collectors.toList()));
158+
159+
if(userInfos == null){
160+
return Collections.emptySet();
161+
}
152162

153-
return userRoles.stream().map(userRole -> {
154-
UserInfo userInfo = new UserInfo();
155-
userInfo.setUserId(userRole.getUserId());
156-
return userInfo;
157-
}).collect(Collectors.toSet());
163+
return userInfos.stream()
164+
.sorted(Comparator.comparing(UserInfo::getUserId))
165+
.collect(Collectors.toCollection(LinkedHashSet::new));
158166
}
159167

160168
/**

apollo-portal/src/main/resources/static/scripts/controller/role/NamespaceRoleController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ role_module.controller('NamespaceRoleController',
3939
.then(function (result) {
4040

4141
}, function (result) {
42-
toastr.warn(AppUtil.errorMsg(result), $translate.instant('Namespace.Role.InitNamespacePermissionError'));
42+
toastr.warning(AppUtil.errorMsg(result), $translate.instant('Namespace.Role.InitNamespacePermissionError'));
4343
});
4444

4545
PermissionService.has_assign_user_permission($scope.pageContext.appId)

apollo-portal/src/main/resources/static/scripts/controller/role/SystemRoleController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ angular.module('systemRole', ['app.service', 'apollo.directive', 'app.util', 'to
6363
getCreateApplicationRoleUsers();
6464
},
6565
function (reason) {
66-
toastr.warn(AppUtil.errorMsg(reason), $translate.instant('SystemRole.DeleteFailed'));
66+
toastr.warning(AppUtil.errorMsg(reason), $translate.instant('SystemRole.DeleteFailed'));
6767
}
6868
);
6969
};

apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/spi/defaultImpl/RolePermissionServiceTest.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
*/
1717
package com.ctrip.framework.apollo.portal.spi.defaultImpl;
1818

19+
import static org.junit.Assert.assertEquals;
20+
import static org.junit.Assert.assertFalse;
21+
import static org.junit.Assert.assertTrue;
22+
1923
import com.ctrip.framework.apollo.common.entity.BaseEntity;
2024
import com.ctrip.framework.apollo.portal.AbstractIntegrationTest;
2125
import com.ctrip.framework.apollo.portal.entity.bo.UserInfo;
@@ -29,19 +33,15 @@
2933
import com.ctrip.framework.apollo.portal.repository.UserRoleRepository;
3034
import com.ctrip.framework.apollo.portal.service.RolePermissionService;
3135
import com.google.common.collect.Sets;
36+
import java.util.List;
37+
import java.util.Set;
38+
import java.util.stream.Collectors;
39+
import org.assertj.core.api.Assertions;
3240
import org.junit.Before;
3341
import org.junit.Test;
3442
import org.springframework.beans.factory.annotation.Autowired;
3543
import org.springframework.test.context.jdbc.Sql;
3644

37-
import java.util.List;
38-
import java.util.Set;
39-
import java.util.stream.Collectors;
40-
41-
import static org.junit.Assert.assertEquals;
42-
import static org.junit.Assert.assertFalse;
43-
import static org.junit.Assert.assertTrue;
44-
4545
/**
4646
* @author Jason Song(song_s@ctrip.com)
4747
*/
@@ -285,13 +285,14 @@ public void testRemoveRoleFromUsersWithRoleNotExisted() throws Exception {
285285
@Sql(scripts = "/sql/permission/insert-test-userroles.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
286286
@Sql(scripts = "/sql/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
287287
public void testQueryUsersWithRole() throws Exception {
288-
String someRoleName = "someRoleName";
289-
290-
Set<UserInfo> users = rolePermissionService.queryUsersWithRole(someRoleName);
288+
String roleName = "someRoleName";
289+
Set<UserInfo> users = rolePermissionService.queryUsersWithRole(roleName);
290+
Assertions.assertThat(users).isEmpty();
291291

292+
roleName = "apolloRoleName";
293+
users = rolePermissionService.queryUsersWithRole(roleName);
292294
Set<String> userIds = users.stream().map(UserInfo::getUserId).collect(Collectors.toSet());
293-
294-
assertTrue(userIds.containsAll(Sets.newHashSet("someUser", "anotherUser")));
295+
assertTrue(userIds.containsAll(Sets.newHashSet("apollo")));
295296
}
296297

297298
@Test

apollo-portal/src/test/resources/application.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ spring:
2020
application:
2121
name: apollo-portal
2222

23-
logging:
24-
level:
25-
org.springframework.cloud: 'DEBUG'
26-
file:
27-
name: /opt/logs/100003173/apollo-portal.log
28-
2923
apollo:
3024
portal:
3125
envs: local

apollo-portal/src/test/resources/sql/permission/insert-test-roles.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
--
1616
INSERT INTO "Role" (`Id`, `RoleName`) VALUES (990, 'someRoleName');
1717
INSERT INTO "Role" (`Id`, `RoleName`) VALUES (991, 'anotherRoleName');
18+
INSERT INTO "Role" (`Id`, `RoleName`) VALUES (992, 'apolloRoleName');

0 commit comments

Comments
 (0)