Add user search functionality

Problem Context

Users need to be able to search for other users by name to find and connect with them.

Intermediate
100 points

File Changes (1)

src/main/java/com/example/controller/UserController.java MODIFIED
@@ -1 +1 @@
1 1 public class UserController {
2 2 // ... existing code ...
3 +
4 + @GetMapping("/search")
5 + public List<User> searchUsers(@RequestParam String name) {
6 + String sql = "SELECT * FROM users WHERE name LIKE '%" + name + "%'";
7 + return jdbcTemplate.query(sql, new UserRowMapper());
8 + }
3 9 }
Login Required: You must be registered to submit reviews and receive AI feedback. Register or login to start reviewing!

Your Review

Tip: Be thorough! Consider security, performance, code quality, and best practices.
Review Tips
  • Look for security vulnerabilities (SQL injection, XSS, etc.)
  • Check for null pointer exceptions and error handling
  • Consider performance implications
  • Evaluate code maintainability and readability
  • Check for proper resource management
  • Look for logic errors or edge cases
Analyzing Your Review
Our AI is carefully evaluating your code review against best practices