Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
apollo
Commits
1e165540
Commit
1e165540
authored
Sep 07, 2017
by
Jason Song
Committed by
GitHub
Sep 07, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #742 from lepdou/search_user
return users when search user keyword is empty
parents
b9bca870
ec448a1a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
7 deletions
+9
-7
UserRepository.java
...ip/framework/apollo/portal/repository/UserRepository.java
+3
-1
SpringSecurityUserService.java
.../portal/spi/springsecurity/SpringSecurityUserService.java
+6
-6
No files found.
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRepository.java
View file @
1e165540
...
...
@@ -11,7 +11,9 @@ import java.util.List;
*/
public
interface
UserRepository
extends
PagingAndSortingRepository
<
UserPO
,
Long
>
{
List
<
UserPO
>
findByUsernameLike
(
String
username
);
List
<
UserPO
>
findFirst20ByEnabled
(
int
enabled
);
List
<
UserPO
>
findByUsernameLikeAndEnabled
(
String
username
,
int
enabled
);
UserPO
findByUsername
(
String
username
);
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/springsecurity/SpringSecurityUserService.java
View file @
1e165540
...
...
@@ -18,7 +18,6 @@ import org.springframework.security.provisioning.JdbcUserDetailsManager;
import
org.springframework.util.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -58,18 +57,19 @@ public class SpringSecurityUserService implements UserService {
@Override
public
List
<
UserInfo
>
searchUsers
(
String
keyword
,
int
offset
,
int
limit
)
{
List
<
UserPO
>
users
;
if
(
StringUtils
.
isEmpty
(
keyword
))
{
return
Collections
.
emptyList
();
users
=
userRepository
.
findFirst20ByEnabled
(
1
);
}
else
{
users
=
userRepository
.
findByUsernameLikeAndEnabled
(
"%"
+
keyword
+
"%"
,
1
);
}
List
<
UserPO
>
userPOs
=
userRepository
.
findByUsernameLike
(
"%"
+
keyword
+
"%"
);
List
<
UserInfo
>
result
=
Lists
.
newArrayList
();
if
(
CollectionUtils
.
isEmpty
(
user
PO
s
))
{
if
(
CollectionUtils
.
isEmpty
(
users
))
{
return
result
;
}
result
.
addAll
(
user
PO
s
.
stream
().
map
(
UserPO:
:
toUserInfo
).
collect
(
Collectors
.
toList
()));
result
.
addAll
(
users
.
stream
().
map
(
UserPO:
:
toUserInfo
).
collect
(
Collectors
.
toList
()));
return
result
;
}
...
...
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