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
RevLine 
[bfa113e]1package it.finki.tinki.controller;
2
[29c0ed0]3import it.finki.tinki.model.Users.Account;
4import it.finki.tinki.model.pojo.AccountLoginDataPojo;
[83a5af4]5import it.finki.tinki.model.pojo.AuthResponseDataPojo;
[29c0ed0]6import it.finki.tinki.service.AccountService;
7import org.springframework.web.bind.annotation.*;
[83a5af4]8import org.springframework.web.server.ResponseStatusException;
[bfa113e]9
10@RestController
[3f5bf9e]11@CrossOrigin(origins = "http://localhost:3000")
[29c0ed0]12@RequestMapping("/api")
[bfa113e]13public class TestController {
14
[29c0ed0]15 AccountService accountService;
[7987457]16
[29c0ed0]17 public TestController(AccountService accountService) {
18 this.accountService = accountService;
[7987457]19 }
20
[29c0ed0]21 @PostMapping(path = "/login")
[83a5af4]22 public AuthResponseDataPojo testPage(@RequestBody AccountLoginDataPojo body) throws ResponseStatusException {
[3f5bf9e]23
24 System.out.println(body);
25
[83a5af4]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;
[bfa113e]37 }
38
39}
Note: See TracBrowser for help on using the repository browser.