From f4e3f70bc2464444e83298106b62781bc2dcb0ad Mon Sep 17 00:00:00 2001 From: Li Shengzhao Date: Thu, 14 Apr 2016 23:55:44 +0800 Subject: [PATCH] Import Mongodb branch codes --- pom.xml | 2 +- .../monkeyk/sos/infrastructure/DateUtils.java | 12 ++------ .../mongo/UserRepositoryMongo.java | 6 +++- src/main/webapp/login.jsp | 30 ------------------- 4 files changed, 8 insertions(+), 42 deletions(-) diff --git a/pom.xml b/pom.xml index 6f5147b..47b971c 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ 2.5.4 1.8.6 - false + true diff --git a/src/main/java/com/monkeyk/sos/infrastructure/DateUtils.java b/src/main/java/com/monkeyk/sos/infrastructure/DateUtils.java index fb23857..82c3664 100644 --- a/src/main/java/com/monkeyk/sos/infrastructure/DateUtils.java +++ b/src/main/java/com/monkeyk/sos/infrastructure/DateUtils.java @@ -1,7 +1,7 @@ package com.monkeyk.sos.infrastructure; -import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.Locale; @@ -30,7 +30,7 @@ public abstract class DateUtils { } public static String toDateTime(Date date) { - return toDateTime(LocalDateTime.from(date.toInstant()), DEFAULT_DATE_TIME_FORMAT); + return toDateTime(date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(), DEFAULT_DATE_TIME_FORMAT); } public static String toDateTime(LocalDateTime dateTime, String pattern) { @@ -38,12 +38,4 @@ public abstract class DateUtils { } - public static String toDateText(LocalDate date, String pattern) { - if (date == null || pattern == null) { - return null; - } - return date.format(DateTimeFormatter.ofPattern(pattern, Locale.SIMPLIFIED_CHINESE)); - } - - } \ No newline at end of file diff --git a/src/main/java/com/monkeyk/sos/infrastructure/mongo/UserRepositoryMongo.java b/src/main/java/com/monkeyk/sos/infrastructure/mongo/UserRepositoryMongo.java index 878e092..041d5f1 100644 --- a/src/main/java/com/monkeyk/sos/infrastructure/mongo/UserRepositoryMongo.java +++ b/src/main/java/com/monkeyk/sos/infrastructure/mongo/UserRepositoryMongo.java @@ -14,6 +14,7 @@ package com.monkeyk.sos.infrastructure.mongo; import com.monkeyk.sos.domain.user.User; import com.monkeyk.sos.domain.user.UserRepository; +import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.domain.Sort; @@ -85,7 +86,10 @@ public class UserRepositoryMongo extends AbstractMongoSupport implements UserRep @Override public List findUsersByUsername(String username) { - Query query = new Query(Criteria.where("username").is(username)); + Query query = new Query(); + if (StringUtils.isNotEmpty(username)) { + query.addCriteria(Criteria.where(username).regex("/*" + username + "/*")); + } return mongoTemplate().find(query, User.class); } } diff --git a/src/main/webapp/login.jsp b/src/main/webapp/login.jsp index 80eb6cb..d908e1d 100644 --- a/src/main/webapp/login.jsp +++ b/src/main/webapp/login.jsp @@ -45,35 +45,5 @@ -
-

You can use the users to login as follow:

- - - - - - - - - - - - - - - - - - - - - - - - - -
UsernamePasswordPrivileges
adminadminAll privileges, allow visit [Mobile] and [Unity] resources
unityunityOnly allow visit [Unity] resource, support grant_type: - authorization_code,refresh_token,implicit
mobilemobileOnly allow visit [Mobile] resource, support grant_type: password,refresh_token
-
\ No newline at end of file