1 | package com.example.baza.web;
|
---|
2 |
|
---|
3 |
|
---|
4 |
|
---|
5 | import com.example.baza.model.*;
|
---|
6 | import com.example.baza.service.*;
|
---|
7 | import org.springframework.stereotype.Controller;
|
---|
8 | import org.springframework.ui.Model;
|
---|
9 | import org.springframework.web.bind.annotation.*;
|
---|
10 |
|
---|
11 | import java.time.LocalDate;
|
---|
12 | import java.util.List;
|
---|
13 |
|
---|
14 | @Controller
|
---|
15 | @RequestMapping("/borrow")
|
---|
16 | public class PozajmicaController {
|
---|
17 | private final InstancaOdKnigaService instancaOdKnigaService;
|
---|
18 | private final KaznaService kaznaService;
|
---|
19 | private final BibliotekarService bibliotekarService;
|
---|
20 | private final ChlenService chlenService;
|
---|
21 | private final PozajmicaService pozajmicaService;
|
---|
22 | private final ChovekService chovekService;
|
---|
23 | private final IzdavacService izdavacService;
|
---|
24 | private final KategorijaService kategorijaService;
|
---|
25 | private final AvtorService avtorService;
|
---|
26 | private final KnigiService knigiService;
|
---|
27 |
|
---|
28 | public PozajmicaController(InstancaOdKnigaService instancaOdKnigaService, KaznaService kaznaService, BibliotekarService bibliotekarService, ChlenService chlenService, PozajmicaService pozajmicaService, ChovekService chovekService, IzdavacService izdavacService, KategorijaService kategorijaService, AvtorService avtorService, KnigiService knigiService) {
|
---|
29 | this.instancaOdKnigaService = instancaOdKnigaService;
|
---|
30 | this.kaznaService = kaznaService;
|
---|
31 | this.bibliotekarService = bibliotekarService;
|
---|
32 | this.chlenService = chlenService;
|
---|
33 | this.pozajmicaService = pozajmicaService;
|
---|
34 | this.chovekService = chovekService;
|
---|
35 | this.izdavacService = izdavacService;
|
---|
36 | this.kategorijaService = kategorijaService;
|
---|
37 | this.avtorService = avtorService;
|
---|
38 | this.knigiService = knigiService;
|
---|
39 | }
|
---|
40 | @GetMapping
|
---|
41 | public String getProductPage(@RequestParam(required = false) String error, Model model){
|
---|
42 | if(error!=null && !error.isEmpty()){
|
---|
43 | model.addAttribute("hasError",true);
|
---|
44 | model.addAttribute("error",error);
|
---|
45 | }
|
---|
46 | List<Pozajmica> pozajmici=this.pozajmicaService.listAll();
|
---|
47 | List<InstancaOdKniga> isbn=this.instancaOdKnigaService.listAll();
|
---|
48 | List<Bibliotekar2> bibliotekar=this.bibliotekarService.findAll();
|
---|
49 | List<Chlen2> chlen=this.chlenService.findAll();
|
---|
50 | List<Chovek2> chovek=this.chovekService.listAll();
|
---|
51 |
|
---|
52 | model.addAttribute("pozajmici",pozajmici);
|
---|
53 | model.addAttribute("bibliotekar",bibliotekar);
|
---|
54 | model.addAttribute("isbn",isbn);
|
---|
55 | model.addAttribute("chlen",chlen);
|
---|
56 | model.addAttribute("chovek",chovek);
|
---|
57 | return "pozajmica.html";
|
---|
58 | }
|
---|
59 |
|
---|
60 | @GetMapping("/add-borrowed-book")
|
---|
61 | public String addProductPage(Model model){
|
---|
62 | List<Pozajmica> pozajmici=this.pozajmicaService.listAll();
|
---|
63 | List<InstancaOdKniga> isbn=this.instancaOdKnigaService.listAll();
|
---|
64 | List<Bibliotekar2> bibliotekar=this.bibliotekarService.findAll();
|
---|
65 | List<Chlen2> chlen=this.chlenService.findAll();
|
---|
66 | List<Knigi> knigi=this.knigiService.listAll();
|
---|
67 | model.addAttribute("pozajmici",pozajmici);
|
---|
68 | model.addAttribute("bibliotekar",bibliotekar);
|
---|
69 | model.addAttribute("isbn",isbn);
|
---|
70 | model.addAttribute("chlen",chlen);
|
---|
71 | model.addAttribute("knigi",knigi);
|
---|
72 | return "add-borrow";
|
---|
73 | }
|
---|
74 |
|
---|
75 |
|
---|
76 | }
|
---|
77 |
|
---|