Skip to content

Commit

Permalink
Merge pull request #8 from giakinh0823/giakinh0823
Browse files Browse the repository at this point in the history
add search first name and last name user
  • Loading branch information
giakinh0823 authored Mar 10, 2022
2 parents 2d67eb0 + 9df1c87 commit b3a0c20
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/java/dal/auth/UserDBContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,21 @@ public ArrayList<User> findUsers(String value, int pageIndex, int pageSize) {
+ "ON [user_per].[userId] = [user].[id]\n"
+ "INNER JOIN [permission]\n"
+ "ON [permission].[id] = [user_per].[permissionId]\n"
+ " WHERE LOWER([user].[username]) LIKE LOWER(?) or LOWER([user].[email]) LIKE LOWER(?) or LOWER([user].[phone]) LIKE LOWER(?)) [user]\n"
+ " WHERE LOWER([user].[username]) LIKE LOWER(?) or LOWER([user].[email]) LIKE LOWER(?) or LOWER([user].[phone]) LIKE LOWER(?) or LOWER([user].[first_name]) LIKE LOWER(?) or LOWER([user].[last_name]) LIKE LOWER(?)) [user]\n"
+ "WHERE row_index >= (? - 1) * ? + 1 AND row_index <= ? * ?";
PreparedStatement statement = null;
try {
statement = connection.prepareStatement(sql);
statement.setString(1, "%" + value + "%");
statement.setString(2, "%" + value + "%");
statement.setString(3, "%" + value + "%");
statement.setString(4, "%" + value + "%");
statement.setString(5, "%" + value + "%");

statement.setInt(4, pageIndex);
statement.setInt(5, pageSize);
statement.setInt(6, pageIndex);
statement.setInt(7, pageSize);
statement.setInt(8, pageIndex);
statement.setInt(9, pageSize);
ResultSet result = statement.executeQuery();
while (result.next()) {
User user = new User();
Expand Down

0 comments on commit b3a0c20

Please sign in to comment.