1 | package com.example.baza.web;
|
---|
2 |
|
---|
3 | import com.example.baza.model.Chlen2;
|
---|
4 | import com.example.baza.model.Chovek2;
|
---|
5 | import com.example.baza.service.ChlenService;
|
---|
6 | import com.example.baza.service.ChovekService;
|
---|
7 | import org.springframework.stereotype.Controller;
|
---|
8 | import org.springframework.ui.Model;
|
---|
9 | import org.springframework.web.bind.annotation.GetMapping;
|
---|
10 | import org.springframework.web.bind.annotation.RequestMapping;
|
---|
11 | import org.springframework.web.bind.annotation.RequestParam;
|
---|
12 | import java.util.*;
|
---|
13 |
|
---|
14 | @Controller
|
---|
15 | @RequestMapping("/members")
|
---|
16 | public class MembersController {
|
---|
17 |
|
---|
18 | private final ChlenService chlenService;
|
---|
19 | private final ChovekService chovekService;
|
---|
20 |
|
---|
21 | public MembersController(ChlenService chlenService, ChovekService chovekService) {
|
---|
22 | this.chlenService = chlenService;
|
---|
23 | this.chovekService = chovekService;
|
---|
24 | }
|
---|
25 |
|
---|
26 | @GetMapping
|
---|
27 | public String getMembers(@RequestParam(required = false) String error, Model model)
|
---|
28 | {
|
---|
29 | if(error!=null && !error.isEmpty()){
|
---|
30 | model.addAttribute("hasError",true);
|
---|
31 | model.addAttribute("error",error);
|
---|
32 | }
|
---|
33 | List<Chlen2> chlenovi = this.chlenService.findAll();
|
---|
34 | List<Chovek2> lugje = this.chovekService.listAll();
|
---|
35 | model.addAttribute("chlenovi", chlenovi);
|
---|
36 | model.addAttribute("lugje", lugje);
|
---|
37 |
|
---|
38 |
|
---|
39 | return "chlenovi";
|
---|
40 | }
|
---|
41 | @GetMapping("/add")
|
---|
42 | public String showAdd() {
|
---|
43 | return "chlenovi-form";
|
---|
44 | }
|
---|
45 | }
|
---|