main
Last change
on this file since 996b8ba was 996b8ba, checked in by trajchevaM <118018439+trajchevaM@…>, 17 months ago |
commit on new and updated functionalities
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[996b8ba] | 1 | package finki.paw5.service.implementation;
|
---|
| 2 |
|
---|
| 3 | import finki.paw5.model.entities.User;
|
---|
| 4 | import finki.paw5.repository.UserRepository;
|
---|
| 5 | import finki.paw5.service.UserService;
|
---|
| 6 | import org.springframework.stereotype.Service;
|
---|
| 7 |
|
---|
| 8 | import java.sql.Date;
|
---|
| 9 | import java.time.LocalDate;
|
---|
| 10 | import java.util.Optional;
|
---|
| 11 |
|
---|
| 12 | @Service
|
---|
| 13 | public class UserServiceImpl implements UserService {
|
---|
| 14 |
|
---|
| 15 | private final UserRepository userRepository;
|
---|
| 16 |
|
---|
| 17 | public UserServiceImpl(UserRepository userRepository) {
|
---|
| 18 | this.userRepository = userRepository;
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | @Override
|
---|
| 22 | public User register(String password, String repeatPassword, String name, String email, String telephone) {
|
---|
| 23 | if (email == null || email.isEmpty() || password == null || password.isEmpty()) {
|
---|
| 24 | //throw new Exception();
|
---|
| 25 | }
|
---|
| 26 | if (!password.equals(repeatPassword)) {
|
---|
| 27 | //throw new Exception();
|
---|
| 28 | }
|
---|
| 29 | if (this.userRepository.findByEmail(email)!=null) {
|
---|
| 30 | //throw new Exception("Username exists:"+email);
|
---|
| 31 | }
|
---|
| 32 | User user = new User(LocalDate.now(), name, email, password, telephone);
|
---|
| 33 | return userRepository.save(user);
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.