source: src/main/java/it/finki/tinki/service/impl/AccountServiceImpl.java@ a222a43

Last change on this file since a222a43 was 29c0ed0, checked in by Vzdra <vladko.zdravkovski@…>, 3 years ago

added initial login functionality

  • Property mode set to 100644
File size: 1.7 KB
Line 
1package it.finki.tinki.service.impl;
2
3import it.finki.tinki.model.Users.Account;
4import it.finki.tinki.model.Users.Company;
5import it.finki.tinki.model.Users.Team;
6import it.finki.tinki.model.Users.User;
7import it.finki.tinki.model.enumerator.AccountType;
8import it.finki.tinki.repository.CompanyRepository;
9import it.finki.tinki.repository.TeamRepository;
10import it.finki.tinki.repository.UserRepository;
11import it.finki.tinki.service.AccountService;
12import org.springframework.stereotype.Service;
13
14import java.util.HashMap;
15import java.util.Map;
16
17@Service
18public class AccountServiceImpl implements AccountService {
19
20 UserRepository userRepository;
21 TeamRepository teamRepository;
22 CompanyRepository companyRepository;
23
24 public AccountServiceImpl(UserRepository userRepository, TeamRepository teamRepository, CompanyRepository companyRepository) {
25 this.userRepository = userRepository;
26 this.teamRepository = teamRepository;
27 this.companyRepository = companyRepository;
28 }
29
30 @Override
31 public Account findUser(String email, String password, AccountType type) {
32
33 if(type.equals(AccountType.USER)){
34 User u1 = userRepository.findByEmailAndPassword(email, password);
35 if(u1!=null){
36 return u1;
37 }
38 }
39 else if(type.equals(AccountType.TEAM)){
40 Team t1 = teamRepository.findByEmailAndPassword(email, password);
41 if(t1!=null){
42 return t1;
43 }
44 }
45 else if(type.equals(AccountType.COMPANY)){
46 Company c1 = companyRepository.findByEmailAndPassword(email, password);
47 if(c1!=null){
48 return c1;
49 }
50 }
51
52 return null;
53 }
54}
Note: See TracBrowser for help on using the repository browser.