source: src/main/java/it/finki/tinki/controller/TestController.java@ 3f5bf9e

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

added test login

  • Property mode set to 100644
File size: 1.2 KB
Line 
1package it.finki.tinki.controller;
2
3import it.finki.tinki.model.Users.Account;
4import it.finki.tinki.model.pojo.AccountLoginDataPojo;
5import it.finki.tinki.model.pojo.AuthResponseDataPojo;
6import it.finki.tinki.service.AccountService;
7import org.springframework.web.bind.annotation.*;
8import org.springframework.web.server.ResponseStatusException;
9
10@RestController
11@CrossOrigin(origins = "http://localhost:3000")
12@RequestMapping("/api")
13public class TestController {
14
15 AccountService accountService;
16
17 public TestController(AccountService accountService) {
18 this.accountService = accountService;
19 }
20
21 @PostMapping(path = "/login")
22 public AuthResponseDataPojo testPage(@RequestBody AccountLoginDataPojo body) throws ResponseStatusException {
23
24 System.out.println(body);
25
26 Account a1 = accountService.findUser(body.getAccount(), body.getPassword(), body.getType());
27 AuthResponseDataPojo resp = new AuthResponseDataPojo();
28
29 if(a1!=null){
30 resp.setId(a1.getId());
31 resp.setEmail(a1.getEmail());
32 resp.setName(a1.getName());
33 resp.setType(a1.getAccountType());
34 }
35
36 return resp;
37 }
38
39}
Note: See TracBrowser for help on using the repository browser.