Skip to content

Commit

Permalink
Add get all users service.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanVasilev17 committed Dec 26, 2023
1 parent 698e4fa commit e75fa42
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

import javax.ws.rs.NotFoundException;

@Service
@RequiredArgsConstructor
public class AuthenticationService {
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/com/stefan/security/user/UserController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.stefan.security.user;

import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@AllArgsConstructor
@Validated
public class UserController {
private final UserService userService;

@GetMapping("/api/get-all-users")
public List<User> getAllUsers() {
return userService.getAllUsers();
}
}
9 changes: 9 additions & 0 deletions src/main/java/com/stefan/security/user/UserService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.stefan.security.user;


import java.util.List;

public interface UserService {
List<User> getAllUsers();

}
20 changes: 20 additions & 0 deletions src/main/java/com/stefan/security/user/UserServiceImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.stefan.security.user;

import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import java.util.List;

@Service
@AllArgsConstructor
@Validated
public class UserServiceImpl implements UserService {

private final UserRepository userRepository;

@Override
public List<User> getAllUsers() {
return userRepository.findAll();
}
}

0 comments on commit e75fa42

Please sign in to comment.