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

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

added response data

  • Property mode set to 100644
File size: 1.1 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@RequestMapping("/api")
12public class TestController {
13
14 AccountService accountService;
15
16 public TestController(AccountService accountService) {
17 this.accountService = accountService;
18 }
19
20 @PostMapping(path = "/login")
21 public AuthResponseDataPojo testPage(@RequestBody AccountLoginDataPojo body) throws ResponseStatusException {
22 Account a1 = accountService.findUser(body.getAccount(), body.getPassword(), body.getType());
23 AuthResponseDataPojo resp = new AuthResponseDataPojo();
24
25 if(a1!=null){
26 resp.setId(a1.getId());
27 resp.setEmail(a1.getEmail());
28 resp.setName(a1.getName());
29 resp.setType(a1.getAccountType());
30 }
31
32 return resp;
33 }
34
35}
Note: See TracBrowser for help on using the repository browser.