source: src/main/java/com/example/moviezone/service/Impl/UserServiceImpl.java@ eb226b2

Last change on this file since eb226b2 was ac25203, checked in by DenicaKj <dkorvezir@…>, 22 months ago

Spring Security

  • Property mode set to 100644
File size: 935 bytes
Line 
1package com.example.moviezone.service.Impl;
2
3import com.example.moviezone.model.User;
4import com.example.moviezone.model.exceptions.UserNotFoundException;
5import com.example.moviezone.repository.UserRepository;
6import com.example.moviezone.service.UserService;
7import org.springframework.stereotype.Service;
8
9import java.util.List;
10
11@Service
12public class UserServiceImpl implements UserService {
13
14 private final UserRepository userRepository;
15
16 public UserServiceImpl(UserRepository userRepository) {
17 this.userRepository = userRepository;
18 }
19
20 @Override
21 public List<User> findAllUsers() {
22 return userRepository.findAll();
23 }
24
25 @Override
26 public User findById(Integer id) {
27 return userRepository.findById(id).orElseThrow(UserNotFoundException::new);
28 }
29
30 @Override
31 public User findByUsername(String username) {
32 return userRepository.findByUsername(username);
33 }
34
35
36}
Note: See TracBrowser for help on using the repository browser.