Last change
on this file since 83a5af4 was 83a5af4, checked in by Vzdra <vladko.zdravkovski@…>, 4 years ago |
added response data
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | package it.finki.tinki.controller;
|
---|
2 |
|
---|
3 | import it.finki.tinki.model.Users.Account;
|
---|
4 | import it.finki.tinki.model.pojo.AccountLoginDataPojo;
|
---|
5 | import it.finki.tinki.model.pojo.AuthResponseDataPojo;
|
---|
6 | import it.finki.tinki.service.AccountService;
|
---|
7 | import org.springframework.web.bind.annotation.*;
|
---|
8 | import org.springframework.web.server.ResponseStatusException;
|
---|
9 |
|
---|
10 | @RestController
|
---|
11 | @RequestMapping("/api")
|
---|
12 | public 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.