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 {
paramMap.put(Constants.Parameters.LAST_NAME, 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
if (searchRequest.getLimit() > 0) {
builder.append(NamedUserQueries.LIMIT);
......
......@@ -156,10 +156,11 @@ public class UserServiceImpl implements UserDetailsService, UserService {
@Override
public User save(User user) {
if (StringUtils.isNotBlank(user.getPassword())) {
String encryptedPassword = bcryptEncoder.encode(user.getPassword());
user.setPassword(encryptedPassword);
if (StringUtils.isBlank(user.getPassword())) {
user.setPassword("UP-SMF#User");
}
String encryptedPassword = bcryptEncoder.encode(user.getPassword());
user.setPassword(encryptedPassword);
return userDao.save(user);
}
......
package com.tarento.retail.util;
import java.util.HashMap;
import java.util.Map;
public class Constants {
/**
......@@ -96,6 +99,8 @@ public class Constants {
public static final String COUNTRY = "country";
public static final String LIMIT = "limit";
public static final String OFFSET = "offset";
public static final String IN_VALUE = "inValues";
public static final String VALUE = "value";
}
public interface EmailTemplate {
......@@ -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 {
Constants.Parameters.COUNTRY);
final String LIMIT = String.format(" limit :%s ", Constants.Parameters.LIMIT);
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