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
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
[29c0ed0]11@RequestMapping("/api")
[bfa113e]12public class TestController {
13
[29c0ed0]14 AccountService accountService;
[7987457]15
[29c0ed0]16 public TestController(AccountService accountService) {
17 this.accountService = accountService;
[7987457]18 }
19
[29c0ed0]20 @PostMapping(path = "/login")
[83a5af4]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;
[bfa113e]33 }
34
35}
Note: See TracBrowser for help on using the repository browser.