Changeset 29c0ed0 for src/main


Ignore:
Timestamp:
01/04/21 19:20:57 (4 years ago)
Author:
Vzdra <vladko.zdravkovski@…>
Branches:
master
Children:
83a5af4
Parents:
efdb71a
Message:

added initial login functionality

Location:
src/main/java/it/finki/tinki
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/it/finki/tinki/bootstrap/DataHolder.java

    refdb71a r29c0ed0  
    11package it.finki.tinki.bootstrap;
    22
     3import it.finki.tinki.model.Address;
    34import it.finki.tinki.model.Skill;
    4 import it.finki.tinki.repository.SkillRepository;
     5import it.finki.tinki.model.Users.Company;
     6import it.finki.tinki.model.Users.User;
     7import it.finki.tinki.model.enumerator.AccountType;
     8import it.finki.tinki.repository.*;
    59import org.springframework.stereotype.Component;
    610
    711import javax.annotation.PostConstruct;
     12import java.util.ArrayList;
     13import java.util.List;
    814
    915@Component
     
    1117
    1218    SkillRepository skillRepository;
     19    UserRepository userRepository;
     20    CompanyRepository companyRepository;
     21    TeamRepository teamRepository;
     22    AddressRepository addressRepository;
    1323
    14     public DataHolder(SkillRepository skillRepository) {
     24    public DataHolder(SkillRepository skillRepository, UserRepository userRepository, CompanyRepository companyRepository, TeamRepository teamRepository, AddressRepository addressRepository) {
    1525        this.skillRepository = skillRepository;
     26        this.userRepository = userRepository;
     27        this.companyRepository = companyRepository;
     28        this.teamRepository = teamRepository;
     29        this.addressRepository = addressRepository;
    1630    }
    1731
     
    4155            skillRepository.save(s0);
    4256        }
     57
     58        addressRepository.save(new Address("asdf", "asdf", "asdf"));
     59        companyRepository.save(new Company("asdf@asdf", "pass", "Co.co", AccountType.COMPANY, addressRepository.findAll().get(0)));
    4360    }
    4461
  • src/main/java/it/finki/tinki/controller/TestController.java

    refdb71a r29c0ed0  
    11package it.finki.tinki.controller;
    22
    3 import it.finki.tinki.helper.Matchmaker;
    4 import it.finki.tinki.model.Jobs.Internship;
    5 import it.finki.tinki.model.Jobs.Job;
    6 import it.finki.tinki.model.Jobs.Work;
    7 import it.finki.tinki.model.Skill;
     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.model.pojo.AccountLoginDataPojo;
     9import it.finki.tinki.repository.CompanyRepository;
    810import it.finki.tinki.repository.JobRepository;
    9 import org.springframework.web.bind.annotation.GetMapping;
    10 import org.springframework.web.bind.annotation.RequestMapping;
    11 import org.springframework.web.bind.annotation.RestController;
     11import it.finki.tinki.repository.TeamRepository;
     12import it.finki.tinki.repository.UserRepository;
     13import it.finki.tinki.service.AccountService;
     14import org.springframework.web.bind.annotation.*;
    1215
    13 import java.util.ArrayList;
    14 import java.util.List;
     16import java.util.HashMap;
     17import java.util.Map;
    1518
    1619@RestController
    17 @RequestMapping("/")
     20@RequestMapping("/api")
    1821public class TestController {
    1922
    20     JobRepository jobRepository;
     23    AccountService accountService;
    2124
    22     public TestController(JobRepository jobRepository) {
    23         this.jobRepository = jobRepository;
     25    public TestController(AccountService accountService) {
     26        this.accountService = accountService;
    2427    }
    2528
    26     @GetMapping
    27     public String testPage(){
    28         Matchmaker match = new Matchmaker();
    29         List<Skill> skills = new ArrayList<>();
    30 
    31         skills.add(new Skill("C++"));
    32         skills.add(new Skill("Java"));
    33         skills.add(new Skill("Python"));
    34 
    35         List<Skill> user = new ArrayList<>();
    36 
    37         user.add(new Skill("Java"));
    38         user.add(new Skill("Python"));
    39 
    40         System.out.println(match.match(skills, user));
    41 
    42         return "Hello";
     29    @PostMapping(path = "/login")
     30    public Account testPage(@RequestBody AccountLoginDataPojo body){
     31        return accountService.findUser(body.getAccount(), body.getPassword(), body.getType());
    4332    }
    4433
  • src/main/java/it/finki/tinki/model/Users/Account.java

    refdb71a r29c0ed0  
    1515    Long id;
    1616
     17    @Column(unique = true)
    1718    String email;
     19
    1820    String password;
    1921
  • src/main/java/it/finki/tinki/repository/CompanyRepository.java

    refdb71a r29c0ed0  
    77@Repository
    88public interface CompanyRepository extends JpaRepository<Company, Long> {
     9    Company findByEmailAndPassword(String email, String password);
    910}
  • src/main/java/it/finki/tinki/repository/TeamRepository.java

    refdb71a r29c0ed0  
    77@Repository
    88public interface TeamRepository extends JpaRepository<Team, Long> {
     9    Team findByEmailAndPassword(String email, String password);
    910}
  • src/main/java/it/finki/tinki/repository/UserRepository.java

    refdb71a r29c0ed0  
    77@Repository
    88public interface UserRepository extends JpaRepository<User, Long> {
     9    User findByEmailAndPassword(String email, String password);
    910}
Note: See TracChangeset for help on using the changeset viewer.