Commit 5bc59e07 authored by nivetha's avatar nivetha
Browse files

User default pwd & search user modifications

Showing with 43 additions and 4 deletions
+43 -4
...@@ -909,7 +909,29 @@ public class UserDaoImpl implements UserDao { ...@@ -909,7 +909,29 @@ public class UserDaoImpl implements UserDao {
paramMap.put(Constants.Parameters.LAST_NAME, keyword); paramMap.put(Constants.Parameters.LAST_NAME, keyword);
paramMap.put(Constants.Parameters.COUNTRY, keyword); paramMap.put(Constants.Parameters.COUNTRY, keyword);
} }
// dynamic key value search
if (searchRequest.getSearch() != null && searchRequest.getSearch().size() > 0) {
for (Map.Entry<String, Object> entry : searchRequest.getSearch().entrySet()) {
condition = addQueryCondition(builder, condition);
if (entry.getValue() instanceof List) {
if (Constants.UserSearchFields.MAPPING.containsKey(entry.getKey())) {
builder.append(Constants.UserSearchFields.MAPPING.get(entry.getKey()));
} else {
builder.append(entry.getKey());
}
builder.append(NamedUserQueries.IN_CLAUSE);
paramMap.put(Constants.Parameters.IN_VALUE, entry.getValue());
} else {
if (Constants.UserSearchFields.MAPPING.containsKey(entry.getKey())) {
builder.append(Constants.UserSearchFields.MAPPING.get(entry.getKey()));
} else {
builder.append(entry.getKey());
}
builder.append(NamedUserQueries.APPEND_VALUE);
paramMap.put(Constants.Parameters.VALUE, entry.getValue());
}
}
}
// limit & offset // limit & offset
if (searchRequest.getLimit() > 0) { if (searchRequest.getLimit() > 0) {
builder.append(NamedUserQueries.LIMIT); builder.append(NamedUserQueries.LIMIT);
......
...@@ -156,10 +156,11 @@ public class UserServiceImpl implements UserDetailsService, UserService { ...@@ -156,10 +156,11 @@ public class UserServiceImpl implements UserDetailsService, UserService {
@Override @Override
public User save(User user) { public User save(User user) {
if (StringUtils.isNotBlank(user.getPassword())) { if (StringUtils.isBlank(user.getPassword())) {
String encryptedPassword = bcryptEncoder.encode(user.getPassword()); user.setPassword("UP-SMF#User");
user.setPassword(encryptedPassword);
} }
String encryptedPassword = bcryptEncoder.encode(user.getPassword());
user.setPassword(encryptedPassword);
return userDao.save(user); return userDao.save(user);
} }
......
package com.tarento.retail.util; package com.tarento.retail.util;
import java.util.HashMap;
import java.util.Map;
public class Constants { public class Constants {
/** /**
...@@ -96,6 +99,8 @@ public class Constants { ...@@ -96,6 +99,8 @@ public class Constants {
public static final String COUNTRY = "country"; public static final String COUNTRY = "country";
public static final String LIMIT = "limit"; public static final String LIMIT = "limit";
public static final String OFFSET = "offset"; public static final String OFFSET = "offset";
public static final String IN_VALUE = "inValues";
public static final String VALUE = "value";
} }
public interface EmailTemplate { public interface EmailTemplate {
...@@ -177,4 +182,12 @@ public class Constants { ...@@ -177,4 +182,12 @@ public class Constants {
} }
} }
public interface UserSearchFields {
public static final Map<String, String> MAPPING = new HashMap<String, String>() {
{
put("userId", "usr.id");
}
};
}
} }
...@@ -190,6 +190,9 @@ public interface Sql { ...@@ -190,6 +190,9 @@ public interface Sql {
Constants.Parameters.COUNTRY); Constants.Parameters.COUNTRY);
final String LIMIT = String.format(" limit :%s ", Constants.Parameters.LIMIT); final String LIMIT = String.format(" limit :%s ", Constants.Parameters.LIMIT);
final String OFFSET = String.format(" offset :%s ", Constants.Parameters.OFFSET); final String OFFSET = String.format(" offset :%s ", Constants.Parameters.OFFSET);
final String IN_CLAUSE = String.format(" IN (:%s)", Constants.Parameters.IN_VALUE);
final String APPEND_VALUE = String.format(" = :%s ", Constants.Parameters.VALUE);
} }
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment