source: src/main/java/com/example/baza/web/MembersController.java

Last change on this file was ed20c2c, checked in by HumaSejdini <humasejdini12@…>, 2 years ago

Initial commit

  • Property mode set to 100644
File size: 1.4 KB
Line 
1package com.example.baza.web;
2
3import com.example.baza.model.Chlen2;
4import com.example.baza.model.Chovek2;
5import com.example.baza.service.ChlenService;
6import com.example.baza.service.ChovekService;
7import org.springframework.stereotype.Controller;
8import org.springframework.ui.Model;
9import org.springframework.web.bind.annotation.GetMapping;
10import org.springframework.web.bind.annotation.RequestMapping;
11import org.springframework.web.bind.annotation.RequestParam;
12import java.util.*;
13
14@Controller
15@RequestMapping("/members")
16public 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}
Note: See TracBrowser for help on using the repository browser.